예제 #1
0
    private void UpdateCurrentMoveState()
    {
        if (moveController != null && moveController.CurrentMove != null && currentMotionState != null)
        {
            AnimatorStateInfo stateInfo = moveController.GetCurrentStateInfo();
            if (stateInfo.fullPathHash == moveController.GetCurrentAnimHash())
            {
                float normalizedTime = stateInfo.normalizedTime;
                if (currentMotionState.distanceToDestination != null)
                {
                    normalizedTime = Mathf.Min(normalizedTime, 1.0f);
                }
                float currentFrame = moveController.NormalizedTimeToFrame_Wrapped(normalizedTime);
                currentMotionState.OnAnimatorUpdated(currentFrame);

                //myAnimator.gameObject.SendMessage("OnCurrentMotionStateUpdated", SendMessageOptions.DontRequireReceiver);

                if (currentMotionState.isFinished)
                {
                    ToNormalState();
                }
            }
        }
        else
        {
            myAnimator.gameObject.transform.rotation = myAnimator.rootRotation;
            myAnimator.gameObject.transform.position = myAnimator.rootPosition;
        }
    }
예제 #2
0
        public void Update()
        {
            if (mScaleCharacter && !mScaled && mCurrent != null && mCurrent.character != null)
            {
                DoScaleCharacter();

                mScaled = true;
            }

            if (needToTransitionToIdle || needToSetStateAfterMove != MoveController.CombatantMoveState.kIdle)
            {
                if (mCurrent != null && mCurrent.character != null)
                {
                    MoveController    moveController = mCurrent.character.GetComponent <MoveController>();
                    AnimatorStateInfo asi            = moveController.GetCurrentStateInfo();
                    if (asi.normalizedTime >= 1)
                    {
                        MoveEditor.Move theMove = moveController.GetMoveByState(needToSetStateAfterMove);
                        moveController.TransitionTo(needToSetStateAfterMove);
                        moveController.m_lobby_hash = Animator.StringToHash(string.Format("Lobby.{0}", theMove.name));
                        moveController.SetMove(theMove);
                        moveController.CrossFade(moveController.GetCurrentAnimHash(), 0.2f, 0, 0f);
                        needToTransitionToIdle  = false;
                        needToSetStateAfterMove = MoveController.CombatantMoveState.kIdle;
                    }
                }
            }
        }
예제 #3
0
    public void Update()
    {
        if (!GameEngine.Instance.IsTimeToRootScene)
        {
            return;
        }

        if (moveChanged)
        {
            moveChanged = false;
        }

        if (moveController == null)
        {
            return;
        }

        currentMove = moveController.CurrentMove;

        if (currentMove != null)
        {
            AnimatorStateInfo stateInfo = moveController.GetCurrentStateInfo();

            if (stateInfo.fullPathHash == moveController.GetCurrentAnimHash())
            {
                if (isCrossFading)
                {
                    isCrossFading = false;
                }

                float currentFrame = regularEvents.lastUpdatedFrame;                 //isCrossFading ? regularEvents.lastUpdatedFrame : moveController.NormalizedTimeToFrame_Wrapped(stateInfo.normalizedTime);
                float nextFrame    = moveController.NormalizedTimeToFrame_Wrapped(stateInfo.normalizedTime + (Time.deltaTime * myAnimator.speed / currentMove._animationClip.length));
                UpdateRequiredEvents(currentFrame, nextFrame);
                UpdateRegularEvents(currentFrame, nextFrame);
            }
        }
    }
예제 #4
0
        public new void Update()
        {
            if (mScaleCharacter && !mScaled && (mCurrent != null && mCurrent.character != null || mCurrentOther != null && mCurrentOther.character != null))
            {
                DoScaleCharacter();

                mScaled = true;
            }

            if (mCurrent != null && mCurrent.character != null)
            {
                MoveController    moveController = mCurrent.character.GetComponent <MoveController>();
                AnimatorStateInfo asi            = moveController.GetCurrentStateInfo();

                if (!((int)moveController.CurrentState == (int)MoveController.CombatantMoveState.kReady))
                {
                    if (asi.normalizedTime >= 1)
                    {
                        MoveEditor.Move theMove = moveController.GetMoveIfExists("Ready");
                        moveController.TransitionTo(MoveController.CombatantMoveState.kReady);
                        moveController.m_lobby_hash = Animator.StringToHash(string.Format("Lobby.{0}", theMove.name));
                        moveController.SetMove(theMove);
                        moveController.CrossFade(MoveController.m_ready_hash, 0.2f, 0, 0f);
                    }
                }
            }

            if (mCurrentOther != null && mCurrentOther.character != null)
            {
                MoveController    moveController = mCurrentOther.character.GetComponent <MoveController>();
                AnimatorStateInfo asi            = moveController.GetCurrentStateInfo();

                if (!((int)moveController.CurrentState == (int)MoveController.CombatantMoveState.kReady))
                {
                    if (asi.normalizedTime >= 1)
                    {
                        MoveEditor.Move theMove = moveController.GetMoveIfExists("Ready");
                        moveController.TransitionTo(MoveController.CombatantMoveState.kReady);
                        moveController.m_lobby_hash = Animator.StringToHash(string.Format("Lobby.{0}", theMove.name));
                        moveController.SetMove(theMove);
                        moveController.CrossFade(MoveController.m_ready_hash, 0.2f, 0, 0f);
                    }
                }
            }
        }
예제 #5
0
        public void Update()
        {
            // base.Update();

            if (needToTransitionToIdle)
            {
                if (ModelGO != null && ModelGO.GetComponent <CharacterVariant>().CharacterInstance != null)
                {
                    MoveController    moveController = ModelGO.GetComponent <CharacterVariant>().CharacterInstance.GetComponent <MoveController>();
                    AnimatorStateInfo asi            = moveController.GetCurrentStateInfo();

                    if (asi.normalizedTime >= 1)
                    {
                        MoveEditor.Move theMove = moveController.GetMoveIfExists("Idle");
                        moveController.TransitionTo(MoveController.CombatantMoveState.kIdle);
                        moveController.m_lobby_hash = Animator.StringToHash("Lobby." + theMove.name);
                        moveController.SetMove(theMove);
                        moveController.CrossFade(MoveController.m_idle_hash, 0.2f, 0, 0f);
                        needToTransitionToIdle = false;
                    }
                }
            }
        }