public void DicreaseHealth(int dmg)
    {
        currentHealth -= dmg;
        healthBar.UpdateBar(currentHealth, maxHealth);

        if (currentHealth <= mediumHealth)
        {
            healthBar.UpdateColor(Color.yellow);
        }

        if (currentHealth <= criticalHealth)
        {
            healthBar.UpdateColor(Color.red);
        }

        if (currentHealth <= 0)
        {
            GameObject player = gameObject.transform.parent.transform.parent.gameObject;
            if (blood != null)
            {
                Instantiate(blood, player.transform.position, new Quaternion());
            }
            MultiplayerEventManager.TriggerPlayerDead(player.GetComponent <MultiplayerPlayerId>().GetId());
            Destroy(player);
        }
    }
Esempio n. 2
0
 private void FallOutOfMap()
 {
     if (gameObject.tag == "Player" || gameObject.tag == "Enemy")
     {
         AudioForCharacter.FallDeathSound();
         MultiplayerEventManager.TriggerPlayerDead(gameObject.GetComponent <MultiplayerPlayerId>().GetId());
     }
     Destroy(gameObject);
 }