Esempio n. 1
0
    public void TakeDamage(int dmg)
    {
        curHP -= dmg;
        healthbar.SetHealth(curHP);
        if (HPnumbers != null)
        {
            updateText();
        }
        if (curHP <= 0)
        {
            if (isPlayer)
            {
                //respawn character
                lvl.respawn();
                healthbar.SetHealth(maxHP);
            }
            else
            {
                Destroy(this.gameObject);
            }
        }

        //update save data
        if (isPlayer)
        {
            data.hp = curHP;
        }
    }
Esempio n. 2
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("Player"))
     {
         //add death animation in future
         level.respawn();
     }
 }