示例#1
0
    public void GetHit(Vector2 _hitDirection, float _dmg, float _knockback, float _knockUp, float _stunTime)
    {
        //print(gameObject.name + " hit!");

        if (eHandleInteract != null)
        {
            if (_hitDirection == Vector2.right) // knock to the left
            {
                eHandleInteract.TakeDamage(_hitDirection, _dmg, _knockback, _knockUp, _stunTime);
            }
            else if (_hitDirection == Vector2.left) // knock to the right
            {
                eHandleInteract.TakeDamage(_hitDirection, _dmg, -_knockback, _knockUp, _stunTime);
            }
            else if (_hitDirection == Vector2.zero) // below or above
            {
                eHandleInteract.TakeDamage(_hitDirection, _dmg, -_knockback, _knockUp, _stunTime);
            }
        }
        else if (pHealthSystem != null)
        {
            if (_hitDirection == Vector2.right) // knock to the left
            {
                pHealthSystem.TakeDamage(_hitDirection, _dmg, _knockback, _knockUp, _stunTime, false);
            }
            else if (_hitDirection == Vector2.left) // knock to the right
            {
                pHealthSystem.TakeDamage(_hitDirection, _dmg, -_knockback, _knockUp, _stunTime, false);
            }
            else if (_hitDirection == Vector2.zero) // below or above
            {
                pHealthSystem.TakeDamage(_hitDirection, _dmg, -_knockback, _knockUp, _stunTime, false);
            }
        }
        else if (bO != null)
        {
            if (_hitDirection == Vector2.right) // knock to the left
            {
                bO.TakeDamage(_hitDirection, _dmg, _knockback, _knockUp, _stunTime);
            }
            else if (_hitDirection == Vector2.left) // knock to the right
            {
                bO.TakeDamage(_hitDirection, _dmg, -_knockback, _knockUp, _stunTime);
            }
            else if (_hitDirection == Vector2.zero) // below or above
            {
                bO.TakeDamage(_hitDirection, _dmg, -_knockback, _knockUp, _stunTime);
            }
        }
        else if (rO != null)
        {
            if (_hitDirection == Vector2.right) // knock to the left
            {
                rO.TakeDamage(_hitDirection, _dmg, _knockback, _knockUp, _stunTime);
            }
            else if (_hitDirection == Vector2.left) // knock to the right
            {
                rO.TakeDamage(_hitDirection, _dmg, -_knockback, _knockUp, _stunTime);
            }
            else if (_hitDirection == Vector2.zero) // below or above
            {
                rO.TakeDamage(_hitDirection, _dmg, -_knockback, _knockUp, _stunTime);
            }
        }
    }