Beispiel #1
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;
                    }
                }
            }
        }
Beispiel #2
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;
        }
    }
Beispiel #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);
            }
        }
    }