Exemplo n.º 1
0
        public override NodeState Activate(NodeStateHandle state)
        {
            for (int i = 0; i < state.ChildCount; ++i)
            {
                state.ActivateChild(i);
            }

            return(NodeState.Running);
        }
Exemplo n.º 2
0
 public override NodeState Update(float dt, NodeStateHandle state, ref float value)
 {
     value -= dt;
     if (value <= 0.0f)
     {
         return(NodeState.Complete);
     }
     return(NodeState.Running);
 }
Exemplo n.º 3
0
 public override NodeState Activate(NodeStateHandle state, ref float value)
 {
     if (MaxDuration.HasValue)
     {
         value = (float)(new System.Random().NextDouble() * (MaxDuration.Value - MinDuration)) + MinDuration;
     }
     else
     {
         value = MinDuration;
     }
     return(NodeState.Running);
 }
Exemplo n.º 4
0
        public override NodeState Update(float dt, NodeStateHandle h)
        {
            for (int i = 0; i < h.ChildCount; ++i)
            {
                if (h.ChildState(i) != NodeState.Running)
                {
                    return(h.ChildState(i));
                }
            }

            return(NodeState.Running);
        }
Exemplo n.º 5
0
        public override NodeState Update(float dt, NodeStateHandle h)
        {
            for (int i = 0; i < h.ChildCount; ++i)
            {
                if (!h.ChildState(i).Active())
                {
                    h.ActivateChild(i);
                }
            }

            return(NodeState.Running);
        }
Exemplo n.º 6
0
        public override NodeState Update(float dt, NodeStateHandle state, ref int value)
        {
            var curChildState = state.ChildState(value);

            if (curChildState.Active())
            {
                return(NodeState.Running);
            }
            ++value;
            if (value < state.ChildCount)
            {
                state.ActivateChild(value);
                return(NodeState.Running);
            }
            else
            {
                return(NodeState.Complete);
            }
        }
Exemplo n.º 7
0
        public unsafe void Update(float dt, int nodeIndex, TreeDef treeDef, NativeSlice <NodeState> state, NativeSlice <byte> data)
        {
            Profiler.BeginSample("TNode::Update");
            var arr = data.SliceConvert <T>();

            for (int i = 0; i < arr.Length; ++i)
            {
                var h = new NodeStateHandle(nodeIndex, state.Slice(i * treeDef.Nodes.Length, treeDef.Nodes.Length), treeDef);
                var v = arr[i];

                if (h.State == NodeState.Activating)
                {
                    h.State = Activate(h, ref v);
                }

                if (h.State == NodeState.Running)
                {
                    h.State = Update(dt, h, ref v);
                    arr[i]  = v;
                }
            }
            Profiler.EndSample();
        }
Exemplo n.º 8
0
        public void Update(float dt, int nodeIndex, TreeDef treeDef, NativeSlice <NodeState> state, NativeSlice <byte> data)
        {
            int nStates = state.Length / treeDef.Nodes.Length;

            for (int i = 0; i < nStates; ++i)
            {
                var h = new NodeStateHandle(nodeIndex, state.Slice(i * treeDef.Nodes.Length, treeDef.Nodes.Length), treeDef);

                if (!h.State.Active())
                {
                    continue;
                }

                if (h.State == NodeState.Activating)
                {
                    h.State = Activate(h);
                }

                if (h.State == NodeState.Running)
                {
                    h.State = Update(dt, h);
                }
            }
        }
Exemplo n.º 9
0
 public override NodeState Activate(NodeStateHandle state)
 {
     return(NodeState.Running);
 }
Exemplo n.º 10
0
 public override NodeState Activate(NodeStateHandle state, ref int value)
 {
     value = 0;
     state.ActivateChild(0);
     return(NodeState.Running);
 }
Exemplo n.º 11
0
 public override NodeState Update(float dt, NodeStateHandle h)
 {
     Debug.Log(Value);
     return(NodeState.Complete);
 }
Exemplo n.º 12
0
 public abstract NodeState Update(float dt, NodeStateHandle h);
Exemplo n.º 13
0
 public abstract NodeState Activate(NodeStateHandle state);
Exemplo n.º 14
0
 public abstract NodeState Update(float dt, NodeStateHandle state, ref T value);
Exemplo n.º 15
0
 public abstract NodeState Activate(NodeStateHandle state, ref T value);