#undef SINGLE_TEST
// Define INGAME_ZOOM to allow zooming in and out with
// the PageUp and PageDown keys.
#define INGAME_ZOOM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace CarFire
{
///
/// This class is responsible for controlling what draws to the screen when the game is running.
///
public class Display
{
Texture2D everything;
Texture2D projectile1;
Game mGame;
GameLogic mGameLogic;
#if SINGLE_TEST
List mLastPressedKeys = new List();
#endif
public Display(Game game)
{
mGame = game;
mGameLogic = new GameLogic(game);
/*
mMap = aMap;
mCharacters = characters;
*/
}
///
/// LoadContent will be called once per game and is the place to load
/// all of your content.
///
public void LoadContent(ContentManager contentManager)
{
everything = contentManager.Load("cs");
projectile1 = contentManager.Load("projectile");
}
///
/// UnloadContent will be called once per game and is the place to unload
/// all content.
///
public void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
///
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
///
/// Provides a snapshot of timing values.
public void Update(TimeSpan timeSpan,int thisPlayer)
{
mGameLogic.Update(timeSpan, thisPlayer);
#if INGAME_ZOOM
if (Keyboard.GetState().IsKeyDown(Keys.PageUp)) mGame.State.Map.Zoom = mGame.State.Map.Zoom + 0.5f;
if (Keyboard.GetState().IsKeyDown(Keys.PageDown)) mGame.State.Map.Zoom = mGame.State.Map.Zoom - 0.5f;
#endif
}
///
/// This is called when the game should draw itself.
///
/// Used to draw with
public void Draw(SpriteBatch spriteBatch)
{
mGame.State.Map.Draw(spriteBatch);
mGame.State.Entities.ForEach(delegate(IEntity e) { e.Draw(spriteBatch); });
foreach(Projectile projectile in mGame.State.mProjectiles)
{
projectile.Draw(spriteBatch);
}
for(int i = 0; i < mGame.State.NumberOfPlayers; i++)//IPlayer character in mCharacters)
{
if (mGame.State.mCharacters[i] != null)
{
mGame.State.mCharacters[i].Draw(spriteBatch);
}
}
}
}
}