using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; namespace CarFire { public class Human : IPlayer { //Member Variables String CharName; Map theMap; int movementSpeed; int gridX; int gridY; Texture2D charModel; int health; int damage; int range; int score; bool isMoving; int pixelX; int pixelY; bool visible; public Human(Map _theMap, String Name) { theMap = _theMap; CharName = Name; movementSpeed = 20; // randomly set now health = 100; score = 0; visible = false; } public void LoadContent(ContentManager contentManager) { charModel = contentManager.Load("deselectBox"); //change to charModel when designed } public void UnloadContent() { } public long Update(GameTime gameTime, NetworkManager networkGame) { return 0; } public long Draw(SpriteBatch spriteBatch) { spriteBatch.Draw(charModel, theMap.GetRectangleFromCoordinates(gridX, gridY), Color.White); return 0; } public int GridX { get { return gridX; } set { gridX = value; } } public int GridY { get { return gridY; } set { gridY = value; } } public int Health { get { return health; } } public int Score { get { return score; } } public bool alive { get { return health > 0; } } public void causeDamageTo(int amount) { health -= amount; } /// /// Moves the current player being controlled based on a given set of key presses. /// The player can only move one grid space per movePlayer call. Thus this method /// is made to be called ever update. The player will only move if the grid space /// that is being moved to is an open space. /// /// A general list of keys that are pressed. Other keys can be included but only direction keys will be used public void MovePlayer(List keysPressed) { // move upleft keysPressed.Contains(Keys.Left); if (keysPressed.Contains(Keys.Up) && keysPressed.Contains(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY - 1)) { gridX -= 1; gridY -= 1; } // move upright else if (keysPressed.Contains(Keys.Up) && keysPressed.Contains(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY - 1)) { gridX += 1; gridY -= 1; } // move downleft else if (keysPressed.Contains(Keys.Down) && keysPressed.Contains(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY + 1)) { gridX -= 1; gridY += 1; } // move downright else if (keysPressed.Contains(Keys.Down) && keysPressed.Contains(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY + 1)) { gridX += 1; gridY += 1; } // move up else if (keysPressed.Contains(Keys.Up) && theMap.IsCellOpen(gridX, gridY - 1)) { gridY -= 1; } // move down else if (keysPressed.Contains(Keys.Down) && theMap.IsCellOpen(gridX, gridY + 1)) { gridY += 1; } // move left else if (keysPressed.Contains(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY)) { gridX -= 1; } // move right else if (keysPressed.Contains(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY)) { gridX += 1; } } public void powerUp(int amount) { health += amount; } public void Spawn(Vector2 spawn) { gridX = (int)spawn.X; gridY = (int)spawn.Y; visible = true; } } }