Example #1
0
 public void SetWarning(Unit unit)
 {
     if (unit.IsProtect()) return;
     bool enable = unit.IsEnable();
     if (enable && !unit.IsProtect()) {
         unit.SetEnable(false);
     }
     foreach (Room other in this.level.GetRooms()) {
         if (!this.level.IsReachFromStart(other, true)) {
             this.SetUnitColor(other, FloorColor.Warning);
         }
     }
     foreach (Route other in this.level.GetRoutes()) {
         if (!this.level.IsReachFromStart(other, true)) {
             this.SetUnitColor(other, FloorColor.Warning);
         }
     }
     if (enable) {
         unit.SetEnable(true);
     }
 }
Example #2
0
 public void DestroyUnit(Unit unit)
 {
     bool rigidbody = this.IsExistPlayer(unit);
     foreach (Vector2 point in unit.GetFloors()) {
         this.DestroyTile(point, rigidbody);
     }
     GameObject player = GameObject.FindWithTag("Player");
     Unit playerUnit = this.GetUnit(player.transform.position);
     if (playerUnit == unit) {
         // kill the player
         player.SendMessage("Death", false);
     } else {
         if (unit.IsEnable()) {
             GameObject radar = GameObject.FindWithTag("Radar");
             radar.SendMessage("DestroyUnit", unit);
             List<GameObject> enemies = new List<GameObject>();
             // Send enemies to controller killed by explosion.
             foreach (GameObject enemy in GameObject.FindGameObjectsWithTag("Enemy")) {
                 if (this.level.GetUnit(this.PositionToMatrix(enemy.transform.position)) == unit) {
                     enemy.SendMessage("Death");
                     enemies.Add(enemy);
                 }
             }
             GameObject controller = GameObject.FindWithTag("GameController");
             controller.SendMessage("DestroyEnemy", enemies);
         }
     }
 }