//Using a given state, update the engine to the new state (I.E switch to game view mode | front-end mode) public void UpdateGameState(GameState newState) { //Destroy the previous state by clearing its reference (Garbage collector will pick it up) activeGameState = null; //Update state record to point to the new state object switch (newState) { case GameState.Splash: { activeGameState = new Splash_Screen(engCoreRef); break; } case GameState.FrontEnd: { activeGameState = new Front_End(engCoreRef); break; } case GameState.Game: { activeGameState = new Dialogue(engCoreRef); break; } } }
/// <summary> /// Initialization Method /// </summary> public Dialogue(Engine_Core coreRef) { //Cast to the interface in order to call interface functions myInterface = this; //Retain a reference to the Engine_Core engCoreRef = coreRef; //Run the core state function Console.WriteLine("Activating Dialogue State!"); myInterface.Main(); }
//Initialization method public Front_End_UI(Front_End curState, Engine_Core coreRef, IGame_State_Base stateInterface) { //Store references stateFunctions = stateInterface; engCoreRef = coreRef; state = curState; //---------------GENERATE BUTTONS--------------- //Create the Start Game Button Base_Button.ClickEvent clickEvent = GoToGame; startGameButton = new Base_Button( new Sprite() { Texture = engCoreRef.Content.Load <Texture2D>("UI/Front_End/Test_Button"), Color = Color.White, Size = new Rectangle(engCoreRef.GraphicsDevice.Viewport.Width / 2 - 128, (engCoreRef.GraphicsDevice.Viewport.Height / 2) - 32, 256, 64) }, new TextSprite() { Font = engCoreRef.Content.Load <SpriteFont>("UI/Fonts/Menu_Button_01"), Text = "Start Game", Color = Color.White }, clickEvent); //Create the Exit Game Button clickEvent = ExitGame; exitGameButton = new Base_Button( new Sprite() { Texture = engCoreRef.Content.Load <Texture2D>("UI/Front_End/Test_Button"), Color = Color.White, Size = new Rectangle(engCoreRef.GraphicsDevice.Viewport.Width / 2 - 128, (engCoreRef.GraphicsDevice.Viewport.Height / 2) + (engCoreRef.GraphicsDevice.Viewport.Height / 6) - 32, 256, 64) }, new TextSprite() { Font = engCoreRef.Content.Load <SpriteFont>("UI/Fonts/Menu_Button_01"), Text = "Exit Game", Color = Color.White }, clickEvent); //Add the buttons to the draw stack engCoreRef.drawStack.Add("Start_Game_Button", startGameButton.myArt); engCoreRef.textDrawStack.Add("Start_Game_Button_Text", startGameButton.myText); engCoreRef.drawStack.Add("Exit_Game_Button", exitGameButton.myArt); engCoreRef.textDrawStack.Add("Exit_Game_Button_Text", exitGameButton.myText); }
/// <summary> /// Initialization Method /// </summary> public Front_End(Engine_Core coreRef) { //Cast to the interface in order to call interface functions myInterface = this; //Retain a reference to the Engine_Core engCoreRef = coreRef; //Generate the U.I Class frontEndUI = new Front_End_UI(this, engCoreRef, myInterface); //Run the core state function Console.WriteLine("Activating Front-End!"); myInterface.Main(); }