//List<IPlayer> mCharacters = new List<IPlayer>();\r
IPlayer[] mCharacters = new IPlayer[4];\r
Texture2D everything;\r
+ Texture2D projectile1;\r
Map mMap;\r
int currentCenterX = 5;\r
int currentCenterY = 5;\r
public void LoadContent(ContentManager contentManager)\r
{\r
everything = contentManager.Load<Texture2D>("cs");\r
+ projectile1 = contentManager.Load<Texture2D>("projectile");\r
mMap = contentManager.Load<Map>("Maps/stable");\r
Map.DefaultTile = contentManager.Load<Texture2D>("default");\r
mMap.CenterCell = new Vector2(currentCenterX,currentCenterY);\r
mMap.CenterCell = new Vector2(mCharacters[0].GridX, mCharacters[0].GridY);\r
#endif\r
\r
- for (int i = 0; i < 4; i++)\r
- {\r
- if (mCharacters[i] == null)\r
- {\r
- if(state.keysDown[i].Contains(Keys.Enter))\r
- {\r
- mCharacters[i] = (new Human(mMap, "", everything, everything, this));\r
- mCharacters[i].GridX = mMap.GetStartingPositionForPlayer(i+1).X;\r
- mCharacters[i].GridY = mMap.GetStartingPositionForPlayer(i+1).Y;\r
- }\r
- }\r
- else\r
- {\r
- mMap.CenterCell = new Vector2(mCharacters[0].GridX, mCharacters[0].GridY);\r
- mCharacters[i].MovePlayer(state.keysDown[i]);\r
- }\r
- }\r
+ \r
for (int i = 0; i < mProjectiles.Count; i++ )\r
{\r
mProjectiles[i].Update(timespan);\r
}\r
}\r
}\r
+ for (int i = 0; i < 4; i++)\r
+ {\r
+ //If player has not selected a player yet let them select one.\r
+ if (mCharacters[i] == null)\r
+ {\r
+ if (state.keysDown[i].Contains(Keys.Enter))\r
+ {\r
+ mCharacters[i] = (new Human(mMap, "", everything, projectile1, this));\r
+ mCharacters[i].GridX = mMap.GetStartingPositionForPlayer(i + 1).X;\r
+ mCharacters[i].GridY = mMap.GetStartingPositionForPlayer(i + 1).Y;\r
+ }\r
+ }\r
+ else\r
+ {\r
+\r
+ mCharacters[i].MovePlayer(state.keysDown[i]);\r
+ mMap.CenterCell = new Vector2(mCharacters[0].GridX, mCharacters[0].GridY);\r
+ }\r
+ }\r
}\r
\r
/// <summary>\r
up,\r
down\r
};\r
+ const int moveCoolDown = 12;\r
+ const int shootCoolDown = 10;\r
//Member Variables\r
State state;\r
String CharName;\r
int movementCoolDown;\r
Display theDisplay;\r
int projectileSpeed;\r
+ int projectileCoolDown;\r
\r
public Human(Map _theMap, String Name, Texture2D model, Texture2D projectile, Display mDisplay)\r
{\r
state = State.up;\r
charModel = model;\r
projectileModel = projectile;\r
- movementCoolDown = movementSpeed;\r
projectileSpeed = 30;\r
+ \r
}\r
\r
public void LoadContent(ContentManager contentManager)\r
{\r
gridX -= 1;\r
gridY -= 1;\r
- movementCoolDown = movementSpeed;\r
+ movementCoolDown = moveCoolDown;\r
}\r
// move upright\r
else if (keysPressed.Contains<Keys>(Keys.Up) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY - 1))\r
{\r
gridX += 1;\r
gridY -= 1;\r
- movementCoolDown = movementSpeed;\r
+ movementCoolDown = moveCoolDown;\r
}\r
// move downleft\r
else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY + 1))\r
{\r
gridX -= 1;\r
gridY += 1;\r
- movementCoolDown = movementSpeed;\r
+ movementCoolDown = moveCoolDown;\r
}\r
// move downright\r
else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY + 1))\r
{\r
gridX += 1;\r
gridY += 1;\r
- movementCoolDown = movementSpeed;\r
+ movementCoolDown = moveCoolDown;\r
}\r
// move up\r
else if (keysPressed.Contains<Keys>(Keys.Up) && theMap.IsCellOpen(gridX, gridY - 1))\r
{\r
state = State.up;\r
gridY -= 1;\r
- movementCoolDown = movementSpeed;\r
+ movementCoolDown = moveCoolDown;\r
}\r
// move down\r
else if (keysPressed.Contains<Keys>(Keys.Down) && theMap.IsCellOpen(gridX, gridY + 1))\r
{\r
state = State.down;\r
gridY += 1;\r
- movementCoolDown = movementSpeed;\r
+ movementCoolDown = moveCoolDown;\r
}\r
// move left\r
else if (keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY))\r
{\r
state = State.left;\r
gridX -= 1;\r
- movementCoolDown = movementSpeed;\r
+ movementCoolDown = moveCoolDown;\r
}\r
// move right\r
else if (keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY))\r
{\r
state = State.right;\r
gridX += 1;\r
- movementCoolDown = movementSpeed;\r
+ movementCoolDown = moveCoolDown;\r
}\r
}\r
- if (keysPressed.Contains<Keys>(Keys.Space))\r
+ if (projectileCoolDown > 0)\r
+ projectileCoolDown--;\r
+ else if (projectileCoolDown == 0)\r
{\r
- //TODO spawn projectile... needs to be added to display though\r
- if (state == State.up)\r
+ if (keysPressed.Contains<Keys>(Keys.Space))\r
{\r
- theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(0, -projectileSpeed), GridX, GridY));\r
- }\r
- if (state == State.down)\r
- {\r
- theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(0, projectileSpeed), GridX, GridY + 1));\r
- }\r
- if (state == State.right)\r
- {\r
- theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(projectileSpeed, 0), GridX +1, GridY));\r
- }\r
- if (state == State.left)\r
- {\r
- theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(-projectileSpeed, 0), GridX, GridY));\r
+ //TODO spawn projectile... needs to be added to display though\r
+ if (state == State.up)\r
+ {\r
+ projectileCoolDown = shootCoolDown;\r
+ theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(0, -projectileSpeed), GridX, GridY - 1));\r
+ }\r
+ if (state == State.down)\r
+ {\r
+ projectileCoolDown = shootCoolDown;\r
+ theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(0, projectileSpeed), GridX, GridY + 1));\r
+ }\r
+ if (state == State.right)\r
+ {\r
+ projectileCoolDown = shootCoolDown;\r
+ theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(projectileSpeed, 0), GridX + 1, GridY));\r
+ }\r
+ if (state == State.left)\r
+ {\r
+ projectileCoolDown = shootCoolDown;\r
+ theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(-projectileSpeed, 0), GridX - 1, GridY));\r
+ }\r
}\r
}\r
}\r
//Console.WriteLine(gridX + " " + gridY);\r
//Console.WriteLine(theMap.GetRectangleFromCoordinates(new Vector2(gridX, gridY)));\r
Rectangle position = theMap.GetRectangleFromCoordinates(new Vector2(gridX, gridY));\r
- spriteBatch.Draw(projectileModel, position, Color.White);\r
- //Rectangle position2 = new Rectangle(pixelX-30, pixelY-30, 60, 60);\r
- //spriteBatch.Draw(projectileModel, position2, Color.White);\r
+ //spriteBatch.Draw(projectileModel, position, Color.White);\r
+ Rectangle position2 = new Rectangle((int)(pixelX), (int)(pixelY), (int)Map.PixelsToUnitSquares, (int)Map.PixelsToUnitSquares);\r
+ Rectangle position3 = theMap.GetRectangleFromCoordinates(new Vector2(pixelX / Map.PixelsToUnitSquares, pixelY / Map.PixelsToUnitSquares));\r
+ spriteBatch.Draw(projectileModel, position3, Color.White);\r
}\r
\r
/// <summary>\r