// This virtual method is automatically called byt map/layer, when update is called from main.cpp virtual void update(float deltaTime) { // Call update to base class CharacterController::update(deltaTime); // AutoAttackFlagCarryingBot if (m_gameObjectToShoot != 0) { float rotation = m_gameObjectToShoot->getRotation(); slm::vec2 enemyForwardDir; enemyForwardDir.x = cosf(rotation); enemyForwardDir.y = sinf(rotation); autoUsePrimaryWeapon(m_gameObjectToShoot->getPosition() + m_predictionDistance*enemyForwardDir, m_aimTolerance); } // DirectMoverAI if (m_gameObjectToGo != 0) { // Move to position m_distanceToDestination = moveDirectToPosition(m_gameObjectToGo->getPosition(), m_reachTolerance); } // If has collided to home base, then drop bomb. if (m_collisionToHomeBase) { // Obly if I has flag if (hasItem()) { dropItem1(); } m_collisionToHomeBase = false; } }
virtual void onMessage(const std::string& msgName, yam2d::Object* eventObject) { CharacterController::onMessage(msgName, eventObject); if (msgName == "Collision") { CollisionEvent* collisionEvent = dynamic_cast<CollisionEvent*>(eventObject); assert(collisionEvent != 0); assert(collisionEvent->getMyGameObject() == getGameObject()); yam2d::GameObject* otherGo = collisionEvent->getOtherGameObject(); std::string otherType = otherGo->getType(); if (otherType == "HomeBase") { if (hasItem()) { dropItem1(); } } } }
void Dummies::update(float deltaTime) { // Call update to base class CharacterController::update(deltaTime); if (m_gameObjectToShoot != 0) { float rotation = m_gameObjectToShoot->getRotation(); slm::vec2 enemyForwardDir; enemyForwardDir.x = cosf(rotation); enemyForwardDir.y = sinf(rotation); autoUsePrimaryWeapon(m_gameObjectToShoot->getPosition() + m_predictionDistance*enemyForwardDir, m_aimTolerance); //if (hasCooledDownSecondary() == true) //{ // tryUseSecondaryWeapon(); //} } // Call update to base class //CharacterController::update(deltaTime); if (m_gameObjectToGo != 0) { // Move to position m_distanceToDestination = moveDirectToPosition(m_gameObjectToGo->getPosition(), m_reachTolerance); } // If has collided to home base, then drop bomb. if (m_collisionToHomeBase) { // Obly if I has flag if (hasItem()) { dropItem1(); } m_collisionToHomeBase = false; } }