예제 #1
0
        public bool ShouldTakeControl()
        {
            //Return true if we're intersecting a radio tower
            for (int i = 0; i < unit.GetVisibleObjects().GetCount(); i++)
            {
                RadioTower t = unit.GetVisibleObjects()[i] as RadioTower;
                if (t != null && !t.IsActive() && unit.HasResources())
                {
                    if (GameMath.TestCircleCircle(t.GetBounds(), unit.GetBounds()))
                    {
                        tower = t;
                        return true;
                    }
                }
            }

            return false;
        }
예제 #2
0
        public bool ShouldTakeControl()
        {
            //Return true if we have a radio tower in mind that isn't active
            if (unit.GetMostRecentTower() != null && !unit.GetMostRecentTower().IsActive() && unit.HasResources())
            {
                tower = unit.GetMostRecentTower();
                return true;
            }

            //or return true if we can see a radio tower
            for (int i = 0; i < unit.GetVisibleObjects().GetCount(); i++)
            {
                RadioTower t = unit.GetVisibleObjects()[i] as RadioTower;
                //If there's a tower I can see, and it's inactive, and I have resources...
                if (t != null && !t.IsActive() && unit.HasResources())
                {
                    tower = t;
                    return true;
                }
            }

            return false;
        }
예제 #3
0
파일: Unit.cs 프로젝트: bschwind/AI-Example
 private void UpdateMostRecentTower()
 {
     for (int i = 0; i < visibleObjects.GetCount(); i++)
     {
         RadioTower t = visibleObjects[i] as RadioTower;
         if (t != null && !t.IsActive())
         {
             if (GameMath.TestCircleCircle(t.GetBounds(), this.GetViewCircle()))
             {
                 mostRecentTower = t;
             }
         }
     }
 }
예제 #4
0
파일: Unit.cs 프로젝트: bschwind/AI-Example
 public void SetMostRecentTower(RadioTower t)
 {
     mostRecentTower = t;
 }