Ejemplo n.º 1
0
        /// <summary>
        /// Returns to an existing state.
        /// </summary>
        /// <param name="state">The state to return to.</param>
        private void ReturnTo(State state)
        {
            //Do nothing if there's no such state
            if (!m_StateList.Contains(state)) return;

            //Keep marking state until found
            LinkedListNode<State> Current = m_StateList.Last;
            while (Current != null && Current.Value != state) {
                //Increase depth and go to next
                Current = Current.Previous;
                m_Depth++;
            }
        }
Ejemplo n.º 2
0
        public State GetPreviousState(State state)
        {
            //Check for null
            if (state == null)          return null;
            if (m_StateList == null)    return null;

            //Variable
            LinkedListNode<State> Source  = null;
            LinkedListNode<State> Current = m_StateList.First;

            //While state still exist
            while (Current != null) {
                //Find source
                if (Current.Value == state) Source = Current;
                Current = Current.Next;
            }

            //Return null if there's no previous state
            if (Source.Previous == null) return null;

            //Otherwise, return previous value
            return Source.Previous.Value;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a new state at the end of the state list.
        /// </summary>
        /// <param name="state">The new state that will be added</param>
        private void AddState(State state)
        {
            //Do nothing if state is null
            if (state == null) return;

            //Add and initialize state
            m_StateList.AddLast(state);
            m_StateList.Last.Value.Initialize();
            EnterState();

            //Logging
            Global.Logger.AddLine(state + " has been added to the state list.");

            //If top state isn't popup, turn off lower states
            #region Manage popup states);
            if (!m_StateList.Last.Value.IsPopUp()) {
                //Create variable
                LinkedListNode<State> Current = m_StateList.Last;

                do {
                    //Turn off previous state
                    Current = Current.Previous;
                    if (Current != null) Current.Value.SetVisibility(false);
                    //While current state is popup
                } while (Current != null && Current.Value.IsPopUp());
            }
            #endregion
        }