Beispiel #1
0
 /// <summary>
 /// Notify listeners of dead units and remove from the index.
 /// </summary>
 /// <param name="event">Event from the newest ResponseObservation</param>
 private void DeadUnits(Event @event)
 {
     if (@event == null)
     {
         return;
     }
     foreach (var id in @event.DeadUnits)
     {
         if (UnitsSelf.TryGetValue(id, out var deadUnit))
         {
             UnitsSelf.Remove(id);
             Handler.Handle(Case.UnitDestroyed, deadUnit);
         }
         else if (StructuresSelf.TryGetValue(id, out deadUnit))
         {
             StructuresSelf.Remove(id);
             Handler.Handle(Case.StructureDestroyed, deadUnit);
         }
         else if (WorkersSelf.TryGetValue(id, out deadUnit))
         {
             WorkersSelf.Remove(id);
             Handler.Handle(Case.WorkerDestroyed, deadUnit);
         }
         else if (UnitsEnemy.TryGetValue(id, out deadUnit))
         {
             UnitsEnemy.Remove(id);
             Handler.Handle(Case.UnitAddedEnemy, deadUnit);
         }
         else if (StructureEnemy.TryGetValue(id, out deadUnit))
         {
             StructureEnemy.Remove(id);
             Handler.Handle(Case.StructureAddedEnemy, deadUnit);
         }
         else if (WorkersEnemy.TryGetValue(id, out deadUnit))
         {
             WorkersEnemy.Remove(id);
             Handler.Handle(Case.WorkerAddedEnemy, deadUnit);
         }
         else if (MineralFields.TryGetValue(id, out deadUnit))
         {
             MineralFields.Remove(id);
             foreach (var c in Colonies)
             {
                 if (c.Minerals.Remove(deadUnit))
                 {
                     break;
                 }
             }
             Handler.Handle(Case.MineralDepleted, deadUnit);
         }
     }
 }
Beispiel #2
0
        public void DoTestExit(Collider col)
        {
            if (!SelfBaseUnit.IsLive)
            {
                return;
            }
            TUnit unit = col.GetComponent <TUnit>();

            if (unit != null)
            {
                Units.Remove(unit);
                UnitsEnemy.Remove(unit);
                UnitsAlly.Remove(unit);
                UnitsSelf.Remove(unit);
                unit.DetectionMgr.Remove(this, SelfBaseUnit);
                OnExit(unit);
            }
            OnExitObject(col);
        }