Exemplo n.º 1
0
    public void Damage(int damage)
    {
        OnHurt.Invoke(damage);

        if (damage >= health)
        {
            OnBreak.Invoke();
        }
        else
        {
            health -= damage;
        }
    }
    public void takeDamage(float amount, HitBox hitbox = null, bool byPlayer = false)
    {
        if (!takeNoDamage)
        {
            hitpoints -= amount;
        }
        timeSinceHit = 0;

        if (flashWhiteOnHit)
        {
            if (deformer != null)
            {
                deformer.flashWhite();
            }
            //if (byPlayer) gameManager.Instance.playerCtrl.hitLag(0);
        }

        //Remember to set the hurtCallback as Dynamic and not Static
        //or it will user the Inspector HitBox (which shouldn't exist)
        if (receivesHitStun)
        {
            hitStun(hitStunDuration);
        }
        if (hurtCallback != null)
        {
            hurtCallback.Invoke(hitbox);
        }
        if (hitbox && hitbox.incendiary)
        {
            Vector3 rpos = new Vector3(Random.Range(-.25f, .25f), Random.Range(-.25f, .25f), 0);
            gameManager.createInstance("Effects/Fire/IncendiaryParticle", rpos + transform.position, transform);
        }
        if (hurtSound)
        {
            SoundManager.Instance.playClip(hurtSound.name);
        }

        if (!dead)
        {
            checkDead();
        }
    }
Exemplo n.º 3
0
 private void GotHurt(int value)
 {
     HurtEvent?.Invoke(this, value);
     Health -= value;
 }
Exemplo n.º 4
0
 private void Update_HitEvent(int hurtIndex, Transform position)
 {
     HurtEvent?.Invoke(hurtIndex, position);
 }