public override void Skip()
 {
     if (runtimeCharToMove != null)
     {
         Vector3 lookVector = AdvGame.GetCharLookVector(direction, (relativeTo == RelativeTo.Character) ? runtimeCharToMove : null);
         runtimeCharToMove.SetLookDirection(lookVector, true);
     }
 }
        public override float Run()
        {
            if (!isRunning)
            {
                isRunning = true;

                if (runtimeCharToMove != null)
                {
                    if (!isInstant && runtimeCharToMove.IsMovingAlongPath())
                    {
                        runtimeCharToMove.EndPath();
                    }

                    Vector3 lookVector = AdvGame.GetCharLookVector(direction, (relativeTo == RelativeTo.Character) ? runtimeCharToMove : null);
                    runtimeCharToMove.SetLookDirection(lookVector, isInstant);

                    if (!isInstant)
                    {
                        if (willWait)
                        {
                            return(defaultPauseTime);
                        }
                    }
                }

                return(0f);
            }
            else
            {
                if (runtimeCharToMove.IsTurning())
                {
                    return(defaultPauseTime);
                }
                else
                {
                    isRunning = false;
                    return(0f);
                }
            }
        }
Exemple #3
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            if (!Application.isPlaying)
            {
                return;
            }
            character = playerData as AC.Char;

            if (character == null)
            {
                GameObject characterObject = playerData as GameObject;
                if (characterObject != null)
                {
                    character = characterObject.GetComponent <AC.Char>();
                }
            }

            if (character != null)
            {
                if (character.GetAnimEngine() == null)
                {
                    ACDebug.LogWarning("The 2D character animation track requires that " + character + "'s has an animation engine.");
                    return;
                }

                if (!character.GetAnimEngine().isSpriteBased)
                {
                    ACDebug.LogWarning("The 2D character animation track requires that " + character + "'s animation is sprite-based.");
                    return;
                }

                if (character.turn2DCharactersIn3DSpace)
                {
                    ACDebug.LogWarning("For the 2D character animation track to work, " + character + "'s 'Turn root object in 3D?' must be unchecked.");
                    return;
                }

                if (forceDirection)
                {
                    Vector3 lookVector = AdvGame.GetCharLookVector(charDirection);
                    character.SetLookDirection(lookVector, turnInstantly);
                }

                if (lastFramePosition != Vector3.zero)
                {
                    Vector3 deltaPosition = character.transform.position - lastFramePosition;
                    if (Mathf.Approximately(deltaPosition.sqrMagnitude, 0f))
                    {
                        if (character.isTalking && (character.talkingAnimation == TalkingAnimation.Standard || character.animationEngine == AnimationEngine.Custom))
                        {
                            character.GetAnimEngine().PlayTalk();
                        }
                        else
                        {
                            character.GetAnimEngine().PlayIdle();
                        }
                        SetOverrideState(false);
                    }
                    else
                    {
                        SetOverrideState(true);

                        switch (moveSpeed)
                        {
                        case PathSpeed.Walk:
                            character.GetAnimEngine().PlayWalk();
                            break;

                        case PathSpeed.Run:
                            character.GetAnimEngine().PlayRun();
                            break;

                        default:
                            break;
                        }

                        if (!forceDirection)
                        {
                            Vector3 lookVector = new Vector3(deltaPosition.x, 0f, deltaPosition.y);
                            character.SetLookDirection(lookVector, turnInstantly);
                        }
                    }
                }

                lastFramePosition = character.transform.position;
            }
        }