Пример #1
0
        public FSMConnection ConectTo(FSMState anotherState, ConditionTask condition)
        {
            FSMConnection connection = new FSMConnection(this, anotherState, _fsm);

            connection.SetCondition(condition);
            return(connection);
        }
Пример #2
0
        public void TransitionToAnotherState()
        {
            FSM           fsm        = new FSM();
            FSMState      state1     = new FSMState(fsm);
            FSMState      state2     = new FSMState(fsm);
            FSMState      state3     = new FSMState(fsm);
            FSMConnection connection = new FSMConnection(state2, state3, fsm);

            connection.SetCondition(new PassAfterNthTime(3));
            state1.ConectTo(state2);
            fsm.SetFirstNode(state1);
            fsm.Start();
            for (int i = 0; i < 4; i++)
            {
                fsm.Update();
            }
            Assert.AreEqual(state3, fsm.CurrentState);
        }