//enters a new state and exists the current state. private void SetState(CharacterStateData state) { //check if our current state is vald if (m_currState) { //exit the state m_currState.OnExit(this); //[TODO] } //Check the new state is valid if (state) { //enter the state state.OnEnter(this); //[TODO] } //set our current state to the new state m_currState = state; }
public override void OnTick(Controller controller, CharacterStateData data) { //get our state data casted CharacterMultiStateData myData = data as CharacterMultiStateData; //tick our state if (myData.states.Count > 0) { for (int i = 0; i < myData.states.Count; ++i) { CharacterStateData newState = myData.states[i].GetStateOnTransition(controller); if (newState) { myData.states[i].OnExit(controller); myData.states[i] = newState; newState.OnEnter(controller); } myData.states[i].OnTick(controller); } } base.OnTick(controller, data); }