示例#1
0
 // Updates if they exists.
 public void Update(float deltaTime)
 {
     for (int i = 0; i < objects.Count; i++)
     {
         if (!CUtils.IsObjectInScreen(objects[i]))
         {
             objects[i] = null;
             objects.Remove(objects[i]);
         }
     }
     foreach (Bullet obj in objects)
     {
         if (obj != null)
         {
             obj.Run(deltaTime);
         }
         else
         {
             objects.Remove(obj);
         }
     }
 }
示例#2
0
 // Updates the targets list if a object is closer to the ai
 public void UpdateList()
 {
     if (onNewTarget)
     {
         for (int j = 0; j < 3; j++)
         {
             for (int i = 0; i < targets.Count; i++)
             {
                 try
                 {
                     if (i + 1 < targets.Count)
                     {
                         if (CUtils.DistanceABS(position, targets[i].position) > CUtils.DistanceABS(position, targets[i + 1].position))
                         {
                             Object obj = targets[i + 1];
                             targets[i + 1] = targets[i];
                             targets[i]     = obj;
                         }
                     }
                 }
                 catch (IndexOutOfRangeException) { }
             }
         }
         onNewTarget = false;
     }
 }