public void SwitchState(RobotState state) { currentState?.OnStateExit(); currentState = state; currentState.robot = this; currentState.OnStateEnter(); txt.text = "State : " + currentState.GetType().ToString(); }
public void SetState(RobotState state) { if (CurrentState != null) { CurrentState.OnStateExit(); } CurrentState = state; gameObject.name = "Robot - " + state.GetType().Name; if (CurrentState != null) { CurrentState.OnStateEnter(); } }