public bool checkWinCondition() { bool ret = false; if (currentLevel >= 0 && currentLevel <= 4) { ret = (characterManager.getEggNum() == 0); } else if (currentLevel == 5) { ret = (characterManager.getEnemyNum() == 0); } return(ret); }
public void drawHud() { spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState, Matrix.Identity); spriteBatch.GraphicsDevice.SamplerStates[0].MagFilter = TextureFilter.Point; spriteBatch.GraphicsDevice.SamplerStates[0].MinFilter = TextureFilter.Point; spriteBatch.GraphicsDevice.SamplerStates[0].MipFilter = TextureFilter.Point; Vector2 upPos = new Vector2(10, 10); for (int i = 0; i < player.getHP() / 10; i++) { spriteBatch.Draw(HPBoxSprite, upPos, Color.White); upPos.X += 10; } upPos.Y += 10; upPos.X = 0; Color playerC = Color.White; if (player.getBombCooldown() > 0) { playerC = Color.Black; } spriteBatch.Draw(playerSprite, upPos, playerC); upPos.X += playerSprite.Width; string lives = " x" + player.getLives(); //spriteBatch.DrawString(font, health, new Vector2(0, 0), Color.Yellow); if (player.getLives() >= 0) { spriteBatch.DrawString(font, lives, upPos, Color.Yellow); } float eggSize = hollowEggSprite.Width + 5; upPos = new Vector2(graphics.GraphicsDevice.Viewport.Width - eggSize, graphics.GraphicsDevice.Viewport.Height - eggSize); for (int i = 0; i < characterManager.getEggNum(); i++) { spriteBatch.Draw(hollowEggSprite, upPos, Color.White); upPos.X -= eggSize; } for (int i = 0; i < player.getEggs(); i++) { spriteBatch.Draw(eggSprite, upPos, Color.White); upPos.X -= eggSize; } string pointString = "" + points; upPos = new Vector2(graphics.GraphicsDevice.Viewport.Width - (font.MeasureString(pointString).X) - 10, (font.MeasureString(pointString).Y / 2.0f)); spriteBatch.DrawString(font, pointString, upPos, Color.Yellow); string[] mainText = null; if (levelManager.getCurrentLevel() == 0) { mainText = intro; Vector2 pos; string g = "PLANET EARTH IS BLUE"; float scale = 3.0f; pos.X = (graphics.GraphicsDevice.Viewport.Width / 2.0f) - (font.MeasureString(g).X / 2.0f * scale); pos.Y = 100; spriteBatch.DrawString(font, g, pos, Color.Blue, 0.0f, new Vector2(0.0f, 0.0f), scale, SpriteEffects.None, 0.0f); } else if (levelManager.getCurrentLevel() == 6) { mainText = end; } if (mainText != null) { Vector2 pos = new Vector2(0.0f, 400.0f); for (int i = 0; i < mainText.Length; i++) { Color col = Color.Yellow; if (mainText[i].CompareTo("-alone-") == 0) { col = Color.Blue; } float scale = 1.0f; pos.X = (graphics.GraphicsDevice.Viewport.Width / 2.0f) - (font.MeasureString(mainText[i]).X / 2.0f * scale); spriteBatch.DrawString(font, mainText[i], pos, col, 0.0f, new Vector2(0.0f, 0.0f), scale, SpriteEffects.None, 0.0f); pos.Y += font.MeasureString(mainText[i]).Y * 1.1f; } } if (gameOver) { Vector2 pos; string g = "GAME OVER"; float scale = 2.0f; pos.X = (graphics.GraphicsDevice.Viewport.Width / 2.0f) - (font.MeasureString(g).X / 2.0f * scale); pos.Y = (graphics.GraphicsDevice.Viewport.Height / 2.0f) - (font.MeasureString(g).Y / 2.0f * scale); spriteBatch.DrawString(font, g, pos, Color.Red, 0.0f, new Vector2(0.0f, 0.0f), scale, SpriteEffects.None, 0.0f); } spriteBatch.End(); }