/// <summary> /// Change the current state to a new state /// </summary> /// <param name="newState">The new state to change to </param> public void ChangeState(State newState) { if (currentState == newState) { return; } //check null for initialization if (currentState != null) { //Exit the current state currentState.Exit(); _LogState("Exit"); } //Make current state as previous prevState = currentState; //Make the new state as current currentState = newState; //Enter the new state currentState.Entry(); _LogState("Entry"); }
public void ChangeState(State <T> newState) { if (currentState != null) { currentState.Exit(); } currentState = newState; currentState.Init(this, refScript); DebugMessage("Entering"); currentState.Enter(); DebugMessage(newState.GetType().Name); }
public void ChangeState(TStateType newState) { if (currentState != null) { currentState.Exit(); } currentState = stateDictionary[newState]; if (currentState != null) { currentState.Enter(); } }
public void ChangeState(State <T> newState) { if (newState == null) { Debug.Log("Trying to change to a null State"); } else { previousState = currentState; currentState.Exit(owner); currentState = newState; currentState.Enter(owner); } }
public void ChangeState(State newState) { if (currentState != null) { currentState.Exit(); } currentState = newState; if (currentState != null) { currentState.SetCharacter(character); currentState.Enter(); } }