Example #1
0
 public void AddTransition(State sourceState, State targetState, string transitionTrigger)
 {
     if (sourceState != null && targetState != null && Array.Exists(m_Triggers, element => element == transitionTrigger))
     {
         var newTransition = new StateTransition(sourceState, targetState, transitionTrigger);
         if (!Array.Exists(m_Transitions, element => element.Equals(newTransition)))
         {
             Array.Resize(ref m_Transitions, m_Transitions.Length + 1);
             m_Transitions[m_Transitions.Length - 1] = newTransition;
         }
     }
 }
Example #2
0
        public void RemoveTransition(StateTransition transition)
        {
            if (Array.Exists(m_Transitions, element => element.Equals(transition)))
            {
                var transitionIndex = Array.IndexOf(m_Triggers, transition);
                for (int i = transitionIndex; i < m_Transitions.Length - 1; i++)
                {
                    m_Transitions[i] = m_Transitions[i + 1];
                }

                Array.Resize(ref m_Transitions, m_Transitions.Length - 1);
            }
        }