Beispiel #1
0
        public void AddTransition(S initial_state, S end_state, StateTransitionCall call)
        {
            StateTransition <S> temp_transition = new StateTransition <S>(initial_state, end_state);

            if (TransitionTable.ContainsKey(temp_transition))
            {
                return;
            }

            TransitionTable.Add(temp_transition, call);
        }
Beispiel #2
0
        virtual public void Advance(S next_state)
        {
            StateTransition <S> temp_state_transition = new StateTransition <S>(currentState, next_state);

            System.Delegate temp_delegate;
            if (TransitionTable.TryGetValue(temp_state_transition, out temp_delegate))
            {
                if (temp_delegate != null)
                {
                    StateTransitionCall call = temp_delegate as StateTransitionCall;
                    call();
                }

                previousState = currentState;
                currentState  = next_state;
            }
            else
            {
                throw new FiniteStateMachineException();
            }
        }