From: Kyle Date: Mon, 19 Apr 2010 02:12:20 +0000 (+0000) Subject: Added a few member fariables and parameter to constructor X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=98a1207447757d2e01f5fba091acf87f8795c8ad;p=chaz%2Fcarfire Added a few member fariables and parameter to constructor git-svn-id: https://bd85.net/svn/cs3505_group@100 92bb83a3-7c8f-8a45-bc97-515c4e399668 --- diff --git a/CarFire/CarFire/CarFire/Human.cs b/CarFire/CarFire/CarFire/Human.cs index acb0d3b..7a926a6 100644 --- a/CarFire/CarFire/CarFire/Human.cs +++ b/CarFire/CarFire/CarFire/Human.cs @@ -11,13 +11,22 @@ namespace CarFire { public class Human : IPlayer { + public enum State + { + left, + right, + up, + down + }; //Member Variables + State state; String CharName; Map theMap; int movementSpeed; int gridX; int gridY; Texture2D charModel; + Texture2D projectileModel; int health; int damage; int range; @@ -26,21 +35,28 @@ namespace CarFire int pixelX; int pixelY; bool visible; + int movementCoolDown; - public Human(Map _theMap, String Name) + public Human(Map _theMap, String Name, Texture2D model) { theMap = _theMap; CharName = Name; - movementSpeed = 20; // randomly set now + movementSpeed = 12; // randomly set now health = 100; score = 0; visible = false; + //default state + state = State.up; + charModel = model; + movementCoolDown = movementSpeed; } public void LoadContent(ContentManager contentManager) { charModel = contentManager.Load("deselectBox"); //change to charModel when designed + projectileModel = contentManager.Load("emptySelectBox"); //change to a projectile model later + } public void UnloadContent() @@ -80,50 +96,71 @@ namespace CarFire /// 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)) + if(movementCoolDown > 0) + movementCoolDown--; + else if (movementCoolDown == 0) { - gridX -= 1; + // 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; + movementCoolDown = movementSpeed; + } + // move upright + else if (keysPressed.Contains(Keys.Up) && keysPressed.Contains(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY - 1)) + { + gridX += 1; + gridY -= 1; + movementCoolDown = movementSpeed; + } + // move downleft + else if (keysPressed.Contains(Keys.Down) && keysPressed.Contains(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY + 1)) + { + gridX -= 1; + gridY += 1; + movementCoolDown = movementSpeed; + } + // move downright + else if (keysPressed.Contains(Keys.Down) && keysPressed.Contains(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY + 1)) + { + gridX += 1; + gridY += 1; + movementCoolDown = movementSpeed; + } + // move up + else if (keysPressed.Contains(Keys.Up) && theMap.IsCellOpen(gridX, gridY - 1)) + { + gridY -= 1; + movementCoolDown = movementSpeed; + } + // move down + else if (keysPressed.Contains(Keys.Down) && theMap.IsCellOpen(gridX, gridY + 1)) + { + gridY += 1; + movementCoolDown = movementSpeed; + } + // move left + else if (keysPressed.Contains(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY)) + { + gridX -= 1; + movementCoolDown = movementSpeed; + } + // move right + else if (keysPressed.Contains(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY)) + { + gridX += 1; + movementCoolDown = movementSpeed; + } } - // move right - else if (keysPressed.Contains(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY)) + if (keysPressed.Contains(Keys.Space)) { - gridX += 1; + //TODO spawn projectile... needs to be added to display though + if (state == State.up) + { + + } } }