Beispiel #1
0
    void SetKnockback(AttackStats stats)
    {
        m_LaunchDirection = stats.launchDirection;
        m_HorizontalDir   = stats.horizontalDir;

        m_CurrentKnockTime   = 0f;
        m_KnockStartPosition = transform.localPosition;

        if (m_LaunchDirection == LaunchDirection.MOVE)
        {
            m_PushTargetPosition = transform.position;

            switch (stats.axis)
            {
            case AttackStats.Axis.X:
            {
                m_PushTargetPosition.x = stats.targetPosition;
                break;
            }

            case AttackStats.Axis.Z:
            {
                m_PushTargetPosition.z = stats.targetPosition;
                break;
            }

            default: break;
            }
        }
    }
 public AttackStats(AttackStats source)
 {
     name            = source.name;
     damageProvider  = source.damageProvider;
     type            = source.type;
     launchDirection = source.launchDirection;
     axis            = source.axis;
     horizontalDir   = source.horizontalDir;
     targetPosition  = source.targetPosition;
     damage          = source.damage;
     stunDuration    = source.stunDuration;
 }
Beispiel #3
0
    void ForceMove()
    {
        if (m_CharacterController.enabled)
        {
            Vector3 lerp      = Vector3.Lerp(transform.position, m_PushTargetPosition, 10f * Time.fixedDeltaTime);
            Vector3 direction = lerp - transform.position;
            direction.y = Physics.gravity.y * Time.fixedDeltaTime;

            m_CharacterController.Move(direction);
        }

        if (!m_IsStun)
        {
            m_LaunchDirection = LaunchDirection.NO_LAUNCH;

            if (OnKnockback != null)
            {
                OnKnockback();
            }
        }
    }
Beispiel #4
0
    void KnockMotion(GamePhysics.Knock knock)
    {
        Vector3 lastPosition = transform.localPosition;

        Vector3 newPosition = MathHelper.GetBallisticMotion(knock.Angle, knock.Force, -Physics.gravity.y, m_CurrentKnockTime, m_HorizontalDir);

        m_CurrentKnockTime += knock.Speed * Time.deltaTime;

        Vector3 direction = (m_KnockStartPosition + newPosition - lastPosition);

        m_CharacterController.Move(direction);

        if (m_CharacterController.isGrounded)
        {
            m_LaunchDirection = LaunchDirection.NO_LAUNCH;

            if (OnKnockback != null)
            {
                OnKnockback();
            }
        }
    }