Exemplo n.º 1
0
 public virtual void Close(Tick tick)
 {
 }
Exemplo n.º 2
0
 public virtual void Exit(Tick tick)
 {
 }
Exemplo n.º 3
0
 public virtual NodeStates Tick(Tick tick)
 {
     return(NodeStates.Error);
 }
Exemplo n.º 4
0
 public virtual void Open(Tick tick)
 {
 }
Exemplo n.º 5
0
 public virtual void Enter(Tick tick)
 {
 }
Exemplo n.º 6
0
 public virtual NodeStates Execute(Tick tick)
 {
     return(NodeStates.Error);
 }
Exemplo n.º 7
0
        public void Tick(GameObject target, Blackboard blackboard)
        {
            var tick = new Tick();

            tick.target     = target;
            tick.blackboard = blackboard;
            tick.tree       = this;

            /* TICK NODE */
            this.root.Execute(tick);

            /* CLOSE NODES FROM LAST TICK, IF NEEDED */
            List <Node> lastOpenNodes;

            lastOpenNodes = new List <Node>();

            try
            {
                lastOpenNodes = (List <Node>)blackboard.Get("openNodes", id).value;
            }
            catch (Exception) { }

            var currOpenNodes = new List <Node>(tick.openNodes);

            // does not close if it is still open in this tick
            var start = 0;
            int n     = 0;

            if (lastOpenNodes == null)
            {
                n = currOpenNodes.Count;
            }
            else
            {
                n = Math.Min(lastOpenNodes.Count, currOpenNodes.Count);
            }


            if (lastOpenNodes != null)
            {
                for (int i = 0; i < n; i++)
                {
                    start = i + 1;
                    if ((Node)lastOpenNodes[i] != currOpenNodes[i])
                    {
                        break;
                    }
                }
            }
            else
            {
                start = currOpenNodes.Count;
            }

            // close the nodes
            if (lastOpenNodes != null)
            {
                for (var i = lastOpenNodes.Count - 1; i >= start; i--)
                {
                    lastOpenNodes[i].Close(tick);
                }
            }

            /* POPULATE BLACKBOARD */
            blackboard.Set("openNodes", currOpenNodes, id);
            blackboard.Set("nodeCount", tick.nodeCount, id);
        }