/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Aquamarine); // TODO: Add your drawing code here switch (gameState) { case GAMESTATE.GAMESTATE_MAIN_MENU: { spriteBatch.Begin(); spriteBatch.DrawString(defaultFont, "###############", new Vector2(graphics.PreferredBackBufferWidth / 2 - 100, 25), Color.Black); spriteBatch.DrawString(defaultFont, "## Main Menu ##", new Vector2(graphics.PreferredBackBufferWidth / 2 - 100, 50), Color.Black); spriteBatch.DrawString(defaultFont, "###############", new Vector2(graphics.PreferredBackBufferWidth / 2 - 100, 75), Color.Black); foreach (MenuItem mi in menuManager.GetActiveMenu().GetItems()) { if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_PASSIVE) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X, mi.GetLocation().Y), Color.Black); } if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_ACTIVE) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X - 50, mi.GetLocation().Y), Color.Black); } if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_PRESSED) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X - 50, mi.GetLocation().Y), Color.Black); } } spriteBatch.End(); break; } case GAMESTATE.GAMESTATE_PAUSE_MENU: { spriteBatch.Begin(); foreach (MenuItem mi in menuManager.GetActiveMenu().GetItems()) { if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_PASSIVE) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X, mi.GetLocation().Y), Color.Black); } if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_ACTIVE) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X - 50, mi.GetLocation().Y), Color.Black); } if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_PRESSED) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X - 50, mi.GetLocation().Y), Color.Black); } } spriteBatch.End(); break; } case GAMESTATE.GAMESTATE_GAME_RUNNING: { spriteBatch.Begin(); spriteBatch.Draw(gameTextures_levelTextures[0], gameRect, Color.White); int[] fieldArray = gameField.GetFieldArray(); Rectangle blockRect = new Rectangle(0, 0, 0, 0) { Width = (gameRect.Width / (Config.GetFieldWidth() - 2)), Height = (gameRect.Height / (Config.GetFieldHeight() - 5)) }; for (int xxx = 0; xxx < Config.GetFieldWidth() - 2; xxx++) { for (int yyy = 0; yyy < Config.GetFieldHeight() - 5; yyy++) { int currentFieldValue = fieldArray[(yyy + 2) * Config.GetFieldWidth() + xxx + 1]; if (currentFieldValue != 0) { blockRect.X = gameRect.X + blockRect.Width * xxx; blockRect.Y = gameRect.Y + blockRect.Height * yyy; switch (currentFieldValue) { case 1: { spriteBatch.Draw(gameTextures_Cyan, blockRect, Color.White); break; } case 2: { spriteBatch.Draw(gameTextures_Yellow, blockRect, Color.White); break; } case 3: { spriteBatch.Draw(gameTextures_Magenta, blockRect, Color.White); break; } case 4: { spriteBatch.Draw(gameTextures_Green, blockRect, Color.White); break; } case 5: { spriteBatch.Draw(gameTextures_Red, blockRect, Color.White); break; } case 6: { spriteBatch.Draw(gameTextures_Blue, blockRect, Color.White); break; } case 7: { spriteBatch.Draw(gameTextures_Orange, blockRect, Color.White); break; } default: break; } //ghost Block drawing if (currentFieldValue < 0) { spriteBatch.Draw(gameTextures_Ghost, blockRect, Color.White); } } } } spriteBatch.DrawString(defaultFont, gameField.ToString(), new Vector2(10, 10), Color.Black); spriteBatch.DrawString(defaultFont, "difficulty " + difficultyLevel + " tick \nspeed (millis):\n " + difficultyTickSpeedMillis[difficultyLevel], new Vector2(700, 10), Color.Black); spriteBatch.DrawString(defaultFont, "ghost block \n location:\n " + gameField.GetGhostBlock().GetLocation(), new Vector2(700, 200), Color.Black); spriteBatch.DrawString(defaultFont, "GAME OVER?:\n " + gameField.GetGameOver(), new Vector2(700, 400), Color.Black); spriteBatch.End(); break; } case GAMESTATE.GAMESTATE_GAMEOVER: { spriteBatch.Begin(); spriteBatch.DrawString(defaultFont, "###############", new Vector2(graphics.PreferredBackBufferWidth / 2 - 100, 25), Color.Black); spriteBatch.DrawString(defaultFont, "## Game Over! ##", new Vector2(graphics.PreferredBackBufferWidth / 2 - 100, 50), Color.Black); spriteBatch.DrawString(defaultFont, "###############", new Vector2(graphics.PreferredBackBufferWidth / 2 - 100, 75), Color.Black); foreach (MenuItem mi in menuManager.GetActiveMenu().GetItems()) { if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_PASSIVE) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X, mi.GetLocation().Y), Color.Black); } if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_ACTIVE) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X - 50, mi.GetLocation().Y), Color.Black); } if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_PRESSED) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X - 50, mi.GetLocation().Y), Color.Black); } } spriteBatch.End(); break; } case GAMESTATE.GAMESTATE_SCORE_BOARD: { spriteBatch.Begin(); spriteBatch.DrawString(defaultFont, "###############", new Vector2(graphics.PreferredBackBufferWidth / 2 - 100, 25), Color.Black); spriteBatch.DrawString(defaultFont, "## Scoreboard! ##", new Vector2(graphics.PreferredBackBufferWidth / 2 - 100, 50), Color.Black); spriteBatch.DrawString(defaultFont, "###############", new Vector2(graphics.PreferredBackBufferWidth / 2 - 100, 75), Color.Black); foreach (MenuItem mi in menuManager.GetActiveMenu().GetItems()) { if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_PASSIVE) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X, mi.GetLocation().Y), Color.Black); } if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_ACTIVE) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X - 50, mi.GetLocation().Y), Color.Black); } if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_PRESSED) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X - 50, mi.GetLocation().Y), Color.Black); } } spriteBatch.End(); break; } case GAMESTATE.GAMESTATE_OPTIONS_MENU: { spriteBatch.Begin(); spriteBatch.DrawString(defaultFont, "###############", new Vector2(graphics.PreferredBackBufferWidth / 2 - 100, 25), Color.Black); spriteBatch.DrawString(defaultFont, "### Options ###", new Vector2(graphics.PreferredBackBufferWidth / 2 - 100, 50), Color.Black); spriteBatch.DrawString(defaultFont, "###############", new Vector2(graphics.PreferredBackBufferWidth / 2 - 100, 75), Color.Black); foreach (MenuItem mi in menuManager.GetActiveMenu().GetItems()) { if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_PASSIVE) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X, mi.GetLocation().Y), Color.Black); } if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_ACTIVE) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X - 50, mi.GetLocation().Y), Color.Black); } if (mi.GetState() == MenuItem.MENUITEM_STATE.MENUITEM_STATE_PRESSED) { spriteBatch.DrawString(mi.GetFont(), mi.GetText(), new Vector2(mi.GetLocation().X - 50, mi.GetLocation().Y), Color.Black); } } spriteBatch.End(); break; } } base.Draw(gameTime); }