X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FRanged.cs;fp=CarFire%2FCarFire%2FCarFire%2FHuman.cs;h=b859cd6246fc79a1b1632b5d156e6b3dedd55b74;hb=f31fe51445e412355ef197ea87da3b07f7fc1c70;hp=0d65d494a744cdfaf4b5a7e609af887431139200;hpb=b3adecad08c0bb066d6efe041835a9636a96b066;p=chaz%2Fcarfire diff --git a/CarFire/CarFire/CarFire/Human.cs b/CarFire/CarFire/CarFire/Ranged.cs similarity index 89% rename from CarFire/CarFire/CarFire/Human.cs rename to CarFire/CarFire/CarFire/Ranged.cs index 0d65d49..b859cd6 100644 --- a/CarFire/CarFire/CarFire/Human.cs +++ b/CarFire/CarFire/CarFire/Ranged.cs @@ -9,7 +9,7 @@ using Microsoft.Xna.Framework.Input; namespace CarFire { - public class Human : IPlayer + public class Ranged : IPlayer { //The number of frames between each projectile is spawned. const int shootCoolDown = 18; @@ -31,7 +31,7 @@ namespace CarFire int mPlayerIndex; - public Human(Game theGame, String Name, Point position, int playerIndex) + public Ranged(Game theGame, String Name, Point position, int playerIndex) { game = theGame; CharName = Name; @@ -85,7 +85,22 @@ namespace CarFire /// 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) + public void UpdateInput(TimeSpan timeSpan, List keysPressed) + { + + UpdatePosition(timeSpan, keysPressed); + + if (projectileCoolDown > 0) + projectileCoolDown--; + else if (projectileCoolDown == 0) + { + if (keysPressed.Contains(Keys.Space)) + { + Attack(); + } + } + } + public void UpdatePosition(TimeSpan timeSpan, List keysPressed) { bool moveLeft = keysPressed.Contains(Keys.Left); bool moveRight = keysPressed.Contains(Keys.Right); @@ -107,15 +122,10 @@ namespace CarFire { mMotion.LockUpdate(timeSpan, moveLeft, moveRight, moveUp, moveDown); } - - - if (projectileCoolDown > 0) - projectileCoolDown--; - else if (projectileCoolDown == 0) - { - if (keysPressed.Contains(Keys.Space)) - { - float velocityX = 0; + } + public void Attack() + { + float velocityX = 0; float velocityY = 0; int startX = Coordinates.X; int startY = Coordinates.Y; @@ -144,14 +154,9 @@ namespace CarFire toShoot *= projectileSpeed; projectileCoolDown = shootCoolDown; game.State.mDisplay.AddProjectiles(new Projectile(game, projectileModel, - toShoot, new Point(startX, startY), mPlayerIndex)); - - - } - } + toShoot, new Point(startX, startY), mPlayerIndex, damage)); + } - - public void powerUp(int amount) { health += amount;