Exemplo n.º 1
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        //ScriptPlayable<TimeMachineBehaviour> inputPlayable = (ScriptPlayable<TimeMachineBehaviour>)playable.GetInput(i);
        //Debug.Log(PlayableExtensions.GetTime<ScriptPlayable<TimeMachineBehaviour>>(inputPlayable));

        if (!Application.isPlaying)
        {
            return;
        }

        int inputCount = playable.GetInputCount();

        for (int i = 0; i < inputCount; i++)
        {
            float inputWeight = playable.GetInputWeight(i);
            ScriptPlayable <TimeMachineBehaviour> inputPlayable = (ScriptPlayable <TimeMachineBehaviour>)playable.GetInput(i);
            TimeMachineBehaviour input = inputPlayable.GetBehaviour();

            if (inputWeight > 0f)
            {
                if (!input.clipExecuted)
                {
                    switch (input.action)
                    {
                    case TimeMachineBehaviour.TimeMachineAction.Pause:
                        if (input.ConditionMet())
                        {
                            // TODO: musíš implementovať GameManager, pomocou ktorého
                            // budes ovládať hru a prepínať hlavné udalosti
                            // teraz by to mohla byť ten TimelineManager
                            // GameManager.Instance.PauseTimeline(director);
                            input.clipExecuted = true;                                     //this prevents the command to be executed every frame of this clip
                        }
                        break;

                    case TimeMachineBehaviour.TimeMachineAction.JumpToTime:
                    case TimeMachineBehaviour.TimeMachineAction.JumpToMarker:
                        if (input.ConditionMet())
                        {
                            //Rewind
                            if (input.action == TimeMachineBehaviour.TimeMachineAction.JumpToTime)
                            {
                                //Jump to time
                                (playable.GetGraph().GetResolver() as PlayableDirector).time = (double)input.timeToJumpTo;
                            }
                            else
                            {
                                //Jump to marker
                                double t = markerClips[input.markerToJumpTo];
                                (playable.GetGraph().GetResolver() as PlayableDirector).time = t;
                            }
                            input.clipExecuted = false;                                     //we want the jump to happen again!
                        }
                        break;
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        //ScriptPlayable<TimeMachineBehaviour> inputPlayable = (ScriptPlayable<TimeMachineBehaviour>)playable.GetInput(i);
        //Debug.Log(PlayableExtensions.GetTime<ScriptPlayable<TimeMachineBehaviour>>(inputPlayable));

        if (!Application.isPlaying)
        {
            return;
        }

        int inputCount = playable.GetInputCount();

        for (int i = 0; i < inputCount; i++)
        {
            float inputWeight = playable.GetInputWeight(i);
            ScriptPlayable <TimeMachineBehaviour> inputPlayable = (ScriptPlayable <TimeMachineBehaviour>)playable.GetInput(i);
            TimeMachineBehaviour input = inputPlayable.GetBehaviour();

            if (inputWeight > 0.0f)
            {
                if (!input.clipExecuted)
                {
                    switch (input.action)
                    {
                    /*
                     *                      case TimeMachineBehaviour.TimeMachineAction.Pause:
                     *                              if(input.ConditionMet())
                     *                              {
                     *                                      //GameManager.Instance.PauseTimeline(director);   //perlu buat sendiri condition agar bisa keluar dari pause
                     *                                      input.clipExecuted = true; //this prevents the command to be executed every frame of this clip
                     *                              }
                     *                              break;
                     */
                    case TimeMachineBehaviour.TimeMachineAction.JumpToTime:
                    case TimeMachineBehaviour.TimeMachineAction.JumpToMarker:

                        if (input.ConditionMet())
                        {
                            //Rewind
                            if (input.action == TimeMachineBehaviour.TimeMachineAction.JumpToTime)
                            {
                                //Jump to time
                                (playable.GetGraph().GetResolver() as PlayableDirector).time = (double)input.timeToJumpTo;
                            }
                            else if (input.action == TimeMachineBehaviour.TimeMachineAction.JumpToMarker)
                            {
                                //Jump to marker
                                double t = markerClips[input.markerToJumpTo];
                                (playable.GetGraph().GetResolver() as PlayableDirector).time = t;
                            }
                            input.clipExecuted = false;                                     //we want the jump to happen again!
                        }
                        break;
                    }
                }
            }
        }
    }
Exemplo n.º 3
0
    public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    {
        var playable = ScriptPlayable <TimeMachineBehaviour> .Create(graph, template);

        TimeMachineBehaviour clone = playable.GetBehaviour();

        clone.clip  = clip;
        clone.Enter = Start;
        clone.Exit  = End;
        return(playable);
    }
Exemplo n.º 4
0
    public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    {
        var playable = ScriptPlayable <TimeMachineBehaviour> .Create(graph, template);

        TimeMachineBehaviour clone = playable.GetBehaviour();

        clone.action       = action;
        clone.markerLabel  = markerLabel;
        clone.conversation = conversation.Resolve(graph.GetResolver());

        return(playable);
    }
Exemplo n.º 5
0
    public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    {
        var playable = ScriptPlayable <TimeMachineBehaviour> .Create(graph, template);

        TimeMachineBehaviour clone = playable.GetBehaviour();

        clone.markerToJumpTo = markerToJumpTo;
        clone.action         = action;
        clone.condition      = condition;
        clone.markerLabel    = markerLabel;
        clone.timeToJumpTo   = timeToJumpTo;

        return(playable);
    }
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        //ScriptPlayable<TimeMachineBehaviour> inputPlayable = (ScriptPlayable<TimeMachineBehaviour>)playable.GetInput(i);
        //Debug.Log(PlayableExtensions.GetTime<ScriptPlayable<TimeMachineBehaviour>>(inputPlayable));

        if (!Application.isPlaying)
        {
            return;
        }

        int inputCount = playable.GetInputCount();

        for (int i = 0; i < inputCount; i++)
        {
            float inputWeight = playable.GetInputWeight(i);
            ScriptPlayable <TimeMachineBehaviour> inputPlayable = (ScriptPlayable <TimeMachineBehaviour>)playable.GetInput(i);
            TimeMachineBehaviour input = inputPlayable.GetBehaviour();

            if (inputWeight > 0f)
            {
                switch (input.action)
                {
                case TimeMachineBehaviour.TimeMachineAction.Pause:
                    Debug.Log("Pause");
                    (playable.GetGraph().GetResolver() as PlayableDirector).Pause();
                    break;

                case TimeMachineBehaviour.TimeMachineAction.JumpToTime:
                case TimeMachineBehaviour.TimeMachineAction.JumpToMarker:
                    if (input.ConditionMet())
                    {
                        //Rewind
                        if (input.action == TimeMachineBehaviour.TimeMachineAction.JumpToTime)
                        {
                            //Jump to time
                            (playable.GetGraph().GetResolver() as PlayableDirector).time = (double)input.timeToJumpTo;
                        }
                        else
                        {
                            //Jump to marker
                            double t = markerClips[input.markerToJumpTo];
                            (playable.GetGraph().GetResolver() as PlayableDirector).time = t;
                        }
                    }
                    break;
                }
            }
        }
    }
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        int inputCount            = playable.GetInputCount();
        TimeMachineBehaviour clip = null;

        for (int i = 0; i < inputCount; i++)
        {
            if (playable.GetInputWeight(i) > 0f)
            {
                ScriptPlayable <TimeMachineBehaviour> inputPlayable =
                    (ScriptPlayable <TimeMachineBehaviour>)playable.GetInput(i);
                clip = inputPlayable.GetBehaviour();
                break;
            }
        }

        if (director.state != PlayState.Playing || info.evaluationType != FrameData.EvaluationType.Playback)
        {
            _lastClip = null;
            return;
        }

        if (clip != _lastClip)
        {
            //Debug.Log($"({_lastClip?.clip.displayName}) => ({clip?.clip.displayName})");

            if (_lastClip != null)
            {
                _lastClip.Exit.RunAction(this);
                _lastClip = null;
            }
            else
            {
                clip?.Enter.RunAction(this);
                _lastClip = clip;
            }
        }
    }
 public override void OnBehaviourPlay(Playable playable, FrameData info)
 {
     base.OnBehaviourPlay(playable, info);
     _lastClip = null;
 }
 public override void OnGraphStart(Playable playable)
 {
     base.OnGraphStart(playable);
     _lastClip = null;
 }