/// <summary> /// Sets the current in-game state. /// </summary> /// <param name="newState">New state.</param> public void SetState(InGameState newState) { if (state != null) { state.OnExit(this); GameObject.Destroy(state.gameObject); } if (newState != null) { state = newState; state.OnEnter (this); } }