Exemple #1
0
    public void TakeDamage(float damage, string damageIdentifier, float timeForNextAttack)
    {
        if (isDead)
        {
            return;
        }

        if (hitDetectionTable.Get(damageIdentifier))
        {
            // print("PLAYER GOT HIT, BUT HAS IMMUNE");
            return;
        }
        // print("PLAYER GOT HIT!");
        StartCoroutine(SetDamageImmuneForSeconds(damageIdentifier, timeForNextAttack - 0.1f));

        if (isGuarded)
        {
            // print("PLAYER GUARDED ENEMY ATTACK! NO DAMAGE TAKEN!");
            isGuarded = false;
            return;
        }

        health -= damage;

        if (health <= 0)
        {
            isDead = true;
        }
    }
    public void TakeDamage(float damage, string damageIdentifier, float timeForNextAttack)
    {
        if (isDead)
        {
            return;
        }
        if (hitDetectionTable.Get(damageIdentifier))
        {
            // print("ENEMY TOOK THE DAMAGE, BUT HAS IMMUNE FOR " + damageIdentifier);
            return;
        }

        // print("ENEMY GOT HIT, NOW HAS " + health + " AND HAS IMMUNE ABOUT" + damageIdentifier + " FOR " + timeForNextAttack + " seconds.");
        StartCoroutine(SetDamageImmuneForSeconds(damageIdentifier, timeForNextAttack - 0.1f));

        health -= damage;

        if (health <= 0)
        {
            isDead = true;
            animator.SetTrigger("isDead");
            enemyCollider.enabled = false;
        }
    }