/// <summary> /// Initialises necessary objects for game start. /// Most notably initialises the game state machine /// </summary> protected override void Initialize() { this.IsMouseVisible = true; globalBindings = new KeybindingManager(); //Bind the fullscreen toggle to the global bindings globalBindings.BindKeyEvent(Keys.F11, InputState.down, ToggleFullScreen); //Bind the escape button to the Exit action globalBindings.BindKeyEvent(Keys.Escape, InputState.down, Exit); GameData.Initialise(); eventManager = new GameEventManager(); GameEventManager.Instance = eventManager; camera = new Camera(graphics.GraphicsDevice.Viewport); camera.Position = new Vector2(0, 0); Camera.mainCamera = camera; //Default background defaultBackgroundTex = Content.Load <Texture2D>("PlatformerGraphicsDeluxe/Backgrounds/bg"); background = new Graphics.Background(defaultBackgroundTex, Vector2.One, Color.White); GameStateMachine = new FSM(); //NOTE spaces don't seem to scale correctly, so tabs are used. TextScreen startScreenState = new StartScreen(this, "Explorer", "Press enter to continue", Keys.Enter); startScreenState.Name = "Start"; PlayGame playGameState = new PlayGame(this); TextScreen loseScreenState = new EndScreen(this, "YOU LOSE", "Press enter to continue", Keys.Enter); loseScreenState.Name = "Lose"; TextScreen winScreenState = new EndScreen(this, "YOU WIN", "Press enter to continue", Keys.Enter); winScreenState.Name = "Win"; startScreenState.AddTransition(playGameState, () => { return(startScreenState.done); }); loseScreenState.AddTransition(startScreenState, () => { return(loseScreenState.done); }); winScreenState.AddTransition(startScreenState, () => { return(winScreenState.done); }); playGameState.AddTransition(loseScreenState, () => { return(playGameState.GameLost); }); playGameState.AddTransition(winScreenState, () => { return(playGameState.GameWon); }); GameStateMachine.AddStates(startScreenState, playGameState, loseScreenState, winScreenState); base.Initialize(); }