Example #1
0
        public override void Execute(FSMBehaviour fsm)
        {
            NodePort outPort = GetOutputPort("outState");

            if (outPort.ConnectionCount > 0)
            {
                NodeBase_State next = (NodeBase_State)outPort.Connection.node;
                next.SetCurrentState();
            }
        }
Example #2
0
        private NodeBase_State GetNextState()
        {
            NodeBase_State result       = null;
            NodePort       outStatePort = OutStatePort;

            if (outStatePort.ConnectionCount == 0)
            {
                return(result);
            }

            result = (NodeBase_State)outStatePort.Connection.node;

            return(result);
        }
Example #3
0
        public bool SetRootState(NodeBase_State state)
        {
            if (state == _rootState)
            {
                return(false);
            }
            if (state == null)
            {
                return(false);
            }

            _rootState = state;
            return(true);
        }
Example #4
0
        private void GoToNextState(bool decisionResult)
        {
            if (decisionResult == false)
            {
                return;
            }

            NodeBase_State nextState = GetNextState();

            if (nextState == null)
            {
                return;
            }

            nextState.SetCurrentState();
        }
Example #5
0
            public void ExecuteDecisions(FSMBehaviour fsm)
            {
                if (outputPort.ConnectionCount <= 0)
                {
                    return;
                }

                bool result = GetDecisionResult(fsm);

                //Transition to other state
                if (result == false && outputPort.ConnectionCount <= 0)
                {
                    return;
                }

                NodeBase_State state = (NodeBase_State)outputPort.Connection.node;

                state.SetCurrentState();
            }
Example #6
0
        public void InitGraph(FSMBehaviour fsm)
        {
            currentState_elapsedTime = 0;

            if (RootState == null)
            {
                XNode.Node node = nodes.FirstOrDefault(r => r is NodeBase_State);
                if (node != null)
                {
                    _rootState    = (NodeBase_State)node;
                    _currentState = _rootState;
                }
            }

            if (RootState != null)
            {
                _currentState = RootState;
            }
        }
Example #7
0
 private void GoToNextState(bool decisionResult)
 {
     if (decisionResult)
     {
         NodeBase_State nextTrueState = GetNextTrueState();
         if (nextTrueState)
         {
             nextTrueState.SetCurrentState();
         }
     }
     else
     {
         NodeBase_State nextFalseState = GetNextFalseState();
         if (nextFalseState)
         {
             nextFalseState.SetCurrentState();
         }
     }
 }
Example #8
0
        /// <summary>
        /// Força o <seealso cref="CurrentState"/> para o estado do parametro.
        /// </summary>
        /// <param name="state">Novo estado para <see cref="CurrentState"/></param>
        /// <returns>Verdadeiro: Se o <seealso cref="CurrentState"/> foi modificado para um estado diferente do anterior</returns>
        public bool SetCurrentState(NodeBase_State state)
        {
            if (state == _currentState)
            {
                return(false);
            }
            if (state == null)
            {
                return(false);
            }

            currentState_elapsedTime = 0;
            _currentState            = state;

            if (OnStateChangedEvent != null)
            {
                OnStateChangedEvent.Invoke();
            }

            return(true);
        }