Beispiel #1
0
        /// <summary>
        /// Registers a new state
        /// </summary>
        /// <param name="state">State to register</param>
        public void RegisterState(JState state)
        {
            statesList.Add(state);

            //We set a reference to this machine to the state so it will be able
            //to change the current state from within any state
            state.SetStateMachine(this);
        }
Beispiel #2
0
		/// <summary>
		/// Registers a new state
		/// </summary>
		/// <param name="state">State to register</param>
		public void RegisterState(JState state)
		{
			statesList.Add(state);

			//We set a reference to this machine to the state so it will be able
			//to change the current state from within any state
			state.SetStateMachine(this);
		}
Beispiel #3
0
		/// <summary>
		/// Changes the current state with a registered state
		/// </summary>
		/// <param name="state">Name of the state</param>
		public bool SetCurrentState(string state)
		{
			//Run exiting code for the current state
			if (currentState != null)
				currentState.OnExit();

			//Set the new current state
			currentState = statesList.FindFirst(state);

			//Run the entering code for the new current state
			if (currentState != null)
				return currentState.OnEnter();

			return false;
		}
Beispiel #4
0
        /// <summary>
        /// Changes the current state with a registered state
        /// </summary>
        /// <param name="state">Name of the state</param>
        public bool SetCurrentState(string state)
        {
            //Run exiting code for the current state
            if (currentState != null)
            {
                currentState.OnExit();
            }

            //Set the new current state
            currentState = statesList.FindFirst(state);

            //Run the entering code for the new current state
            if (currentState != null)
            {
                return(currentState.OnEnter());
            }

            return(false);
        }
Beispiel #5
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public JStateMachine()
 {
     currentState = null;
     statesList   = new JList <JState>();
 }
Beispiel #6
0
		/// <summary>
		/// Default constructor
		/// </summary>
		public JStateMachine()
		{
			currentState = null;
			statesList = new JList<JState>();
		}