Пример #1
0
 public void ApplyDamage(int damage)
 {
     hp -= damage;
     hpBar.SetHpCurrent(hp);
     Invoke("CreateBlood", 0.3f);
     DamageText.Create(transform, damage);
 }
Пример #2
0
    private void UpdateHealthText(object sender, HealthChangeEventArgs e)
    {
        this.healthText.text = healthSystem.health.ToString();

        if (e.oldValue > e.newValue)
        {
            DamageText.Create(transform.position, e.oldValue - e.newValue);
        }
    }
Пример #3
0
 void DealDamage(GameObject target, int damage)
 {
     target.GetComponent <Alive>().health -= damage;
     DamageText.Create(target.GetComponent <Alive>().location, damage, target.name == "Player");
     Debug.Log(target.name + " took " + damage + " damage!");
     if (target.GetComponent <Alive>().health <= 0)
     {
         if (target.gameObject.name != "Player")
         {
             KillLiving(target);
         }
         else
         {
             //Gameover code goes here
             Debug.Log("Game Over!");
         }
     }
 }