bool playerChosen = false;\r
List<Projectile> mProjectiles = new List<Projectile>();\r
//List<IPlayer> mCharacters = new List<IPlayer>();\r
- IPlayer[] mCharacters = new IPlayer[4];\r
+ //IPlayer[] mCharacters = new IPlayer[4];\r
Texture2D everything;\r
Texture2D projectile1;\r
Game mGame;\r
\r
}\r
//Check for collisons\r
- for (int j = 0; j < mCharacters.Length; j++) \r
+ for (int j = 0; j < mGame.State.mCharacters.Length; j++) \r
{\r
\r
- if(mCharacters[j] != null)\r
+ if(mGame.State.mCharacters[j] != null)\r
for (int i = 0; i < mProjectiles.Count; i++)\r
{\r
- if (mProjectiles[i].Coordinates.X == mCharacters[j].Coordinates.X && mProjectiles[i].Coordinates.Y == mCharacters[j].Coordinates.Y)\r
+ if (mProjectiles[i].Coordinates.X == mGame.State.mCharacters[j].Coordinates.X && mProjectiles[i].Coordinates.Y == mGame.State.mCharacters[j].Coordinates.Y)\r
{\r
- mCharacters[j].causeDamageTo(mProjectiles[i].Damage);\r
- Console.WriteLine(mCharacters[j].Health);\r
+ mGame.State.mCharacters[j].causeDamageTo(mProjectiles[i].Damage);\r
+ Console.WriteLine(mGame.State.mCharacters[j].Health);\r
mProjectiles.RemoveAt(i);\r
i--;\r
}\r
for (int i = 0; i < mGame.State.NumberOfPlayers; i++)\r
{\r
//If player has not selected a player yet let them select one.\r
- if (mCharacters[i] == null)\r
+ if (mGame.State.mCharacters[i] == null)\r
{\r
if (mGame.State.GetKeysDown(i).Contains(Keys.Enter))\r
{\r
- mCharacters[i] = new Human(mGame, "", everything, projectile1, this, mGame.State.Map.GetStartingPositionForPlayer(i + 1));\r
+ //mCharacters[i] = new Human(mGame, "", everything, projectile1, this, mGame.State.Map.GetStartingPositionForPlayer(i + 1));\r
}\r
}\r
//Regular player input updates\r
else\r
{\r
\r
- mCharacters[i].MovePlayer(timespan, mGame.State.GetKeysDown(i));\r
+ mGame.State.mCharacters[i].MovePlayer(timespan, mGame.State.GetKeysDown(i));\r
\r
}\r
}\r
- if (mCharacters[thisPlayer] != null)\r
+ if (mGame.State.mCharacters[thisPlayer] != null)\r
{\r
- mGame.State.Map.CenterCell = mCharacters[thisPlayer].Position;\r
+ mGame.State.Map.CenterCell = mGame.State.mCharacters[thisPlayer].Position;\r
}\r
//Handle wall collisions of projectiles again...\r
for (int i = 0; i < mProjectiles.Count; i++)\r
for(int i = 0; i < mGame.State.NumberOfPlayers; i++)//IPlayer character in mCharacters)\r
{\r
\r
- if (mCharacters[i] != null)\r
+ if (mGame.State.mCharacters[i] != null)\r
{\r
- mCharacters[i].Draw(spriteBatch);\r
+ mGame.State.mCharacters[i].Draw(spriteBatch);\r
\r
}\r
}\r
\r
public Map Map;\r
public List<IEntity> Entities = new List<IEntity>();\r
+ public IPlayer[] mCharacters = new IPlayer[4];\r
+ public Display mDisplay;\r
\r
#endregion\r
\r
\r
public Game()\r
{\r
- mDisplay = new Display(this);\r
+ \r
}\r
public void LoadContent(ContentManager contentManager)\r
{\r
mContentManager = contentManager;\r
- mDisplay.LoadContent(contentManager);\r
+ \r
}\r
\r
public void UnloadContent()\r
\r
State = new GameState(numPlayers);\r
mInputs = new NextInputs(numPlayers);\r
+ State.mDisplay = new Display(this);\r
+ State.mDisplay.LoadContent(mContentManager);\r
\r
State.Map = mContentManager.Load<Map>("Maps/stable");\r
State.Map.Game = this;\r
public long Update(TimeSpan elapsedTime)\r
{\r
State.AdvanceFrame(mInputs, elapsedTime.Milliseconds); // Apply the inputs, advance game state.\r
- mDisplay.Update(elapsedTime, State, mThisPlayerID);\r
+ State.mDisplay.Update(elapsedTime, State, mThisPlayerID);\r
State.Entities.ForEach(delegate(IEntity e) { e.Update(elapsedTime); });\r
mInputs = new NextInputs(State.NumberOfPlayers); // Start with inputs cleared on the next frame.\r
//mDisplay.Update(elapsedTime);\r
\r
public long Draw(SpriteBatch spriteBatch)\r
{\r
- mDisplay.Draw(spriteBatch);\r
+ bool allCharactersSelected = true;\r
+ for (int i = 0; i < State.NumberOfPlayers; i++)\r
+ {\r
+ //If player has not selected a player yet let them select one.\r
+ if (State.mCharacters[i] == null)\r
+ {\r
+ allCharactersSelected = false;\r
+ if (State.GetKeysDown(i).Contains(Keys.Enter))\r
+ {\r
+ State.mCharacters[i] = new Human(this, "", State.Map.GetStartingPositionForPlayer(i + 1));\r
+ State.mCharacters[i].LoadContent(mContentManager);\r
+ }\r
+ }\r
+ }\r
+ if (allCharactersSelected)\r
+ {\r
+ State.mDisplay.Draw(spriteBatch);\r
+ }\r
return CurrentFrameNumber;\r
}\r
\r
\r
MovementManager mMotion;\r
bool visible;\r
- Display theDisplay;\r
\r
//Used to draw projectiles\r
int projectileSpeed;\r
int projectileCoolDown;\r
\r
\r
- public Human(Game theGame, String Name, Texture2D model, Texture2D projectile, Display mDisplay, Point position)\r
+ public Human(Game theGame, String Name, Point position)\r
{\r
game = theGame;\r
CharName = Name;\r
- theDisplay = mDisplay;\r
health = 100;\r
score = 0;\r
visible = false;\r
- charModel = model;\r
- projectileModel = projectile;\r
projectileSpeed = 8;\r
\r
// Speed is the number of grid cells you can move through per second.\r
toShoot.Normalize();\r
toShoot *= projectileSpeed;\r
projectileCoolDown = shootCoolDown;\r
- theDisplay.AddProjectiles(new Projectile(game.State.Map, projectileModel,\r
+ game.State.mDisplay.AddProjectiles(new Projectile(game.State.Map, projectileModel,\r
toShoot, new Point(startX, startY)));\r
\r
\r