private void AddState(GameState newState) { gameStates.Push(newState); Game.Components.Add(newState); OnStateChange += newState.StateChange; }
public void PushState(GameState newState) { drawOrder += DrawOrderInc; newState.DrawOrder = drawOrder; AddState(newState); if (OnStateChange != null) { OnStateChange(this, null); } }
/// <summary> /// This is what will be updated every frame. In here we switch between game screens and more. /// There are many helper function located below that this generic update method calls. /// Some helper functions include drawing and updating. This removes a ton of non-logic from the /// below method. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> //UPDATE GAME HERE// protected override void Update(GameTime gameTime) { //Mouse state. May or may not work for touch. MouseState mouse = Mouse.GetState(); // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); //This switch statment dictates what game state we are currently in. //The game states switch between the welcome home screen, the create a new level screen, the load level screen, //the level editor screen and finally the game playing screen for the patient. switch (CurrentGameState) { ///////////////////////////////update if in HOME SCREEN/////////////////////////////// case GameState.HomeScreen: if (btnNew.isClicked == true) { CurrentGameState = GameState.NewLevelScreen; } if (btnLoad.isClicked == true) { CurrentGameState = GameState.LoadLevelScreen; } if (btnExit.isClicked == true) { this.Exit(); } UpdateHomeScreen(gameTime, mouse); break; //////////////////////////////update if in NEWLEVEL SCREEN////////////////////////////// case GameState.NewLevelScreen: if (btnCancel.isClicked == true) { CurrentGameState = GameState.HomeScreen; } if (btnCreate.isClicked == true) { CurrentGameState = GameState.LevelEditor; } if (clearNameButton.isClicked == true) { nameHighlight = true; } if (clearDescriptionButton.isClicked == true) { nameHighlight = false; } if (a.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "a"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "a"; } a.isClicked = false; Thread.Sleep(50); } if (b.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "b"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "b"; } b.isClicked = false; Thread.Sleep(50); } if (c.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "c"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "c"; } c.isClicked = false; Thread.Sleep(50); } if (d.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "d"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "d"; } d.isClicked = false; Thread.Sleep(50); } if (e.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "e"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "e"; } e.isClicked = false; Thread.Sleep(50); } if (f.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "f"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "f"; } f.isClicked = false; Thread.Sleep(50); } if (g.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "g"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "g"; } g.isClicked = false; Thread.Sleep(50); } if (h.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "h"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "h"; } h.isClicked = false; Thread.Sleep(50); } if (i.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "i"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "i"; } i.isClicked = false; Thread.Sleep(50); } if (j.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "j"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "j"; } j.isClicked = false; Thread.Sleep(50); } if (k.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "k"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "k"; } k.isClicked = false; Thread.Sleep(50); } if (l.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "l"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "l"; } l.isClicked = false; Thread.Sleep(50); } if (m.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "m"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "m"; } m.isClicked = false; Thread.Sleep(50); } if (n.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "n"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "n"; } n.isClicked = false; Thread.Sleep(50); } if (o.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "o"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "o"; } o.isClicked = false; Thread.Sleep(50); } if (p.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "p"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "p"; } p.isClicked = false; Thread.Sleep(50); } if (q.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "q"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "q"; } q.isClicked = false; Thread.Sleep(50); } if (r.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "r"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "r"; } r.isClicked = false; Thread.Sleep(50); } if (s.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "s"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "s"; } s.isClicked = false; Thread.Sleep(50); } if (t.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "t"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "t"; } t.isClicked = false; Thread.Sleep(50); } if (u.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "u"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "u"; } u.isClicked = false; Thread.Sleep(50); } if (v.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "v"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "v"; } v.isClicked = false; Thread.Sleep(50); } if (w.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "w"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "w"; } w.isClicked = false; Thread.Sleep(50); } if (x.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "x"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "x"; } x.isClicked = false; Thread.Sleep(50); } if (y.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "y"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "y"; } y.isClicked = false; Thread.Sleep(50); } if (z.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "z"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "z"; } z.isClicked = false; Thread.Sleep(50); } if (space1.isClicked == true || space2.isClicked) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist + "_"; } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist + "_"; } space1.isClicked = false; space2.isClicked = false; Thread.Sleep(50); } if (delete1.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = nameOfTherapist.Remove((nameOfTherapist.Length)-1); } if (nameHighlight == false) { descriptionByTherapist = descriptionByTherapist.Remove((descriptionByTherapist.Length) - 1); } delete1.isClicked = false; Thread.Sleep(50); } if (clear.isClicked == true) { if (nameHighlight == true) { nameOfTherapist = ""; } if (nameHighlight == false) { descriptionByTherapist = ""; } clear.isClicked = false; Thread.Sleep(50); } if (delName.isClicked == true) { nameHighlight = true; nameOfTherapist = ""; } if (delDesc.isClicked == true) { nameHighlight = false; descriptionByTherapist = ""; } UpdateNewLevelScreen(gameTime, mouse); break; /////////////////////////////////////update if in LOAD LEVEL SCREEN/////////////////////////////// case GameState.LoadLevelScreen: if (goSearch.isClicked == true) { } if (btnCancel.isClicked == true) { CurrentGameState = GameState.HomeScreen; } if (btnOpen.isClicked == true) { CurrentGameState = GameState.LevelEditor; } if (delSearch.isClicked == true) { searchQuery = ""; } if (clearSearchButton.isClicked == true) { if (loadKeyBoard == false) { loadKeyBoard = true; } //else { loadKeyBoard = false; } clearSearchButton.isClicked = false; Thread.Sleep(50); } if (a.isClicked == true) { searchQuery = searchQuery + "a"; a.isClicked = false; Thread.Sleep(50); } if (b.isClicked == true) { searchQuery = searchQuery + "b"; b.isClicked = false; Thread.Sleep(50); } if (c.isClicked == true) { searchQuery = searchQuery + "c"; c.isClicked = false; Thread.Sleep(50); } if (d.isClicked == true) { searchQuery = searchQuery + "d"; d.isClicked = false; Thread.Sleep(50); } if (e.isClicked == true) { searchQuery = searchQuery + "e"; e.isClicked = false; Thread.Sleep(50); } if (f.isClicked == true) { searchQuery = searchQuery + "f"; f.isClicked = false; Thread.Sleep(50); } if (g.isClicked == true) { searchQuery = searchQuery + "g"; g.isClicked = false; Thread.Sleep(50); } if (h.isClicked == true) { searchQuery = searchQuery + "h"; h.isClicked = false; Thread.Sleep(50); } if (i.isClicked == true) { searchQuery = searchQuery + "i"; i.isClicked = false; Thread.Sleep(50); } if (j.isClicked == true) { searchQuery = searchQuery + "j"; j.isClicked = false; Thread.Sleep(50); } if (k.isClicked == true) { searchQuery = searchQuery + "k"; k.isClicked = false; Thread.Sleep(50); } if (l.isClicked == true) { searchQuery = searchQuery + "l"; l.isClicked = false; Thread.Sleep(50); } if (m.isClicked == true) { searchQuery = searchQuery + "m"; m.isClicked = false; Thread.Sleep(50); } if (n.isClicked == true) { searchQuery = searchQuery + "n"; n.isClicked = false; Thread.Sleep(50); } if (o.isClicked == true) { searchQuery = searchQuery + "o"; o.isClicked = false; Thread.Sleep(50); } if (p.isClicked == true) { searchQuery = searchQuery + "p"; p.isClicked = false; Thread.Sleep(50); } if (q.isClicked == true) { searchQuery = searchQuery + "q"; q.isClicked = false; Thread.Sleep(50); } if (r.isClicked == true) { searchQuery = searchQuery + "r"; r.isClicked = false; Thread.Sleep(50); } if (s.isClicked == true) { searchQuery = searchQuery + "s"; s.isClicked = false; Thread.Sleep(50); } if (t.isClicked == true) { searchQuery = searchQuery + "t"; t.isClicked = false; Thread.Sleep(50); } if (u.isClicked == true) { searchQuery = searchQuery + "u"; u.isClicked = false; Thread.Sleep(50); } if (v.isClicked == true) { searchQuery = searchQuery + "v"; v.isClicked = false; Thread.Sleep(50); } if (w.isClicked == true) { searchQuery = searchQuery + "w"; w.isClicked = false; Thread.Sleep(50); } if (x.isClicked == true) { searchQuery = searchQuery + "x"; x.isClicked = false; Thread.Sleep(50); } if (y.isClicked == true) { searchQuery = searchQuery + "y"; y.isClicked = false; Thread.Sleep(50); } if (z.isClicked == true) { searchQuery = searchQuery + "z"; z.isClicked = false; Thread.Sleep(50); } if (space1.isClicked == true || space2.isClicked) { searchQuery = searchQuery + "_"; space1.isClicked = false; space2.isClicked = false; Thread.Sleep(50); } if (delete1.isClicked == true) { searchQuery = searchQuery.Remove((searchQuery.Length) - 1); delete1.isClicked = false; Thread.Sleep(50); } if (clear.isClicked == true) { searchQuery = ""; clear.isClicked = false; Thread.Sleep(50); } UpdateLoadLevelScreen(gameTime, mouse); break; ////////////////////////////////update if in LEVEL EDITIOR SCREEN/////////////////////////////// case GameState.LevelEditor: if (btnHome.isClicked == true) { CurrentGameState = GameState.HomeScreen; //Call A Method Defined In Another Class } if (btnMenu.isClicked == true) { if (levelEditorMenuON == true) { levelEditorMenuON = false; }else { levelEditorMenuON = true; } btnMenu.Update(mouse); btnMenu.isClicked = false; Thread.Sleep(50); //Call A Method Defined In Another Class } if (btnHoldTime.isClicked == true) { //Call A Method Defined In Another Class } if (btnMultiple.isClicked == true) { if (multiState == true) { multiState = false; btnMultiple = new cButton55x55(Content.Load<Texture2D>("LevelEditorGUI/multipleToggleOff"), graphics.GraphicsDevice); btnMultiple.setPosition(new Vector2(355, 30)); btnMultiple.Update(mouse); btnMultiple.isClicked = false; Thread.Sleep(50); } else if (multiState == false) { multiState = true; btnMultiple = new cButton55x55(Content.Load<Texture2D>("LevelEditorGUI/multipleToggleOn"), graphics.GraphicsDevice); btnMultiple.setPosition(new Vector2(355, 30)); btnMultiple.Update(mouse); btnMultiple.isClicked = false; Thread.Sleep(50); } //Call A Method Defined In Another Class } if (btnPlay.isClicked == true) { CurrentGameState = GameState.PatientGame; //Call A Method Defined In Another Class } if (btnRedo.isClicked == true) { //Call A Method Defined In Another Class } if (btnUndo.isClicked == true) { //Call A Method Defined In Another Class } if (btnUpTime.isClicked == true) { //Call A Method Defined In Another Class } if (btnMoreUp.isClicked == true) { intUpTime++; btnMoreUp.isClicked = false; Thread.Sleep(50); //Call A Method Defined In Another Class } if (btnLessUp.isClicked == true) { intUpTime--; btnLessUp.isClicked = false; Thread.Sleep(50); //Call A Method Defined In Another Class } if (btnMoreHold.isClicked == true) { intHoldTime++; btnMoreHold.isClicked = false; Thread.Sleep(50); //Call A Method Defined In Another Class } if (btnLessHold.isClicked == true) { intHoldTime--; btnLessHold.isClicked = false; Thread.Sleep(50); //Call A Method Defined In Another Class } if (btnLemBack.isClicked == true) { levelEditorMenuON = false; btnLemBack.isClicked = false; Thread.Sleep(50); } if (btnLemSave.isClicked == true) { levelEditorMenuON = false; btnLemSave.isClicked = false; Thread.Sleep(50); } if (btnLemLoad.isClicked == true) { levelEditorMenuON = false; btnLemLoad.isClicked = false; Thread.Sleep(50); CurrentGameState = GameState.LoadLevelScreen; } if (btnLemClear.isClicked == true) { levelEditorMenuON = false; btnLemClear.isClicked = false; Thread.Sleep(50); } if (btnLemExit.isClicked == true) { levelEditorMenuON = false; this.Exit(); } if (btnAddLetter.isClicked == true) { showingAlpha = true; showingNumbers = false; showingShapes = false; btnAddLetter.isClicked = false; Thread.Sleep(50); } if (btnAddNumber.isClicked == true) { showingNumbers = true; showingAlpha = false; showingShapes = false; btnAddNumber.isClicked = false; Thread.Sleep(50); } if (btnAddShape.isClicked == true) { showingShapes = true; showingAlpha = false; showingNumbers = false; btnAddShape.isClicked = false; Thread.Sleep(50); } if (btnHidePallet.isClicked == true) { if (shapePalletVisible){shapePalletVisible = false;} else { shapePalletVisible = true; } btnHidePallet.isClicked = false; Thread.Sleep(50); } if (btnThumbCircle.isClicked == true) { showingShapes = false; sizeChoosing = true; btnThumbCircle.isClicked = false; Thread.Sleep(50); } if (btnThumbSquare.isClicked == true) { showingShapes = false; sizeChoosing = true; btnThumbSquare.isClicked = false; Thread.Sleep(50); } if (btnThumbStar.isClicked == true) { showingShapes = false; sizeChoosing = true; btnThumbStar.isClicked = false; Thread.Sleep(50); } if (btnThumbTriangle.isClicked == true) { showingShapes = false; sizeChoosing = true; btnThumbTriangle.isClicked = false; Thread.Sleep(50); } if (sizeTiny.isClicked == true) { showingShapes = false; sizeChoosing = false; colorChoosing = true; sizeTiny.isClicked = false; Thread.Sleep(1500); } if (sizeSmall.isClicked == true) { showingShapes = false; sizeChoosing = false; colorChoosing = true; sizeSmall.isClicked = false; Thread.Sleep(500); } if (sizeMedium.isClicked == true) { showingShapes = false; sizeChoosing = false; colorChoosing = true; sizeMedium.isClicked = false; Thread.Sleep(500); } if (sizeLarge.isClicked == true) { showingShapes = false; sizeChoosing = false; colorChoosing = true; sizeLarge.isClicked = false; Thread.Sleep(500); } if (sizeXLarge.isClicked == true) { showingShapes = false; sizeChoosing = false; colorChoosing = true; sizeXLarge.isClicked = false; Thread.Sleep(500); } if (colorBlackBtn.isClicked == true) { colorChoosing = false; showingShapes = true; colorBlackBtn.isClicked = false; Thread.Sleep(500); } if (colorBlueBtn.isClicked == true) { colorChoosing = false; showingShapes = true; colorBlueBtn.isClicked = false; Thread.Sleep(500); } if (colorDarkBlueBtn.isClicked == true) { colorChoosing = false; showingShapes = true; colorDarkBlueBtn.isClicked = false; Thread.Sleep(500); } if (colorDarkGreyBtn.isClicked == true) { colorChoosing = false; showingShapes = true; colorDarkGreyBtn.isClicked = false; Thread.Sleep(500); } if (colorGreenBtn.isClicked == true) { colorChoosing = false; showingShapes = true; colorGreenBtn.isClicked = false; Thread.Sleep(500); } if (colorGreyBtn.isClicked == true) { colorChoosing = false; showingShapes = true; colorGreyBtn.isClicked = false; Thread.Sleep(500); } if (colorLightBlueBtn.isClicked == true) { colorChoosing = false; showingShapes = true; colorLightBlueBtn.isClicked = false; Thread.Sleep(500); } if (colorLightGreen.isClicked == true) { colorChoosing = false; showingShapes = true; colorLightGreen.isClicked = false; Thread.Sleep(500); } if (colorOrangeBtn.isClicked == true) { colorChoosing = false; showingShapes = true; colorOrangeBtn.isClicked = false; Thread.Sleep(500); } if (colorPinkBtn.isClicked == true) { colorChoosing = false; showingShapes = true; colorPinkBtn.isClicked = false; Thread.Sleep(500); } if (colorRedBtn.isClicked == true) { colorChoosing = false; showingShapes = true; colorRedBtn.isClicked = false; Thread.Sleep(500); } if (colorYellowBtn.isClicked == true) { colorChoosing = false; showingShapes = true; colorYellowBtn.isClicked = false; Thread.Sleep(500); } if (put0.isClicked == true) { put0.isClicked = false; Thread.Sleep(500); } if (put1.isClicked == true) { put1.isClicked = false; Thread.Sleep(500); } if (put2.isClicked == true) { put2.isClicked = false; Thread.Sleep(500); } if (put3.isClicked == true) { put3.isClicked = false; Thread.Sleep(500); } if (put4.isClicked == true) { put4.isClicked = false; Thread.Sleep(500); } if (put5.isClicked == true) { put5.isClicked = false; Thread.Sleep(500); } if (put6.isClicked == true) { put6.isClicked = false; Thread.Sleep(500); } if (put7.isClicked == true) { put7.isClicked = false; Thread.Sleep(500); } if (put8.isClicked == true) { put8.isClicked = false; Thread.Sleep(500); } if (put9.isClicked == true) { put9.isClicked = false; Thread.Sleep(500); } if (putA.isClicked == true) { putA.isClicked = false; Thread.Sleep(500); } if (putB.isClicked == true) { putB.isClicked = false; Thread.Sleep(500); } if (putC.isClicked == true) { putC.isClicked = false; Thread.Sleep(500); } if (putD.isClicked == true) { putD.isClicked = false; Thread.Sleep(500); } if (putE.isClicked == true) { putE.isClicked = false; Thread.Sleep(500); } if (putF.isClicked == true) { putF.isClicked = false; Thread.Sleep(500); } if (putG.isClicked == true) { putG.isClicked = false; Thread.Sleep(500); } if (putH.isClicked == true) { putH.isClicked = false; Thread.Sleep(500); } if (putI.isClicked == true) { putI.isClicked = false; Thread.Sleep(500); } if (putJ.isClicked == true) { putJ.isClicked = false; Thread.Sleep(500); } if (putK.isClicked == true) { putK.isClicked = false; Thread.Sleep(500); } if (putL.isClicked == true) { putL.isClicked = false; Thread.Sleep(500); } if (putM.isClicked == true) { putM.isClicked = false; Thread.Sleep(500); } if (putN.isClicked == true) { putN.isClicked = false; Thread.Sleep(500); } if (putO.isClicked == true) { putO.isClicked = false; Thread.Sleep(500); } if (putP.isClicked == true) { putP.isClicked = false; Thread.Sleep(500); } if (putQ.isClicked == true) { putQ.isClicked = false; Thread.Sleep(500); } if (putR.isClicked == true) { putR.isClicked = false; Thread.Sleep(500); } if (putS.isClicked == true) { putS.isClicked = false; Thread.Sleep(500); } if (putT.isClicked == true) { putT.isClicked = false; Thread.Sleep(500); } if (putU.isClicked == true) { putU.isClicked = false; Thread.Sleep(500); } if (putV.isClicked == true) { putV.isClicked = false; Thread.Sleep(500); } if (putW.isClicked == true) { putW.isClicked = false; Thread.Sleep(500); } if (putX.isClicked == true) { putX.isClicked = false; Thread.Sleep(500); } if (putY.isClicked == true) { putY.isClicked = false; Thread.Sleep(500); } if (putZ.isClicked == true) { putZ.isClicked = false; Thread.Sleep(500); } UpdateLevelEditorScreen(gameTime, mouse); break; ///////////////////////////////update if playing PATIENT GAME//////////////////////////////////////// case GameState.PatientGame: if (btnBack.isClicked == true) { btnBack.isClicked = false; pauseMenuON = true; Thread.Sleep(50); btnBack.Update(mouse); } if (btnPauseContinue.isClicked == true) { pauseMenuON = false; } if (btnPauseEdit.isClicked == true) { pauseMenuON = false; CurrentGameState = GameState.LevelEditor; } if (btnPauseLoad.isClicked == true) { pauseMenuON = false; CurrentGameState = GameState.LoadLevelScreen; } if (btnPauseRestart.isClicked == true) { pauseMenuON = false; } UpdateGameScreen(gameTime, mouse); break; } // TODO: Add your update logic here // UpdateSprite(gameTime); //example code base.Update(gameTime); }
public void ChangeState(GameState newState) { while (gameStates.Count > 0) { RemoveState(); } newState.DrawOrder = StartDrawOrder; drawOrder = StartDrawOrder; AddState(newState); if (OnStateChange != null) { OnStateChange(this, null); } }