Exemple #1
0
    public virtual void Damage(Hurtbox hurt, Hitbox hit)
    {
        if (hit.gameObject.tag != gameObject.tag && !_isInvincible)
        {
            health -= hit.damage;
            if (hit.direction == Vector3.zero)
            {
                Force(hurt.transform.position - hit.transform.position, hit.force);
            }
            else
            {
                Force(hit.direction, hit.force);
            }

            _sprite.FlashAdd(Color.white);
            _sprite.Shake(10, 0.125f);
            Particle.SpawnCross(transform.position + new Vector3(Random.Range(-0.25f, 0.25f), Random.Range(-0.25f, 0.25f), 0), Color.red);
            Particle.SpawnCross(transform.position + new Vector3(Random.Range(-0.25f, 0.25f), Random.Range(-0.25f, 0.25f), 0), Color.blue);
            Particle.SpawnCross(transform.position + new Vector3(Random.Range(-0.25f, 0.25f), Random.Range(-0.25f, 0.25f), 0), Color.green);
            SoundEffects.PlayHit();
            DamagePlus();

            hit.OnHit();
        }
    }