BWAPI
Skynet/Skynet/GoalAction.cpp
Go to the documentation of this file.
00001 #include "GoalAction.h"
00002 
00003 #include "Vector.h"
00004 
00005 bool GoalAction::update(const Goal &squadGoal, const UnitGroup &squadUnitGroup)
00006 {
00007         switch(squadGoal.getGoalType().underlying())
00008         {
00009         case GoalType::Base:
00010                 {
00011                         Unit enemy = squadGoal.getBase()->getClosestEnemyBuilding(mUnit->getPosition());
00012                         if(enemy)
00013                         {
00014                                 mUnit->move(enemy->getPosition(), 128);
00015                                 return true;
00016                         }
00017                         else
00018                         {
00019                                 mUnit->move(squadGoal.getBase()->getCenterLocation(), 128);
00020                                 return true;
00021                         }
00022                 }
00023         case GoalType::Position:
00024                 mUnit->move(squadGoal.getPosition(), 128);
00025                 return true;
00026         case GoalType::Unit:
00027                 mUnit->move(squadGoal.getUnit()->getPosition(), 128);
00028                 return true;
00029         case GoalType::UnitGroup:
00030                 mUnit->move(squadGoal.getEngageUnits().getClosestUnit(mUnit)->getPosition(), 128);
00031                 return true;
00032         }
00033         return false;
00034 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines