-using System;\r
+#define SINGLE_TEST\r
+\r
+using System;\r
using System.Collections.Generic;\r
using System.Linq;\r
using System.Text;\r
{\r
List<Projectile> mProjectiles = new List<Projectile>();\r
List<IPlayer> mCharacters = new List<IPlayer>();\r
+ Texture2D everything;\r
Map mMap;\r
int currentCenterX = 5;\r
int currentCenterY = 5;\r
+#if SINGLE_TEST\r
+ List<Keys> mLastPressedKeys = new List<Keys>();\r
+#endif\r
public Display()\r
{\r
/*\r
/// </summary>\r
public void LoadContent(ContentManager contentManager)\r
{\r
- Texture2D everything = contentManager.Load<Texture2D>("cs");\r
+ everything = contentManager.Load<Texture2D>("cs");\r
mMap = contentManager.Load<Map>("Maps/stable");\r
Map.DefaultTile = contentManager.Load<Texture2D>("default");\r
mMap.CenterCell = new Vector2(currentCenterX,currentCenterY);\r
//Debugging... Spawn eight projectiles.\r
//Diagonals\r
+ \r
mProjectiles.Add(new Projectile(mMap, everything, new Vector2(5,5), 10, 10, 300, 300));\r
mProjectiles.Add(new Projectile(mMap, everything, new Vector2(-5, 5), 10, 10, 300, 300));\r
mProjectiles.Add(new Projectile(mMap, everything, new Vector2(5, -5), 10, 10, 300, 300));\r
mProjectiles.Add(new Projectile(mMap, everything, new Vector2(-5, 0), 10, 10, 300, 300));\r
mProjectiles.Add(new Projectile(mMap, everything, new Vector2(5, 0), 10, 10, 300, 300));\r
mProjectiles.Add(new Projectile(mMap, everything, new Vector2(0, -5), 10, 10, 300, 300));\r
+ \r
\r
\r
// TODO: use this.Content to load your game content here\r
/// <param name="gameTime">Provides a snapshot of timing values.</param>\r
public void Update(TimeSpan timespan)\r
{\r
+ //INPUT - testing input... has to be through network later\r
+#if SINGLE_TEST\r
+ KeyboardState keyState = Keyboard.GetState();\r
+\r
+ List<Keys> pressedKeys = new List<Keys>();\r
+ List<Keys> releasedKeys = new List<Keys>();\r
+\r
+ Keys[] pressedKeysArray = keyState.GetPressedKeys();\r
+ foreach (Keys k in pressedKeysArray)\r
+ {\r
+ if (!mLastPressedKeys.Contains(k)) pressedKeys.Add(k);\r
+ else mLastPressedKeys.Remove(k);\r
+ }\r
+\r
+ releasedKeys = mLastPressedKeys;\r
+ mLastPressedKeys = new List<Keys>(pressedKeysArray);\r
+ //Just apply input for the first player\r
+ mCharacters[0].MovePlayer(pressedKeys);\r
+ if (pressedKeys.Contains(Keys.Enter) && !releasedKeys.Contains(Keys.Enter))\r
+ {\r
+ mProjectiles.Add(new Projectile(mMap, everything, new Vector2(-5,0), mCharacters[0].GridX +1, mCharacters[0].GridY+1, (int)mCharacters[0].GridX*(int)Map.PixelsToUnitSquares,(int)mCharacters[0].GridY*(int)Map.PixelsToUnitSquares));\r
+ }\r
+ mMap.CenterCell = new Vector2(mCharacters[0].GridX, mCharacters[0].GridY);\r
+#endif\r
\r
for (int i = 0; i < mProjectiles.Count; i++ )\r
{\r
//Check for collisons\r
for (int j = 0; j < mCharacters.Count; j++) \r
{\r
+ \r
+ \r
for (int i = 0; i < mProjectiles.Count; i++)\r
{\r
if (mProjectiles[i].GridX == mCharacters[j].GridX && mProjectiles[i].GridY == mCharacters[j].GridY)\r
{\r
- //Debug - not sure if you can remove while doing for each\r
- //Alternative - while loop, and decrement projectile counter if projectile is removed.\r
- mProjectiles.Remove(mProjectiles[i]);\r
mCharacters[j].causeDamageTo(mProjectiles[i].Damage);\r
+ Console.WriteLine(mCharacters[j].Health);\r
+ mProjectiles.RemoveAt(i);\r
+ i--;\r
}\r
}\r
}\r