Ejemplo n.º 1
0
    public void DealDamage(int damageDealt)
    {
        // Get the script on the enemy with this interface
        IEnemy enemyScript = gameObject.GetComponent <IEnemy>();

        // If enemy cant take damage, return
        if (!enemyScript.CanTakeDamage())
        {
            return;
        }

        // Deal damage to enemy
        health -= damageDealt;

        // If enemy's health is less than 1, perform any actions on death
        if (health < 1)
        {
            enemyScript.ActionOnDeath();
        }
    }