X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FHuman.cs;fp=CarFire%2FCarFire%2FCarFire%2FHuman.cs;h=0000000000000000000000000000000000000000;hb=f31fe51445e412355ef197ea87da3b07f7fc1c70;hp=0d65d494a744cdfaf4b5a7e609af887431139200;hpb=b3adecad08c0bb066d6efe041835a9636a96b066;p=chaz%2Fcarfire diff --git a/CarFire/CarFire/CarFire/Human.cs b/CarFire/CarFire/CarFire/Human.cs deleted file mode 100644 index 0d65d49..0000000 --- a/CarFire/CarFire/CarFire/Human.cs +++ /dev/null @@ -1,169 +0,0 @@ -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 - { - //The number of frames between each projectile is spawned. - const int shootCoolDown = 18; - String CharName; - Game game; - Texture2D charModel; - Texture2D projectileModel; - int health; - int damage; - int range; - int score; - - MovementManager mMotion; - bool visible; - - //Used to draw projectiles - int projectileSpeed; - int projectileCoolDown; - int mPlayerIndex; - - - public Human(Game theGame, String Name, Point position, int playerIndex) - { - game = theGame; - CharName = Name; - health = 100; - score = 0; - visible = false; - projectileSpeed = 8; - mPlayerIndex = playerIndex; - - // Speed is the number of grid cells you can move through per second. - mMotion = new MovementManager(position, 4.0f); - } - - public void LoadContent(ContentManager contentManager) - { - charModel = contentManager.Load("cs"); //change to charModel when designed - projectileModel = contentManager.Load("projectile"); //change to a projectile model later - - } - - - public void Update(TimeSpan timeSpan) - { - } - /// - /// This method will draw a character to the screen. - /// - /// - public void Draw(SpriteBatch spriteBatch) - { - Rectangle position = game.State.Map.GetRectangleFromCoordinates(mMotion.Position); - spriteBatch.Draw(charModel, position, Color.White); - } - - public int Health { get { return health; } } - public int Score { get { return score; } } - public bool alive { get { return health > 0; } } - - public Vector2 Position { get { return mMotion.Position; } } - public Point Coordinates { get { return mMotion.Coordinates; } } - - 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(TimeSpan timeSpan, List keysPressed) - { - bool moveLeft = keysPressed.Contains(Keys.Left); - bool moveRight = keysPressed.Contains(Keys.Right); - bool moveUp = keysPressed.Contains(Keys.Up); - bool moveDown = keysPressed.Contains(Keys.Down); - Point destination = MovementManager.GetNeighborCell(mMotion.Coordinates, moveLeft, moveRight, moveUp, moveDown); - if (!keysPressed.Contains(Keys.LeftControl)) - { - if (game.IsCellOpen(destination)) - { - mMotion.Update(timeSpan, moveLeft, moveRight, moveUp, moveDown); - } - else - { - mMotion.Update(timeSpan); - } - } - else - { - mMotion.LockUpdate(timeSpan, moveLeft, moveRight, moveUp, moveDown); - } - - - if (projectileCoolDown > 0) - projectileCoolDown--; - else if (projectileCoolDown == 0) - { - if (keysPressed.Contains(Keys.Space)) - { - float velocityX = 0; - float velocityY = 0; - int startX = Coordinates.X; - int startY = Coordinates.Y; - if (mMotion.Direction == Direction.Down || mMotion.Direction == Direction.LowerLeft || mMotion.Direction == Direction.LowerRight) - { - velocityY = 1; - startY = Coordinates.Y + 1; - } - else if (mMotion.Direction == Direction.Up || mMotion.Direction == Direction.UpperLeft || mMotion.Direction == Direction.UpperRight) - { - velocityY = -1; - startY = Coordinates.Y - 1; - } - if (mMotion.Direction == Direction.Right || mMotion.Direction == Direction.LowerRight || mMotion.Direction == Direction.UpperRight) - { - velocityX = 1; - startX = Coordinates.X + 1; - } - else if (mMotion.Direction == Direction.Left || mMotion.Direction == Direction.LowerLeft || mMotion.Direction == Direction.UpperLeft) - { - velocityX = -1; - startX = Coordinates.X - 1; - } - Vector2 toShoot = new Vector2(velocityX, velocityY); - toShoot.Normalize(); - toShoot *= projectileSpeed; - projectileCoolDown = shootCoolDown; - game.State.mDisplay.AddProjectiles(new Projectile(game, projectileModel, - toShoot, new Point(startX, startY), mPlayerIndex)); - - - } - } - } - - - public void powerUp(int amount) - { - health += amount; - } - - public void Spawn(Vector2 spawn) - { - //gridX = (int)spawn.X; - //gridY = (int)spawn.Y; - visible = true; - } - - - } -} \ No newline at end of file