Beispiel #1
0
    public bool Damage(int damage, Vector2 knockBack, float stunDuration = 0.3f, int stunPoints = 0)
    {
        if (hasFlagHandler && flagHandler.CheckCommonFlag(CommonFlags.Dodgeing))
        {
            return(false);
        }
        health -= damage;
        if (hasStunComponent)
        {
            stunComponent.Stun(knockBack, stunDuration, stunPoints);
        }

        //call health update event
        if (HealthUpdateEvent != null)
        {
            HealthUpdateEvent();
        }
        if (health <= 0 && !deathCalled)
        {
            OnDeath();
            deathCalled = true;
            if (hasStunComponent)
            {
                Destroy(stunComponent);
                hasStunComponent = false;
            }
        }
        return(true);
    }