Пример #1
0
 private void EmitUnitChanged(GameUnit gameUnit, TimelineNode unit, Time time)
 {
     if (UnitChanged != null)
     {
         UnitChanged(gameUnit, unit, time);
     }
 }
Пример #2
0
 private void EmitUnitSelected(GameUnit gameUnit, TimelineNode unit)
 {
     if (UnitSelected != null)
     {
         UnitSelected(gameUnit, unit);
     }
 }
Пример #3
0
    internal TimelineTree Filter(Func <TimelineRecord, bool> predicate)
    {
        return(new TimelineTree(Timeline, FilterList(newParentNode: null, Roots)));

        TimelineNode FilterNode(TimelineNode node, TimelineNode newParentNode)
        {
            var newNode = new TimelineNode();

            newNode.TimelineRecord = node.TimelineRecord;
            newNode.ParentNode     = newParentNode;
            newNode.Children       = FilterList(newNode, node.Children);

            return((newNode.Children.Count > 0 || predicate(node.TimelineRecord))
                ? newNode
                : null);
        }

        List <TimelineNode> FilterList(TimelineNode newParentNode, List <TimelineNode> list)
        {
            var newList = new List <TimelineNode>();

            foreach (var node in list)
            {
                var filteredNode = FilterNode(node, newParentNode);
                if (filteredNode is object)
                {
                    newList.Add(filteredNode);
                }
            }

            return(newList);
        }
    }
Пример #4
0
 public GameUnitsStats(GameUnitsList guList, int duration)
 {
     game = new TimelineNode {
         Start = new Time(0), Stop = new Time(duration)
     };
     gameNode      = new GameUnitStatsNode(game);
     gameUnitNodes = new Dictionary <GameUnit, GameUnitStatsNode>();
     GroupGameStats(guList);
 }
Пример #5
0
        void HandleUnitAdded(GameUnit gameUnit, int frame)
        {
            var unit = new TimelineNode {
                Name = gameUnit.Name, Fps = openedProject.Description.File.Fps
            };

            unit.StartFrame = (uint)(frame - 50);
            unit.StopFrame  = (uint)(frame + 50);
            gameUnit.Add(unit);
        }
Пример #6
0
        public static void PlayRecordAction(string fileName)
        {
            var actionFile = SerializeHelper.LoadJson <ActionRecordFile>(Application.dataPath.CombinePath("131576376315678780"));

            var timelineNode = new TimelineNode();

            foreach (var recordData in actionFile.RecordData)
            {
                var actionName = recordData.ActionName;
                timelineNode.Append(new TimelineNode.TimelinePair(recordData.ExecuteTime, EventAction.Allocate(() =>
                {
                    PTUIManager.Instance.SendMsg(new ActionMsg(actionName));
                })));
            }

            Instance.ExecuteNode(timelineNode);
        }
Пример #7
0
 bool Contained(TimelineNode node, TimelineNode parent)
 {
     if (node.Start > parent.Start && node.Stop < parent.Stop)
     {
         return(true);
     }
     else if (node.Start > parent.Start && node.Stop > parent.Stop)
     {
         return((node.Stop - parent.Stop) < node.Duration * MAX_DIFF);
     }
     else if (node.Start < parent.Start && node.Stop < parent.Stop)
     {
         return((parent.Start - node.Start) < node.Duration * MAX_DIFF);
     }
     else
     {
         return(false);
     }
 }
Пример #8
0
        void Start()
        {
            var timelineNode = new TimelineNode();

            // 第一秒输出 HelloWorld
            timelineNode.Append(1.0f, EventAction.Allocate(() => Debug.Log("HelloWorld")));

            // 第二秒输出 延时了 2 秒
            timelineNode.Append(2.0f, EventAction.Allocate(() => Debug.Log("延时了 2 秒")));

            // 第三秒发送 一个事件
            timelineNode.Append(3.0f, new KeyEventAction("someEventA", timelineNode));

            // 第四秒发送 一个事件
            timelineNode.Append(4.0f, new KeyEventAction("someEventB", timelineNode));

            // 监听 timeline 的 key 事件
            timelineNode.OnKeyEventsReceivedCallback = keyEvent => Debug.Log(keyEvent);

            // 执行 timeline
            this.ExecuteNode(timelineNode);
        }
Пример #9
0
        static int Compare(TimelineNode x, TimelineNode y)
        {
            var xStart = DevOpsUtil.ConvertRestTime(x.TimelineRecord.StartTime);
            var yStart = DevOpsUtil.ConvertRestTime(y.TimelineRecord.StartTime);

            if (xStart is null)
            {
                if (yStart is null)
                {
                    return(0);
                }

                return(-1);
            }

            if (yStart is null)
            {
                return(1);
            }

            return(xStart.Value.CompareTo(yStart.Value));
        }
Пример #10
0
        private void StopGameUnit(GameUnit gameUnit)
        {
            TimelineNode timeInfo;
            Time         start, stop;

            if (!gameUnitsStarted.ContainsKey(gameUnit))
            {
                Log.Warning("Tryed to stop a game unit that was not started: " + gameUnit);
                return;
            }

            start = gameUnitsStarted[gameUnit];
            stop  = new Time {
                MSeconds = (int)player.CurrentTime
            };
            timeInfo = new TimelineNode {
                Name = gameUnit.Name, Fps = fps, Start = start, Stop = stop
            };

            gameUnit.Add(timeInfo);
            gameUnitsStarted.Remove(gameUnit);
            Log.Debug(String.Format("Added new unit:{0} to {1} ", timeInfo, gameUnit));
        }
Пример #11
0
 public GameUnitStatsNode(TimelineNode node)
 {
     Node = node;
 }
Пример #12
0
 void HandleUnitSelected(GameUnit gameUnit, TimelineNode unit)
 {
     unit.Selected = true;
 }
    public void GetNodeFunction(List <NodePort> _ports)
    {
        //cannot find a way to use a switch, so we'll have to stick with a bunch of if statements :notlikethis:
        foreach (NodePort _nodePort in _ports)
        {
            XNode.Node _node = _nodePort.node;
            if (_node.GetType() == typeof(DialogueNode))
            {
                dialoguePanel.SetActive(true);
                currentDialogue = _node as DialogueNode;
                ShowDialogue(currentDialogue);
                return; //do NOT grab the node after this, and wait for the player to advance the dialogue
            }


            if (_node.GetType() == typeof(VoiceClipNode))
            {
                VoiceClipNode voiceClipNode = _node as VoiceClipNode;
                voiceClipNode.OnUse();

                return;
            }

            if (_node.GetType() == typeof(EndSceneNode))
            {
                EndCutscene();
                return;
            }
            else if (_node.GetType() == typeof(EndBattleSceneNode))
            {
                EndCutscene();
                BattleManager BM = GameObject.Find("BattleManager").GetComponent <BattleManager>();
                BM.EnableUI();
                BM.StartActor();

                //Move Battle UI Back In?
                return;
            }
            if (_node is MovementNode movementNode)
            {
                movementNode.CharacterMovement();
            }

            if (_node.GetType() == typeof(CloseDialogue))
            {
                dialoguePanel.SetActive(false);
                speakerPanel.SetActive(false);
            }

            if (_node.GetType() == typeof(CG))
            {
                CG scopedCGNode = _node as CG;
                showCG(_node as CG);

                if (scopedCGNode.waitForInput)
                {
                    currentCGNode = scopedCGNode;
                    dialoguePanel.gameObject.SetActive(false);
                    _charactersInScene.SetActive(false);
                    CGWaitingForInput = true;
                    return;
                }
            }

            if (_node.GetType() == typeof(SetSpriteNode))
            {
                SetImage(_node as SetSpriteNode);
            }

            if (_node.GetType() == typeof(CGHide))
            {
                _cgGraphic.enabled = false;
            }

            if (_node.GetType() == typeof(WaitFor))
            {
                WaitFor _waitForNode = _node as WaitFor;
                StartCoroutine(WaitToAdvance(_waitForNode));
                //do not get next node automatically
                return;
            }
            if (_node.GetType() == typeof(Choices))
            {
                ChoicePanel.SetActive(true);

                nodeOptions = new List <Node>();
                int listIndex = 0;

                Choices         _choiceNode = _node as Choices;
                NodePort        _choicePort = _choiceNode.GetOutputPort("output");
                List <NodePort> _nodePorts  = _choicePort.GetConnections();
                foreach (NodePort _NP in _nodePorts)
                {
                    nodeOptions.Add(_NP.node);
                    Button _newOption = Instantiate(choiceButton) as Button;
                    _newOption.transform.SetParent(ChoicePanel.transform);
                    listIndex++;//on this button it where on the list it is, using this

                    //ChoiceOptionHolder _holder = _newOption.GetComponent<ChoiceOptionHolder>();
                    OptionNode optionNode = _NP.node as OptionNode;
                    _newOption.GetComponentInChildren <Text>().text     = optionNode.optionText;
                    _newOption.GetComponent <ChoiceOptionHolder>().node = _NP.node;
                    // _holder.node = _NP.node;
                    // _holder.indexOfOptions = listIndex;
                }

                return; //do not load next node, since we want the player input to decide the branch to go down
            }
            if (_node.GetType() == typeof(TimelineNode))
            {
                TimelineNode timelineNode = _node as TimelineNode;
                timelineNode.PlayTimeLine();
            }

            //get next node(s)
            NodePort _port = _node.GetOutputPort("output");
            if (_port.IsConnected)
            {
                GetNodeFunction(_port.GetConnections());
            }
        }
    }
Пример #14
0
 protected override void OnDispose()
 {
     mTimelineNode = null;
     mKeyEventName = null;
 }
Пример #15
0
 public KeyEventNode(string keyEventName, TimelineNode timelineNode)
 {
     mTimelineNode = timelineNode;
     mKeyEventName = keyEventName;
 }
Пример #16
0
 void HandleUnitChanged(GameUnit gameUnit, TimelineNode unit, Time time)
 {
     player.CloseActualSegment();
     player.Pause();
     player.SeekTo(time.MSeconds, true);
 }
Пример #17
0
 void HandleUnitSelected(GameUnit gameUnit, TimelineNode unit)
 {
     unit.Selected = true;
     player.SetStartStop(unit.Start.MSeconds, unit.Stop.MSeconds);
 }
Пример #18
0
    internal static TimelineTree Create(Timeline timeline)
    {
        var records = timeline.Records;
        var map     = new Dictionary <string, TimelineNode>();

        // Each stage will have a different root
        var roots = new List <TimelineNode>();

        foreach (var record in records)
        {
            var node = GetOrCreateNode(record.Id);
            node.TimelineRecord = record;

            if (string.IsNullOrEmpty(record.ParentId))
            {
                roots.Add(node);
            }
            else
            {
                var parentNode = GetOrCreateNode(record.ParentId);
                parentNode.Children.Add(node);
                node.ParentNode = parentNode;
            }
        }

        // Now look for hidden roots
        foreach (var value in map.Values)
        {
            if (value.ParentNode is null && !roots.Contains(value))
            {
                roots.Add(value);
            }
        }

        // TODO sort by start time, not name. The tree should reflect execution order
        var comparer = StringComparer.OrdinalIgnoreCase;

        foreach (var value in map.Values)
        {
            value.Children.Sort(Compare);
        }

        roots.Sort(Compare);

        var tree = new TimelineTree(timeline, roots);

        Debug.Assert(tree.Count == timeline.Records.Length);
        return(tree);

        TimelineNode GetOrCreateNode(string id)
        {
            TimelineNode node;

            if (!map.TryGetValue(id, out node))
            {
                node = new TimelineNode();
                map.Add(id, node);
            }

            return(node);
        }
Пример #19
0
 public GameUnitStatsNode(TimelineNode node, List <GameUnitStatsNode> list) : base(list)
 {
     Node = node;
 }
Пример #20
0
 internal TimelineNode(TimelineRecord record, TimelineNode parentNode, List <TimelineNode> children)
 {
     TimelineRecord = record;
     ParentNode     = parentNode;
     Children       = children;
 }
Пример #21
0
 protected override void OnDispose()
 {
     _timelineNode = null;
     _keyEventName = null;
 }