public void Draw(bool drawBackground)
{
int windowWidth = Game.WindowWidth;
int windowHeight = Game.WindowHeight;
if (drawBackground || State == MenuStates.LoadLevel || State == MenuStates.Info)
{
if (Background == null)
Game.graphics.GraphicsDevice.Clear(Color.Black);
else
{
Game.spriteBatch.Begin();
Game.spriteBatch.Draw(Background, new Rectangle(0, 0, windowWidth, windowHeight), Color.White);
Game.spriteBatch.End();
}
}
if (State == MenuStates.Menu)
{
Game.spriteBatch.Begin();
Game.spriteBatch.Draw(TitleTexture, new Rectangle(windowWidth/4, 0, windowWidth/2, windowHeight/10), Color.White);
Game.spriteBatch.Draw(EscTexture, new Rectangle(0, 0, windowWidth, windowHeight/12), Color.White);
if (Paused)
Game.spriteBatch.Draw(MenuItemTextures[(int)MenuItems.Resume], new Rectangle(0, windowHeight / 6, windowWidth, windowHeight / 12), Color.White);
Game.spriteBatch.Draw(MenuItemTextures[(int)MenuItems.NewGame], new Rectangle(0, windowHeight / 6 + windowHeight / 6 * 1, windowWidth, windowHeight / 12), Color.White);
Game.spriteBatch.Draw(MenuItemTextures[(int)MenuItems.LoadLevel], new Rectangle(0, windowHeight / 6 + windowHeight / 6 * 2,windowWidth, windowHeight / 12), Color.White);
Game.spriteBatch.Draw(MenuItemTextures[(int)MenuItems.Info], new Rectangle(0, windowHeight / 6 + windowHeight / 6 * 3, windowWidth, windowHeight / 12), Color.White);
Game.spriteBatch.Draw(CursorTexture[CursorFrame], new Rectangle(windowWidth / 20, windowHeight / 6 * (int)SelectedItem + windowHeight / 6, windowWidth / 10, windowWidth / 20), Color.White);
Game.spriteBatch.End();
}
else if (State == MenuStates.LoadLevel)
{
Game.spriteBatch.Begin();
Game.spriteBatch.Draw(EscTexture, new Rectangle(0, 0, windowWidth, windowHeight / 12), Color.White);
Game.spriteBatch.Draw(MenuItemTextures[(int)MenuItems.LoadLevel], new Rectangle((int)((float)windowWidth / 2f - (float)windowWidth / 2.5f / 2f), windowHeight / 8, (int)((float)windowWidth / 2.5f), windowHeight / 12), Color.White);
int rows = 9;
for (int i = 0; i < LevelConfigs.Count; i++)
{
int x = i / rows;
int y = i % rows;
Game.spriteBatch.DrawString(LevelFont, LevelConfigs[i].LevelName, new Vector2(windowWidth / 10 + x * windowWidth / 3 + 1, (float)windowHeight / 4f + (float)windowHeight / 12f * y + 1), new Color(128, 128, 128, 128),
0, new Vector2(0f, 0f), 1.0f, SpriteEffects.None, 0.5f);
Game.spriteBatch.DrawString(LevelFont, LevelConfigs[i].LevelName, new Vector2(windowWidth / 10 + x * windowWidth / 3, (float)windowHeight / 4f + (float)windowHeight / 12f * y), Color.Red,
0, new Vector2(0f, 0f), 1.0f, SpriteEffects.None, 0.5f);
}
int cx = SelectedLevel / rows;
int cy = SelectedLevel % rows;
Game.spriteBatch.Draw(CursorTexture[CursorFrame], new Rectangle(windowWidth / 30 + cx * windowWidth / 3, (int)(windowHeight / 4.5f) + windowHeight / 12 * cy, windowWidth / 15, windowWidth / 30), Color.White);
Game.spriteBatch.Draw(TitleTexture, new Rectangle(windowWidth / 4, 0, windowWidth / 2, windowHeight / 10), Color.White);
Game.spriteBatch.End();
}
else if (State == MenuStates.Info)
{
Game.spriteBatch.Begin();
Game.spriteBatch.Draw(EscTexture, new Rectangle(0, 0, windowWidth, windowHeight / 12), Color.White);
Game.spriteBatch.Draw(MenuItemTextures[(int)MenuItems.Info], new Rectangle((int)(float)(windowWidth/4.8f), windowHeight / 8, windowWidth, windowHeight / 12), Color.White);
string infoText = "";
if (Input.GamePadConnected)
{
infoText = "- Use the left stick to move the tornado\n"
+ "- Spin the right stick to make the tornado spin faster and do more damage\n"
+ "- Suck up as much as you can to become more powerful\n"
+ "- Start with small objects and work your way up to bigger ones\n"
+ "- Make sure to spin fast when you try to get bigger items\n"
+ "- Suck up the boss building(s) to beat the level!\n\n"
+ "Object mass in increasing order: rock, recycling bin,\n"
+ "bush, man, cow, car, truck, tree, house, skyscraper, \n"
+ "boss, UFO, mountains\n";
}
else
{
infoText = "- Use W,A,S,D or the arrow keys to move the tornado\n"
+ "- Spin your mouse to make the tornado spin faster and do more damage\n"
+ "- Suck up as much as you can to become more powerful\n"
+ "- Start with small objects and work your way up to bigger ones\n"
+ "- Make sure to spin fast when you try to get bigger items\n"
+ "- Suck up the boss building(s) to beat the level!\n"
+ "Object mass in increasing order: rock, recycling bin,\n"
+ "bush, man, cow, car, truck, tree, house, skyscraper, \n"
+ "boss, UFO, mountains\n";
}
Game.spriteBatch.DrawString(InfoFont, infoText, new Vector2(windowWidth / 10 + 2, windowHeight / 4 + 2), new Color(128, 128, 128, 128),
0, new Vector2(0f, 0f), 1.0f, SpriteEffects.None, 0.5f);
Game.spriteBatch.DrawString(InfoFont, infoText, new Vector2(windowWidth / 10, windowHeight / 4), Color.Red,
0, new Vector2(0f, 0f), 1.0f, SpriteEffects.None, 0.5f);
Game.spriteBatch.Draw(TitleTexture, new Rectangle(windowWidth / 4, 0, windowWidth / 2, windowHeight / 10), Color.White);
Game.spriteBatch.End();
}
// advanced tornado animation
if (CursorTimeSinceLastFrame >= 100f)
{
CursorTimeSinceLastFrame = 0.0f;
CursorFrame++;
if (CursorFrame >= CursorTexture.Length)
CursorFrame = 0;
}
}