コード例 #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);
        }
コード例 #2
0
        public bool Equals(StateTransition <S> other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(InitialState.Equals(other.InitialState) && EndState.Equals(other.EndState));
        }
コード例 #3
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();
            }
        }