Beispiel #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);
                }
            }
        }
    }
Beispiel #3
0
    protected override void OnAttack(Collider2D collision)
    {
        BeHitBase beHit = collision.GetComponent <BeHitBase>();

        if (beHit)
        {
            AttackDamage.AttackPolarity = Player.PlayerPolarity;
            AttackDamage.AttackPosition = transform.position;
            DamageBase damage = AttackDamage.Copy();

            float u = (collision.transform.position - transform.position).magnitude / collider.radius;

            damage.AttackForce = AttackDamage.AttackForce * Mathf.Lerp(1, centerForce, u);
            beHit.OnBeHitBefore(damage);
            if (Player.OnAttack != null)
            {
                Player.OnAttack.Invoke(beHit.Player);
            }
        }
        base.OnAttack(collision);
    }