void CPFA_loop_functions::Reset() { if(VariableFoodPlacement == 0) { RNG->Reset(); } GetSpace().Reset(); GetSpace().GetFloorEntity().Reset(); MaxSimCounter = SimCounter; SimCounter = 0; FoodList.clear(); FoodColoringList.clear(); PheromoneList.clear(); FidelityList.clear(); TargetRayList.clear(); // SetFoodDistribution(); argos::CSpace::TMapPerType& footbots = GetSpace().GetEntitiesByType("foot-bot"); argos::CSpace::TMapPerType::iterator it; for(it = footbots.begin(); it != footbots.end(); it++) { argos::CFootBotEntity& footBot = *argos::any_cast<argos::CFootBotEntity*>(it->second); BaseController& c = dynamic_cast<BaseController&>(footBot.GetControllableEntity().GetController()); CPFA_controller& c2 = dynamic_cast<CPFA_controller&>(c); MoveEntity(footBot.GetEmbodiedEntity(), c2.GetStartPosition(), argos::CQuaternion(), false); } }
void Control::CameraControl(){ if (KeyDown(KEY_W)) MoveEntity(dummy,Vec3(0,0,AppSpeed()*0.2*wasdnopeus)); if (KeyDown(KEY_D)) MoveEntity(dummy,Vec3(AppSpeed()*0.2*wasdnopeus,0,0)); if (KeyDown(KEY_A)) MoveEntity(dummy,Vec3(AppSpeed()*-0.2*wasdnopeus,0,0)); if (KeyDown(KEY_S)) MoveEntity(dummy,Vec3(0,0,AppSpeed()*-0.2*wasdnopeus)); if (KeyDown(KEY_Q)) TurnEntity(dummy,Vec3(0,AppSpeed()*1.4*wasdnopeus,0),1); if (KeyDown(KEY_E)) TurnEntity(dummy,Vec3(0,AppSpeed()*-1.4*wasdnopeus,0),1); if (MouseZ() > mousekorkeus) TranslateEntity(dummy,Vec3(0,2*AppSpeed(),0)); if (MouseZ() < mousekorkeus) TranslateEntity(dummy,Vec3(0,-2*AppSpeed(),0)); wasdnopeus = (KeyDown(KEY_LSHIFT))? 2 : 1 ; mousekorkeus = MouseZ(); }
void ETHBucketManager::ResolveMoveRequests() { for (std::list<ETHBucketMoveRequest>::iterator iter = m_moveRequests.begin(); iter != m_moveRequests.end(); ++iter) { // if it's dead, no use in moving it. Let's just discard if (!iter->IsAlive()) { DeleteEntity(iter->GetID()); continue; } MoveEntity(iter->GetID(), iter->GetOldBucket(), iter->GetNewBucket()); } m_moveRequests.clear(); }
void MonsterHunt(Entity_T *e, GLuint delta) { bool frozen = false; Vec2f offset; Vec2i dv[4] = { { 0, 1}, { -1, 0}, { 1, 0}, { 0, -1} }; GLuint dirs[4]; GLuint max_dirs = 0; GLuint num; int i; for(i = 0;i < 4;i++) dirs[i] = 0; offset.x = e->pos.x - game->hero->pos.x; offset.y = e->pos.y - game->hero->pos.y; //Check if the hero is facing them if(offset.y > 0){ if(game->hero->dir == ENTDIR_DOWN) frozen = true; else{ dirs[ENTDIR_UP] += 5; max_dirs +=5; } }else if(offset.y < 0){ if(game->hero->dir == ENTDIR_UP) frozen = true; else{ dirs[ENTDIR_DOWN] += 5; max_dirs +=5; } } if(offset.x > 0){ if(game->hero->dir == ENTDIR_RIGHT) frozen = true; else{ dirs[ENTDIR_LEFT] += 5; max_dirs +=5; } }else if(offset.x < 0){ if(game->hero->dir == ENTDIR_LEFT) frozen = true; else{ dirs[ENTDIR_RIGHT] += 5; max_dirs +=5; } } if(!frozen && max_dirs > 0){ num = Random(max_dirs); //Weighted randoms for(i = 0;i < 4;i++) if(num <= dirs[i]) break; else num -= dirs[i]; if(i != 4){ offset.x = e->pos.x + TILE_WIDTH * dv[i].x; offset.y = e->pos.y + TILE_HEIGHT * dv[i].y; MoveEntity(e, e->onMap, offset); } } e->nextThink = game->currentTime + Random(1000) + 500; }