Ejemplo n.º 1
0
    void SetMovementBlocked(bool isMovementBlocked, EBlockedReason reason)
    {
        if (CanUpdateMovementBlockedStatus(isMovementBlocked, reason))
        {
            m_IsMovementBlocked     = isMovementBlocked;
            m_MovementBlockedReason = reason;

            ChronicleManager.AddChronicle(gameObject, EChronicleCategory.Movement, "Movement has been " + (isMovementBlocked ? "blocked" : "unblocked") + ", reason : " + reason);

            if (m_IsMovementBlocked)
            {
                m_Animator.ResetTrigger(K_ANIM_TAKE_OFF_TRIGGER);
                m_Animator.ResetTrigger(K_ANIM_TURN_AROUND_TRIGGER);
                m_JumpTakeOffRequested = false;

                // If movement is blocked by timeOver, let the jump be triggered before end of round anim
                // Otherwise, player will be blocked in takeOff animation for ever
                if (reason != EBlockedReason.TimeOver)
                {
                    m_JumpTakeOffDirection = 0f;
                    m_TriggerJumpImpulse   = false;
                    m_AttackComponent.SetAttackBlockedByTakeOff(false);
                }

                if (m_Controller.IsJumping() && reason == EBlockedReason.Stun)
                {
                    OnStopMovement();
                }

                if (m_NeedFlip)
                {
                    if (reason == EBlockedReason.Stun)
                    {
                        Flip();
                    }
                    else if ((reason == EBlockedReason.PlayAttack || reason == EBlockedReason.RequestByAttack) && !m_Controller.IsJumping())
                    {
                        Flip();
                    }
                }
            }
        }
        else
        {
            ChronicleManager.AddChronicle(gameObject, EChronicleCategory.Movement, "/!\\ Movement has NOT been " + (isMovementBlocked ? "blocked" : "unblocked") + " by reason : " + reason);
        }
    }
Ejemplo n.º 2
0
    bool CanUpdateMovementBlockedStatus(bool isMovementBlocked, EBlockedReason reason)
    {
        //Block reasons :
        // PlayAttack, RequestByAttack, Stun, TimeOver

        //Unblock reasons :
        // EndAttack, RequestByAttack, StunEnd

        if (m_IsMovementBlocked)
        {
            if (m_MovementBlockedReason == EBlockedReason.TimeOver)
            {
                // We can't update the block status if the current block reason is TimeOver
                return(false);
            }

            // If we need to unblock movement
            if (!isMovementBlocked)
            {
                switch (m_MovementBlockedReason)
                {
                // If movement blocked reason is Play/RequestBy Attack, you can unblock the movement with EndAttack or RequestByAttack
                case EBlockedReason.PlayAttack:
                case EBlockedReason.RequestByAttack:
                    return(reason == EBlockedReason.EndAttack || reason == EBlockedReason.RequestByAttack);

                // If movement blocked reason is Stun, you can unblock the movement only with a StunEnd reason
                case EBlockedReason.Stun:
                    return(reason == EBlockedReason.StunEnd);

                default:
                    string errorMsg = "Movement has been blocked with an invalid reason : " + m_MovementBlockedReason + " and trying to unblock with reason : " + reason;
                    KakutoDebug.LogError(errorMsg);
                    ChronicleManager.AddChronicle(gameObject, EChronicleCategory.Movement, "ERROR : " + errorMsg);
                    return(true);
                }
            }
        }

        return(true);
    }