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;
40 public Human(Map _theMap, String Name, Texture2D model)
45 movementSpeed = 12; // randomly set now
52 movementCoolDown = movementSpeed;
55 public void LoadContent(ContentManager contentManager)
57 charModel = contentManager.Load<Texture2D>("deselectBox"); //change to charModel when designed
58 projectileModel = contentManager.Load<Texture2D>("emptySelectBox"); //change to a projectile model later
62 public void UnloadContent()
67 public long Update(GameTime gameTime, NetworkManager networkGame)
73 public long Draw(SpriteBatch spriteBatch)
75 spriteBatch.Draw(charModel, theMap.GetRectangleFromCoordinates(gridX, gridY), Color.White);
79 public int GridX { get { return gridX; } set { gridX = value; } }
80 public int GridY { get { return gridY; } set { gridY = value; } }
81 public int Health { get { return health; } }
82 public int Score { get { return score; } }
83 public bool alive { get { return health > 0; } }
85 public void causeDamageTo(int amount)
91 /// Moves the current player being controlled based on a given set of key presses.
92 /// The player can only move one grid space per movePlayer call. Thus this method
93 /// is made to be called ever update. The player will only move if the grid space
94 /// that is being moved to is an open space.
96 /// <param name="keysPressed">A general list of keys that are pressed. Other keys can be included but only direction keys will be used</param>
97 public void MovePlayer(List<Keys> keysPressed)
99 if(movementCoolDown > 0)
101 else if (movementCoolDown == 0)
104 keysPressed.Contains<Keys>(Keys.Left);
105 if (keysPressed.Contains<Keys>(Keys.Up) && keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY - 1))
109 movementCoolDown = movementSpeed;
112 else if (keysPressed.Contains<Keys>(Keys.Up) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY - 1))
116 movementCoolDown = movementSpeed;
119 else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY + 1))
123 movementCoolDown = movementSpeed;
126 else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY + 1))
130 movementCoolDown = movementSpeed;
133 else if (keysPressed.Contains<Keys>(Keys.Up) && theMap.IsCellOpen(gridX, gridY - 1))
136 movementCoolDown = movementSpeed;
139 else if (keysPressed.Contains<Keys>(Keys.Down) && theMap.IsCellOpen(gridX, gridY + 1))
142 movementCoolDown = movementSpeed;
145 else if (keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY))
148 movementCoolDown = movementSpeed;
151 else if (keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY))
154 movementCoolDown = movementSpeed;
157 if (keysPressed.Contains<Keys>(Keys.Space))
159 //TODO spawn projectile... needs to be added to display though
160 if (state == State.up)
168 public void powerUp(int amount)
173 public void Spawn(Vector2 spawn)
175 gridX = (int)spawn.X;
176 gridY = (int)spawn.Y;