2 using System.Collections.Generic;
5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Content;
7 using Microsoft.Xna.Framework.Graphics;
8 using Microsoft.Xna.Framework.Input;
12 public class Human : IPlayer
21 const int moveCoolDown = 12;
22 const int shootCoolDown = 10;
31 Texture2D projectileModel;
43 int projectileCoolDown;
45 public Human(Map _theMap, String Name, Texture2D model, Texture2D projectile, Display mDisplay)
49 theDisplay = mDisplay;
51 movementSpeed = 12; // randomly set now
58 projectileModel = projectile;
63 public void LoadContent(ContentManager contentManager)
65 charModel = contentManager.Load<Texture2D>("deselectBox"); //change to charModel when designed
66 projectileModel = contentManager.Load<Texture2D>("emptySelectBox"); //change to a projectile model later
70 public void UnloadContent()
75 public long Update(GameTime gameTime, NetworkManager networkGame)
81 public long Draw(SpriteBatch spriteBatch)
83 spriteBatch.Draw(charModel, theMap.GetRectangleFromCoordinates(gridX, gridY), Color.White);
87 public int GridX { get { return gridX; } set { gridX = value; } }
88 public int GridY { get { return gridY; } set { gridY = value; } }
89 public int Health { get { return health; } }
90 public int Score { get { return score; } }
91 public bool alive { get { return health > 0; } }
93 public void causeDamageTo(int amount)
99 /// Moves the current player being controlled based on a given set of key presses.
100 /// The player can only move one grid space per movePlayer call. Thus this method
101 /// is made to be called ever update. The player will only move if the grid space
102 /// that is being moved to is an open space.
104 /// <param name="keysPressed">A general list of keys that are pressed. Other keys can be included but only direction keys will be used</param>
105 public void MovePlayer(List<Keys> keysPressed)
107 if(movementCoolDown > 0)
109 else if (movementCoolDown == 0)
112 keysPressed.Contains<Keys>(Keys.Left);
113 if (keysPressed.Contains<Keys>(Keys.Up) && keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY - 1))
117 movementCoolDown = moveCoolDown;
120 else if (keysPressed.Contains<Keys>(Keys.Up) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY - 1))
124 movementCoolDown = moveCoolDown;
127 else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY + 1))
131 movementCoolDown = moveCoolDown;
134 else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY + 1))
138 movementCoolDown = moveCoolDown;
141 else if (keysPressed.Contains<Keys>(Keys.Up) && theMap.IsCellOpen(gridX, gridY - 1))
145 movementCoolDown = moveCoolDown;
148 else if (keysPressed.Contains<Keys>(Keys.Down) && theMap.IsCellOpen(gridX, gridY + 1))
152 movementCoolDown = moveCoolDown;
155 else if (keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY))
159 movementCoolDown = moveCoolDown;
162 else if (keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY))
166 movementCoolDown = moveCoolDown;
169 if (projectileCoolDown > 0)
170 projectileCoolDown--;
171 else if (projectileCoolDown == 0)
173 if (keysPressed.Contains<Keys>(Keys.Space))
175 //TODO spawn projectile... needs to be added to display though
176 if (state == State.up)
178 projectileCoolDown = shootCoolDown;
179 theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(0, -projectileSpeed), GridX, GridY - 1));
181 if (state == State.down)
183 projectileCoolDown = shootCoolDown;
184 theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(0, projectileSpeed), GridX, GridY + 1));
186 if (state == State.right)
188 projectileCoolDown = shootCoolDown;
189 theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(projectileSpeed, 0), GridX + 1, GridY));
191 if (state == State.left)
193 projectileCoolDown = shootCoolDown;
194 theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(-projectileSpeed, 0), GridX - 1, GridY));
201 public void powerUp(int amount)
206 public void Spawn(Vector2 spawn)
208 gridX = (int)spawn.X;
209 gridY = (int)spawn.Y;