Exemple #1
0
    virtual protected void OnAttack(Collider2D collision)
    {
        BeHitBase beHit = collision.GetComponent <BeHitBase>();

        if (beHit)
        {
            AttackDamage.AttackPosition = transform.position;
            beHit.OnBeHitBefore(AttackDamage.Copy());
            if (Player.OnAttack != null)
            {
                Player.OnAttack.Invoke(beHit.Player);
            }
        }
    }
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collider.IsTouching(collision))
        {
            BeHitBase beHit = collision.GetComponent <BeHitBase>();

            if (beHit)
            {
                AttackDamage.AttackPolarity = Player.PlayerPolarity;
                AttackDamage.AttackPosition = transform.position;
                beHit.OnBeHitBefore(AttackDamage.Copy());
                ReactionForce(collision.GetComponent <PlayerBase>());
                if (Player.OnAttack != null)
                {
                    Player.OnAttack.Invoke(beHit.Player);
                }
            }
        }
    }