Exemplo n.º 1
0
 /// <summary>
 /// Prints the cached states in the format:
 /// ORDER - STATE
 /// </summary>
 public void PrintStates()
 {
     for (var i = 0; i < m_States.Count; ++i)
     {
         Debug.Message(i + " - " + m_States[i]);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Prints the currently defined transitions int the format:
        /// ORDER - STATE_FROM->STATE_TO
        /// </summary>
        public void PrintTransitions()
        {
            var i = 0;

            foreach (var transition in m_Transitions)
            {
                Debug.Message(i + " - " + transition);
                i++;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Attempts to add a new transition to the current list which is able to be transitioned to
        /// from any other state
        /// </summary>
        /// <param name="a_To">The state to transition to from any other state</param>
        /// <param name="a_IsValidateTransition">An optional delegate with no parameters that returns true when
        ///                                      the state change is valid and false when it is not</param>
        /// <returns>Returns true if the transition was able to be added and false otherwise</returns>
        public bool AddTransitionFromAny(string a_To)
        {
            if (!m_States.Contains(a_To))
            {
                Debug.Warning("'" + a_To + "' does not currently exist as a state");
                return(false);
            }

            if (!m_TransitionsFromAny.Contains(a_To))
            {
                m_TransitionsFromAny.Add(a_To);
                return(true);
            }
            else
            {
                Debug.Warning("'" + a_To + "' already exists as a transition key");
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Attempts to add a new transition to the current list of transitions
        /// </summary>
        /// <param name="a_From">The state to come from</param>
        /// <param name="a_To">The state to go to</param>
        /// <param name="a_IsValidTransition">An optional delegate with no parameters that returns true when
        ///                                   the state change is valid and false when it is not</param>
        /// <returns>Returns true if the transition was able to be added and false otherwise</returns>
        public bool AddTransition(string a_From, string a_To)
        {
            // if 'a_From' and 'a_To' are the same state
            if (a_From.Equals(a_To))
            {
                Debug.Warning("'" + a_From + "'" + " is the same state as " + "'" + a_To + "'");
                return(false);
            }

            // if 'a_From' or 'a_To' is not in the list of states
            if (!m_States.Contains(a_From) || !m_States.Contains(a_To))
            {
                string invalidState;   // Will decipher which state is invalid
                if (!m_States.Contains(a_From))
                {
                    invalidState = a_From;
                }
                else
                {
                    invalidState = a_To;
                }

                Debug.Warning("'" + invalidState + "' does not currently exist as a state");
                return(false);
            }

            // Properly serializes 'a_From' and 'a_To' into the expected key format
            string transition = CreateKey(a_From, a_To);

            // if the key 'key' does not currently exist in 'm_Transitions'
            if (!m_Transitions.Contains(transition))
            {
                m_Transitions.Add(transition);
                return(true);
            }
            else
            {
                Debug.Warning("'" + transition + "' already exists as a transition");
                return(false);
            }
        }