Exemplo n.º 1
0
 public void RemoveNode(IAutoNode node)
 {
     if (currentNodes.Contains(node))
     {
         currentNodes.Remove(node);
     }
 }
Exemplo n.º 2
0
        public override void PostHandle(GraphEngine graphEngine)
        {
            IAutoNode node = GetNextNode();

            if (node != null)
            {
                graphEngine.SetCurrentNode(node);
                graphEngine.Continue();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Set the current node for the graph. Don't use this while in the middle
 /// of traversing another graph.
 /// </summary>
 public void SetCurrentNode(IAutoNode node, bool addToSchedule = true)
 {
     currentNodes.Clear();
     ClearSchedule();
     currentNodes.Add(node);
     if (addToSchedule)
     {
         AddToSchedule(node);
     }
 }
Exemplo n.º 4
0
 private void AddToSchedule(IAutoNode node)
 {
     if (DepthFirst)
     {
         handlerStack.Push(node);
     }
     else
     {
         handlerQueue.Enqueue(node);
     }
 }
Exemplo n.º 5
0
 public void AddNode(IAutoNode node)
 {
     if (!currentNodes.Contains(node))
     {
         currentNodes.Add(node);
         if (!IsScheduleEmpty())
         {
             AddToSchedule(node);
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Perform the transition from one node to the next.
        /// </summary>
        /// <param name="graphEngine">The graph traversal engine making the transition</param>
        /// <param name="node">The node to transition from.</param>
        public virtual void Transition(GraphEngine graphEngine, IAutoNode node)
        {
            Node xnode = (Node)node;

            NodePort  port     = xnode.GetOutputPort(OutputPort);
            NodePort  nextPort = port.Connection;
            IAutoNode nextNode = (IAutoNode)nextPort.node;

            graphEngine.SetCurrentNode(nextNode);
            graphEngine.Continue();
        }
        public void StartDialog_DisablesPlayerMove()
        {
            SetupTest();

            IAutoNode node = Substitute.For <IAutoNode>();

            dialog.FindStartingNode().Returns(node);

            DialogManager.StartDialog(dialog);

            player.Received().DisableMove(DialogManager.Instance);
        }
        public void StartDialog_HandlesFirstNode()
        {
            SetupTest();

            IAutoNode node = Substitute.For <IAutoNode>();

            dialog.FindStartingNode().Returns(node);

            DialogManager.StartDialog(dialog);

            node.Received().HandleNode(DialogManager.GraphEngine);
        }
        public void ContinueDialog_HandlesNode()
        {
            SetupTest();

            IAutoNode node = Substitute.For <IAutoNode>();

            DialogManager.Inject(dialog);
            DialogManager.Inject(node);

            DialogManager.ContinueDialog();

            node.Received().HandleNode(DialogManager.GraphEngine);
        }
Exemplo n.º 10
0
        private List <IAutoNode> RefreshNodeList()
        {
            nodes = new List <IAutoNode>();

            if (graph != null)
            {
                foreach (Node node in graph.nodes)
                {
                    IAutoNode inode = (IAutoNode)node;
                    if (inode != null)
                    {
                        nodes.Add(inode);
                    }
                }
            }

            return(nodes);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Continue traversing the current graph.
        /// </summary>
        public void Continue()
        {
            if (currentNodes != null)
            {
                NotifyObserversNext();

                handlerQueue = handlerQueue ?? new Queue <IAutoNode>();
                handlerStack = handlerStack ?? new Stack <IAutoNode>();
                if (IsScheduleEmpty())
                {
                    FillSchedule(currentNodes);
                }

                while (!IsScheduleEmpty())
                {
                    IAutoNode node = NextScheduledNode();
                    node.HandleNode(this);
                }
            }
        }
Exemplo n.º 12
0
        //-------------------------------------------------------------------------
        // Public Interface
        //-------------------------------------------------------------------------
        /// <summary>
        /// Begin traversing a new graph.
        /// </summary>
        public void StartGraph(IAutoGraph graph)
        {
            if (!handlingNode)
            {
                handlingNode = true;

                currentGraph = graph;
                currentNodes = currentNodes ?? new List <IAutoNode>();
                currentNodes.Clear();

                IAutoNode node = currentGraph.FindStartingNode();

                handlingNode = false;
                if (node == null)
                {
                    return;
                }

                currentNodes.Add(node);
                Continue();
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// Inject a node to be the current node (used for automated testing -- for
 /// normal dev, use <see cref="GraphEngine.SetCurrentNode" /> instead).
 /// </summary>
 public void Inject(IAutoNode node)
 {
     currentNodes = currentNodes ?? new List <IAutoNode>();
     currentNodes.Clear();
     currentNodes.Add(node);
 }