void DotaObjective::Spawn( ) { BaseClass::Spawn(); if (CheckLaneMode()) { TakeAction(DOBJ_ACTION_OPEN); } else { TakeAction(DOBJ_ACTION_CLOSE); } }
// Get Packet and command // If the parameter is string parse it. void Action::GivePacket(Packet pkt){ if(pkt.m_MsgType < 0){ std::cout << "[E] No Information in Packet" << std::endl; } else{ m_GivenPkt = pkt; TakeAction(); } }
//------------------------------------------------------------------------------ bool CalculatedPoint::TakeRequiredAction(const Integer id) { #ifdef DEBUG_CP_ACTION MessageInterface::ShowMessage( "Entering CP::TakeRequiredAction with id = %d (%s)\n", id, (GetParameterText(id)).c_str()); #endif if (id == BODY_NAMES) return TakeAction("ClearBodies"); return SpacePoint::TakeRequiredAction(id); }
Action::Action(Packet pkt, Database* db, Socket* sock){ if(pkt.m_MsgType < 0){ std::cout << "[E] No Information in Packet" << std::endl; } else{ m_db = db; m_GivenPkt = pkt; m_sock = sock; TakeAction(); } }
int DotaObjective::OnTakeDamage( const CTakeDamageInfo &inputInfo ) { if ( m_bMet ) return 0; if ( !(inputInfo.GetDamageType() & DMG_BULLET) ) { CHL2MP_Player * playerAttacker = ToHL2MPPlayer( inputInfo.GetAttacker() ); CreepMaker * maker = (CreepMaker*)gEntList.FindEntityByName( NULL, m_creepMakerName ); if ( !maker ) AssertMsg( false, "Objective can't find its creepmaker!\n" ); CAI_BaseNPC * guardian = (CAI_BaseNPC*)gEntList.FindEntityByName( NULL, m_guardianName ); if( guardian && guardian->IsAlive() ) { if( playerAttacker ) ClientPrint( playerAttacker, HUD_PRINTTALK, UTIL_VarArgs("The guradian is alive in this lane, you can't hurt the gate.\n") ); } else { m_timesHit++; m_timesHit = min(m_timesHit, OBJECTIVE_HEALTHI); // make sure times hit never goes above the maximum times an objective can be hit! CRecipientFilter user; user.AddRecipientsByTeam( this->GetTeam() ); user.MakeReliable(); char szText[200]; Q_snprintf( szText, sizeof(szText), "Your ally gate is under attack from an enemy!" ); UTIL_ClientPrintFilter( user, HUD_PRINTCENTER, szText ); if( playerAttacker ) ClientPrint( playerAttacker, HUD_PRINTTALK, UTIL_VarArgs("Gate has %i health left.\n", OBJECTIVE_HEALTHI - m_timesHit) ); if (m_timesHit >= OBJECTIVE_HEALTHI) { TakeAction(DOBJ_ACTION_CLOSE); } else { IGameEvent *pEvent = gameeventmanager->CreateEvent( "objectivegate_attacked" ); if ( pEvent ) { pEvent->SetString( "lane", GetLane() ); pEvent->SetInt( "team", this->GetTeamNumber() ); pEvent->SetFloat( "health", (OBJECTIVE_HEALTHF - m_timesHit)/OBJECTIVE_HEALTHF ); gameeventmanager->FireEvent( pEvent ); } } } } return 0; }
//创建按键监听器,主要监听返回键 void CThankScene::CreateKeyListener() { auto keyListener = EventListenerKeyboard::create(); keyListener->onKeyReleased = [&](EventKeyboard::KeyCode keyCode, Event* event) { if (EventKeyboard::KeyCode::KEY_RETURN == keyCode || EventKeyboard::KeyCode::KEY_ESCAPE == keyCode || EventKeyboard::KeyCode::KEY_BACKSPACE == keyCode) { TakeAction(); } }; _eventDispatcher->addEventListenerWithSceneGraphPriority(keyListener, this); }
//------------------------------------------------------------------------------ bool CalculatedPoint::SetStringParameter(const Integer id, const std::string &value) { #ifdef DEBUG_CP_SET_STRING MessageInterface::ShowMessage("Entering CalculatedPoint::SetString with id = %d (%s), value = %s\n", id, GetParameterText(id).c_str(), value.c_str()); #endif if (id == BODY_NAMES) { if (isBuiltIn) { std::string errmsg = "The value of \""; errmsg += value + "\" for field \"BodyNames\" on built-in CalculatedPoint \"";; errmsg += instanceName + "\" is not an allowed value.\n"; errmsg += "The allowed values are: [None].\n"; throw SolarSystemException(errmsg); } std::string value1 = GmatStringUtil::Trim(value); // If there are names inside a brace-enclosed list, reset the // entire array of names to that list if (GmatStringUtil::IsEnclosedWithBraces(value1)) { // bodyNames.clear(); TakeAction("ClearBodies"); StringArray nameList = GmatStringUtil::ToStringArray(value1); for (unsigned int ii = 0; ii < nameList.size(); ii++) { ValidateBodyName(nameList.at(ii), true, true); } } else { ValidateBodyName(value, true, true); } #ifdef DEBUG_CP_SET_STRING MessageInterface::ShowMessage("Exiting CalculatedPoint::SetString: BodyNames are: \n"); for (unsigned int ii = 0; ii < bodyNames.size(); ii++) MessageInterface::ShowMessage(" %d %s\n", (Integer) ii, (bodyNames.at(ii)).c_str()); #endif return true; } return SpacePoint::SetStringParameter(id, value); }
void CThankScene::CreateTouchListener() { auto touchListener = EventListenerTouchOneByOne::create(); touchListener->onTouchBegan = [&](Touch* touch, Event* event) { return true; }; touchListener->onTouchMoved = [&](Touch* touch, Event* event) { }; touchListener->onTouchEnded = [&](Touch* touch, Event* event) { TakeAction(); }; _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); }
int CAgent::TimeStep(CWorldState* pWorldState) { FilterState(pWorldState,true); //acquire state again as other agents might have changed it if (!IsStateValid()) return -1; UpdateQMatrices(pWorldState, false); //update q matrices from all modules //world state is passed as an argument to calculate rewards int action= SelectAction(); //greedy, e-greedy, ... TakeAction(action,pWorldState); //update world FilterState(pWorldState,false); //acquire state again as other agents might have changed it UpdateQMatrices(pWorldState, true); // FilterState(pWorldState,false); //spread new state among all modules // if (!IsStateValid()) return -1; return action; }
void NPC::Update(int timeElapsedMs) { EvaluateSurroundings(); TakeAction(DetermineAction(), timeElapsedMs); Character::Update(timeElapsedMs); }