Beispiel #1
0
 //урон
 private void UnitTakeDamage(short damage)
 {
     //первичное обновление
     if (current_health == max_health)
     {
         unit_ui.Find("Health").gameObject.SetActive(true);
     }
     //обработка
     current_health -= damage;
     if (current_health > 0)
     {
         player_controller.RefreshUnitUI(unit_ui, (float)current_health / max_health, 0);
     }
     else
     {
         if (this is EarthUnit)
         {
             player_controller.CheckSelectedUnit(this);
         }
         unit_ui.gameObject.SetActive(false);
         if (an_unit.GetBool("Moving"))
         {
             an_unit.SetBool("Moving", false);
         }
         if (this is EarthUnit)
         {
             an_unit.SetBool("Defense", false);
         }
         rb_unit.velocity = Vector3.zero;
         iMove            = false;
         an_unit.SetTrigger("Dead");
         if (current_zone != null)
         {
             current_zone.ResetUnitList(this);
         }
         GetComponent <CapsuleCollider>().enabled = false;
     }
 }