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
29 Texture2D projectileModel;
42 public Human(Map _theMap, String Name, Texture2D model, Texture2D projectile, Display mDisplay)
46 theDisplay = mDisplay;
48 movementSpeed = 12; // randomly set now
55 projectileModel = projectile;
56 movementCoolDown = movementSpeed;
60 public void LoadContent(ContentManager contentManager)
62 charModel = contentManager.Load<Texture2D>("deselectBox"); //change to charModel when designed
63 projectileModel = contentManager.Load<Texture2D>("emptySelectBox"); //change to a projectile model later
67 public void UnloadContent()
72 public long Update(GameTime gameTime, NetworkManager networkGame)
78 public long Draw(SpriteBatch spriteBatch)
80 spriteBatch.Draw(charModel, theMap.GetRectangleFromCoordinates(gridX, gridY), Color.White);
84 public int GridX { get { return gridX; } set { gridX = value; } }
85 public int GridY { get { return gridY; } set { gridY = value; } }
86 public int Health { get { return health; } }
87 public int Score { get { return score; } }
88 public bool alive { get { return health > 0; } }
90 public void causeDamageTo(int amount)
96 /// Moves the current player being controlled based on a given set of key presses.
97 /// The player can only move one grid space per movePlayer call. Thus this method
98 /// is made to be called ever update. The player will only move if the grid space
99 /// that is being moved to is an open space.
101 /// <param name="keysPressed">A general list of keys that are pressed. Other keys can be included but only direction keys will be used</param>
102 public void MovePlayer(List<Keys> keysPressed)
104 if(movementCoolDown > 0)
106 else if (movementCoolDown == 0)
109 keysPressed.Contains<Keys>(Keys.Left);
110 if (keysPressed.Contains<Keys>(Keys.Up) && keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY - 1))
114 movementCoolDown = movementSpeed;
117 else if (keysPressed.Contains<Keys>(Keys.Up) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY - 1))
121 movementCoolDown = movementSpeed;
124 else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY + 1))
128 movementCoolDown = movementSpeed;
131 else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY + 1))
135 movementCoolDown = movementSpeed;
138 else if (keysPressed.Contains<Keys>(Keys.Up) && theMap.IsCellOpen(gridX, gridY - 1))
142 movementCoolDown = movementSpeed;
145 else if (keysPressed.Contains<Keys>(Keys.Down) && theMap.IsCellOpen(gridX, gridY + 1))
149 movementCoolDown = movementSpeed;
152 else if (keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY))
156 movementCoolDown = movementSpeed;
159 else if (keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY))
163 movementCoolDown = movementSpeed;
166 if (keysPressed.Contains<Keys>(Keys.Space))
168 //TODO spawn projectile... needs to be added to display though
169 if (state == State.up)
171 theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(0, -projectileSpeed), GridX, GridY));
173 if (state == State.down)
175 theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(0, projectileSpeed), GridX, GridY + 1));
177 if (state == State.right)
179 theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(projectileSpeed, 0), GridX +1, GridY));
181 if (state == State.left)
183 theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(-projectileSpeed, 0), GridX, GridY));
189 public void powerUp(int amount)
194 public void Spawn(Vector2 spawn)
196 gridX = (int)spawn.X;
197 gridY = (int)spawn.Y;