コード例 #1
0
ファイル: blades_edge_mountains.cpp プロジェクト: Expery/Core
            void UpdateAI(const uint32 diff)
            {
                _events.Update(diff);

                switch (_events.ExecuteEvent())
                {
                    case EVENT_SIMON_PERIODIC_PLAYER_CHECK:
                        if (!CheckPlayer())
                            ResetNode();
                        else
                            _events.ScheduleEvent(EVENT_SIMON_PERIODIC_PLAYER_CHECK, 2000);
                        break;
                    case EVENT_SIMON_SETUP_PRE_GAME:
                        SetUpPreGame();
                        _events.CancelEvent(EVENT_SIMON_GAME_TICK);
                        _events.ScheduleEvent(EVENT_SIMON_PLAY_SEQUENCE, 1000);
                        break;
                    case EVENT_SIMON_PLAY_SEQUENCE:
                        if (!playableSequence.empty())
                        {
                            PlayNextColor();
                            _events.ScheduleEvent(EVENT_SIMON_PLAY_SEQUENCE, 1500);
                        }
                        else
                        {
                            listening = true;
                            DoCast(SPELL_VISUAL_START_PLAYER_LEVEL);
                            playerSequence.clear();
                            PrepareClusters();
                            gameTicks = 0;
                            _events.ScheduleEvent(EVENT_SIMON_GAME_TICK, 3000);
                        }
                        break;
                    case EVENT_SIMON_GAME_TICK:
                        DoCast(SPELL_AUDIBLE_GAME_TICK);

                        if (gameTicks > gameLevel)
                            _events.ScheduleEvent(EVENT_SIMON_TOO_LONG_TIME, 500);
                        else
                            _events.ScheduleEvent(EVENT_SIMON_GAME_TICK, 3000);
                        gameTicks++;
                        break;
                    case EVENT_SIMON_RESET_CLUSTERS:
                        PrepareClusters(true);
                        break;
                    case EVENT_SIMON_TOO_LONG_TIME:
                        DoAction(ACTION_SIMON_WRONG_SEQUENCE);
                        break;
                    case EVENT_SIMON_ROUND_FINISHED:
                        DoAction(ACTION_SIMON_ROUND_FINISHED);
                        break;
                }
            }
コード例 #2
0
ファイル: blades_edge_mountains.cpp プロジェクト: Expery/Core
            /*
            Depending on the number of failed pushes for player the damage of the spell scales, so we first
            cast the spell on the target that hits for 50 and shows the visual and then forces the player
            to cast the damaging spell on it self with the modified basepoints.
            4 fails = death.
            On large nodes punishment and reward are the same, summoning the Apexis Guardian.
            */
            void GivePunishment()
            {
                if (large)
                {
                    if (Player* player = me->GetPlayer(*me, playerGUID))
                        if (Creature* guardian = me->SummonCreature(NPC_APEXIS_GUARDIAN, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() - zCoordCorrection, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 20000))
                            guardian->AI()->AttackStart(player);

                    ResetNode();
                }
                else
                {
                    fails++;

                    if (Player* player = me->GetPlayer(*me, playerGUID))
                        DoCast(player, SPELL_BAD_PRESS_TRIGGER, true);

                    if (fails >= 4)
                        ResetNode();
                }
            }
コード例 #3
0
ファイル: CANOpenShell.c プロジェクト: hauptmech/CANopen_OS
int ProcessFocusedCommand(char* command)
{
	int ret = 0;
	int sec = 0;
	int NodeID;
	int NodeType;
	UNS32 data = 0;
	char buf[50];
    int size;
	int index;
	int subindex = 0;
	int datatype = 0;

	EnterMutex();
	switch(command[0])
	{

		case 's' : /* Slave Start*/
					StartNode(CurrentNode);
					break;
        case 't' : /* slave stop */
					StopNode(CurrentNode);
					break;
        case 'x' : /* slave reset */
					ResetNode(CurrentNode);
					break;
		case 'r' : /* Read device entry */
	                ret = sscanf(command, "r%4x,%2x", &index, &subindex);
                    if (ret)
                        ReadSDOEntry(CurrentNode,index,subindex);
					break;
		case 'w' : /* Write device entry */
	                ret = sscanf(command, "w%4x,%2x,%2x,%x", &index, &subindex, &size, &data);
                    if (ret)
                        WriteSDOEntry(CurrentNode,index,subindex,size,data);
					break;
		case '?' : /* Read device entry */
                    ReadSDOEntry(CurrentNode,0x6041,0);
					break;
		case 'c' : /* Write device entry */
	                ret = sscanf(command, "w%x", &data);
                    if (ret)
                        WriteSDOEntry(CurrentNode,0x6040,0,0x2,data);
					break;
		
		default :
					help_menu();
	}
	LeaveMutex();
	return 0;
}
コード例 #4
0
ファイル: blades_edge_mountains.cpp プロジェクト: Expery/Core
 void DoAction(const int32 action)
 {
     switch (action)
     {
         case ACTION_SIMON_ROUND_FINISHED:
             listening = false;
             DoCast(SPELL_VISUAL_START_AI_LEVEL);
             GiveRewardForLevel(gameLevel);
             _events.CancelEventGroup(0);
             if (gameLevel == 10)
                 ResetNode();
             else
                 _events.ScheduleEvent(EVENT_SIMON_SETUP_PRE_GAME, 1000);
             break;
         case ACTION_SIMON_CORRECT_FULL_SEQUENCE:
             gameLevel++;
             DoAction(ACTION_SIMON_ROUND_FINISHED);
             break;
         case ACTION_SIMON_WRONG_SEQUENCE:
             GivePunishment();
             DoAction(ACTION_SIMON_ROUND_FINISHED);
             break;
     }
 }
コード例 #5
0
ファイル: CANOpenShell.c プロジェクト: AubrCool/canfestival
/* Reset all nodes on the network and print message when boot-up*/
void DiscoverNodes()
{
	printf("Wait for Slave nodes bootup...\n\n");
	ResetNode(0x00);
}
コード例 #6
0
ファイル: CANOpenShell.c プロジェクト: AubrCool/canfestival
int ProcessCommand(char* command)
{
	int ret = 0;
	int sec = 0;
	int NodeID;
	int NodeType;

	EnterMutex();
	switch(cst_str4(command[0], command[1], command[2], command[3]))
	{
		case cst_str4('h', 'e', 'l', 'p') : /* Display Help*/
					help_menu();
					break;
		case cst_str4('s', 's', 't', 'a') : /* Slave Start*/
					StartNode(ExtractNodeId(command + 5));
					break;
		case cst_str4('s', 's', 't', 'o') : /* Slave Stop */
					StopNode(ExtractNodeId(command + 5));
					break;
		case cst_str4('s', 'r', 's', 't') : /* Slave Reset */
					ResetNode(ExtractNodeId(command + 5));
					break;
		case cst_str4('i', 'n', 'f', 'o') : /* Retrieve node informations */
					GetSlaveNodeInfo(ExtractNodeId(command + 5));
					break;
		case cst_str4('r', 's', 'd', 'o') : /* Read device entry */
					ReadDeviceEntry(command);
					break;
		case cst_str4('w', 's', 'd', 'o') : /* Write device entry */
					WriteDeviceEntry(command);
					break;
		case cst_str4('s', 'c', 'a', 'n') : /* Display master node state */
					DiscoverNodes();
					break;
		case cst_str4('w', 'a', 'i', 't') : /* Display master node state */
					ret = sscanf(command, "wait#%d", &sec);
					if(ret == 1) {
						LeaveMutex();
						SleepFunction(sec);
						return 0;
					}
					break;
		case cst_str4('q', 'u', 'i', 't') : /* Quit application */
					LeaveMutex();
					return QUIT;
		case cst_str4('l', 'o', 'a', 'd') : /* Library Interface*/
					ret = sscanf(command, "load#%100[^,],%30[^,],%4[^,],%d,%d",
							LibraryPath,
							BoardBusName,
							BoardBaudRate,
							&NodeID,
							&NodeType);

					if(ret == 5)
					{
						LeaveMutex();
						ret = NodeInit(NodeID, NodeType);
						return ret;
					}
					else
					{
						printf("Invalid load parameters\n");
					}
					break;
		default :
					help_menu();
	}
	LeaveMutex();
	return 0;
}
コード例 #7
0
bool CCharShape::Collision (const TVector3d& pos, const TPolyhedron& ph) {
	ResetNode (0);
	TranslateNode (0, TVector3d (pos.x, pos.y, pos.z));
	return CheckCollision (ph);
}
コード例 #8
0
void CCharShape::ResetJoints () {
	ResetNode ("left_shldr");
	ResetNode ("right_shldr");
	ResetNode ("left_hip");
	ResetNode ("right_hip");
	ResetNode ("left_knee");
	ResetNode ("right_knee");
	ResetNode ("left_ankle");
	ResetNode ("right_ankle");
	ResetNode ("tail");
	ResetNode ("neck");
	ResetNode ("head");
}
コード例 #9
0
bool CCharShape::ResetNode (const string& node_trivialname) {
	map<string, size_t>::const_iterator i = NodeIndex.find(node_trivialname);
	if (i == NodeIndex.end()) return false;
	return ResetNode (i->second);
}
コード例 #10
0
ファイル: tux.cpp プロジェクト: RKSimon/extremetuxracer
bool CCharShape::Collision (TVector3 pos, TPolyhedron ph) {
	ResetNode (0);
	TranslateNode (0, MakeVector (pos.x, pos.y, pos.z));	
	return CheckCollision (ph);
}
コード例 #11
0
ファイル: tux.cpp プロジェクト: RKSimon/extremetuxracer
void CCharShape::ResetRoot () { 
	ResetNode (0);
}
コード例 #12
0
ファイル: tux.cpp プロジェクト: RKSimon/extremetuxracer
bool CCharShape::ResetNode (string node_trivialname) {
	int node_name = SPIntN (NodeIndex, node_trivialname, -1);
	if (node_name < 0) return false;
	return ResetNode (node_name);
}
コード例 #13
0
ファイル: CANOpenShell.c プロジェクト: hauptmech/CANopen_OS
int ProcessCommand(char* command)
{
	int ret = 0;
	int sec = 0;
	int NodeID;
	int NodeType;
	UNS32 data = 0;
	char buf[50];

	EnterMutex();
	switch(cst_str4(command[0], command[1], command[2], command[3]))
	{
		case cst_str4('h', 'e', 'l', 'p') : /* Display Help*/
					help_menu();
					break;
		case cst_str4('c', 'l', 'e', 'a') : /* Display Help*/
					system(CLEARSCREEN);
					break;					
		case cst_str4('s', 's', 't', 'a') : /* Slave Start*/
					StartNode(ExtractNodeId(command + 5));
					break;
		case cst_str4('s', 's', 't', 'o') : /* Slave Stop */
					StopNode(ExtractNodeId(command + 5));
					break;
		case cst_str4('s', 'r', 's', 't') : /* Slave Reset */
					ResetNode(ExtractNodeId(command + 5));
					break;
		case cst_str4('i', 'n', 'f', 'o') : /* Retrieve node informations */
					GetSlaveNodeInfo(ExtractNodeId(command + 5));
					break;
		case cst_str4('r', 's', 'd', 'o') : /* Read device entry */
					ReadDeviceEntry(command);
					break;
		case cst_str4('w', 's', 'd', 'o') : /* Write device entry */
					WriteDeviceEntry(command);
					break;
		case cst_str4('n', 'o', 'd', 'e') : /* Write device entry */
					ret = sscanf(command, "node %2x", &NodeID);
					data = 0;
					SDO_write(CANOpenShellOD_Data,NodeID,0x1024,0x00,1, 0, &data, 0);
					CurrentNode = NodeID;
					break;
		case cst_str4('c', 'm', 'd', ' ') : /* Write device entry */

					ret = sscanf(command, "cmd %2x,%s", &NodeID, buf );
					SDO_write(CANOpenShellOD_Data,NodeID,0x1023,0x01,strlen(buf),visible_string, buf, 0);
					SDO_read(CANOpenShellOD_Data,NodeID,0x1023,0x03,visible_string,0);
					
					return 0;
					break;

		case cst_str4('s', 'y', 'n', '0') : /* Display master node state */
                    stopSYNC(CANOpenShellOD_Data);
                    break;
		case cst_str4('s', 'y', 'n', '1') : /* Display master node state */
                    startSYNC(CANOpenShellOD_Data);
                    break;
		case cst_str4('s', 't', 'a', 't') : /* Display master node state */
                    printf("Status3: %x\n",Status3);
                    Status3 = 0;
                    break;
		case cst_str4('s', 'c', 'a', 'n') : /* Display master node state */
					DiscoverNodes();
					break;
		case cst_str4('w', 'a', 'i', 't') : /* Display master node state */
					ret = sscanf(command, "wait#%d", &sec);
					if(ret == 1) {
						LeaveMutex();
						SleepFunction(sec);
						return 0;
					}
					break;
		case cst_str4('g', 'o', 'o', 'o') : /* Quit application */
            setState(CANOpenShellOD_Data, Operational);
            break;
		case cst_str4('q', 'u', 'i', 't') : /* Quit application */
					LeaveMutex();
					return QUIT;
		case cst_str4('l', 'o', 'a', 'd') : /* Library Interface*/
					ret = sscanf(command, "load#%100[^,],%30[^,],%4[^,],%d,%d",
							LibraryPath,
							BoardBusName,
							BoardBaudRate,
							&NodeID,
							&NodeType);

					if(ret == 5)
					{
						LeaveMutex();
						ret = NodeInit(NodeID, NodeType);
						return ret;
					}
					else
					{
						printf("Invalid load parameters\n");
					}
					break;
		default :
					help_menu();
	}
	LeaveMutex();
	return 0;
}