/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { //Loading dependecies inputHelper = InputHelper.Instance; gameSaver = GameSaver.Instance; Assets.pixel = new Texture2D(GraphicsDevice, 1, 1); Assets.pixel.SetData(new[] { Color.White }); topHUDRect = new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height / 16); popupRect = new Rectangle(0, GraphicsDevice.Viewport.Height / 2, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height / 8); boardPos = new Vector2(GraphicsDevice.Viewport.Width / 16, GraphicsDevice.Viewport.Height / 8); gameBoard = new GameBoard(boardPos); //Loading game modes gameModeArr = new GameBoardMode[AMOUNT_OF_GAME_MODES]; gameModeArr[0].name = "4x4"; gameModeArr[0].boardConfig.gridWidth = gameModeArr[0].boardConfig.gridHeight = 4; gameModeArr[0].boardConfig.tileWidth = gameModeArr[0].boardConfig.tileHeight = 128; gameModeArr[0].boardConfig.gameMode = GameModeState.Twos; gameModeArr[1].name = "8x8"; gameModeArr[1].boardConfig.gridWidth = gameModeArr[1].boardConfig.gridHeight = 8; gameModeArr[1].boardConfig.tileWidth = gameModeArr[1].boardConfig.tileHeight = 64; gameModeArr[1].boardConfig.gameMode = GameModeState.Twos; gameModeArr[2].name = "3s (3072) - 4x4"; gameModeArr[2].boardConfig.gridWidth = gameModeArr[2].boardConfig.gridHeight = 4; gameModeArr[2].boardConfig.tileWidth = gameModeArr[2].boardConfig.tileHeight = 128; gameModeArr[2].boardConfig.gameMode = GameModeState.Threes; gameModeArr[3].name = "Duo 2s and 3s - 6x6"; gameModeArr[3].boardConfig.gridWidth = gameModeArr[3].boardConfig.gridHeight = 6; gameModeArr[3].boardConfig.tileWidth = gameModeArr[3].boardConfig.tileHeight = 80; gameModeArr[3].boardConfig.gameMode = GameModeState.Twos | GameModeState.Threes; int[] highScoresLoaded = gameSaver.ReadHighscores(AMOUNT_OF_GAME_MODES); for (int i = 0; i < AMOUNT_OF_GAME_MODES; i++) { gameModeArr[i].highScore = highScoresLoaded[i]; } //Loading title screen menu titleMenu = new Menu(); titleMenu.SetPosition(new Vector2((GraphicsDevice.Viewport.Width / 2) - (GraphicsDevice.Viewport.Width / 8), (GraphicsDevice.Viewport.Height / 2) + (GraphicsDevice.Viewport.Height / 6))); MenuButton playGameBtn, playBigGameBtn, playThreesBtn, playDuoButton, settingsBtn, exitGameBtn; playGameBtn.name = "Play 4x4 Game"; playGameBtn.menuAction = StartRegularGame; playBigGameBtn.name = "Play 8x8 Game"; playBigGameBtn.menuAction = StartBigGame; playThreesBtn.name = "Play 3s Game (3072)"; playThreesBtn.menuAction = StartThreesGame; playDuoButton.name = "Play Duo 2s and 3s Game"; playDuoButton.menuAction = StartDuoGame; settingsBtn.name = "Settings"; settingsBtn.menuAction = GoToSettings; exitGameBtn.name = "Exit Game"; exitGameBtn.menuAction = Exit; titleMenu.AddMultiple(new MenuButton[] { playGameBtn, playBigGameBtn, playThreesBtn, playDuoButton, settingsBtn, exitGameBtn }); //Loading pause menu pauseMenu = new Menu(); pauseMenu.SetPosition(new Vector2((GraphicsDevice.Viewport.Width / 2) - (GraphicsDevice.Viewport.Width / 8), GraphicsDevice.Viewport.Height / 2)); pauseMenu.SetTitle("PAUSED"); MenuButton resumeBtn, returnBtn; resumeBtn.name = "Resume"; resumeBtn.menuAction = HidePauseMenu; returnBtn.name = "Return to Title"; returnBtn.menuAction = ReturnToTitleScreen; pauseMenu.AddMultiple(new MenuButton[] { resumeBtn, returnBtn }); //Creating tile color sets TileColorSet modern, classic, colorful; modern.name = "Modern"; modern.colorAction = TileColorHelper.CreateModernColors; classic.name = "Classic"; classic.colorAction = TileColorHelper.CreateClassicColors; colorful.name = "Colorful"; colorful.colorAction = TileColorHelper.CreateColorfulColors; colorHolder = TileColorHolder.Instance; colorHolder.AddTileColorSet(modern); colorHolder.AddTileColorSet(classic); colorHolder.AddTileColorSet(colorful); //Loading settings menu settingsMenu = new Menu(); settingsMenu.SetPosition(new Vector2((GraphicsDevice.Viewport.Width / 2) - (GraphicsDevice.Viewport.Width / 8), (GraphicsDevice.Viewport.Height / 2) + (GraphicsDevice.Viewport.Height / 4))); settingsMenu.SetTitle("Settings"); MenuButton tileColorBtn, clearHighscoresBtn, backBtn; tileColorBtn.name = "Change Tile Color Theme -%o-"; tileColorBtn.menuAction = colorHolder.GoToNextTileColorSet; clearHighscoresBtn.name = "Clear High Scores"; clearHighscoresBtn.menuAction = ClearHighscores; backBtn.name = "Back"; backBtn.menuAction = ReturnToTitleScreen; settingsMenu.AddMultiple(new MenuButton[] { tileColorBtn, clearHighscoresBtn, backBtn }); //Starting game at specified screen SetScreenState = ScreenState.TitleScreen; base.Initialize(); }