From: Kyle Date: Thu, 22 Apr 2010 23:42:55 +0000 (+0000) Subject: Rearranged stuff to make scoring work. X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=b3adecad08c0bb066d6efe041835a9636a96b066;p=chaz%2Fcarfire Rearranged stuff to make scoring work. git-svn-id: https://bd85.net/svn/cs3505_group@132 92bb83a3-7c8f-8a45-bc97-515c4e399668 --- diff --git a/CarFire/CarFire/CarFire/Game.cs b/CarFire/CarFire/CarFire/Game.cs index 445336a..4aa1cfe 100644 --- a/CarFire/CarFire/CarFire/Game.cs +++ b/CarFire/CarFire/CarFire/Game.cs @@ -232,7 +232,6 @@ namespace CarFire #region Public Methods - public bool IsCellOpen(Point point) { if (!State.Map.IsCellOpen(point)) return false; @@ -385,7 +384,7 @@ namespace CarFire allCharactersSelected = false; if (State.GetKeysDown(i).Contains(Keys.Enter)) { - State.mCharacters[i] = new Human(this, "", State.Map.GetStartingPositionForPlayer(i + 1)); + State.mCharacters[i] = new Human(this, "", State.Map.GetStartingPositionForPlayer(i + 1), i); State.mCharacters[i].LoadContent(mContentManager); } } diff --git a/CarFire/CarFire/CarFire/Human.cs b/CarFire/CarFire/CarFire/Human.cs index 3897491..0d65d49 100644 --- a/CarFire/CarFire/CarFire/Human.cs +++ b/CarFire/CarFire/CarFire/Human.cs @@ -28,9 +28,10 @@ namespace CarFire //Used to draw projectiles int projectileSpeed; int projectileCoolDown; + int mPlayerIndex; - public Human(Game theGame, String Name, Point position) + public Human(Game theGame, String Name, Point position, int playerIndex) { game = theGame; CharName = Name; @@ -38,6 +39,7 @@ namespace CarFire 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); @@ -141,8 +143,8 @@ namespace CarFire toShoot.Normalize(); toShoot *= projectileSpeed; projectileCoolDown = shootCoolDown; - game.State.mDisplay.AddProjectiles(new Projectile(game.State.Map, projectileModel, - toShoot, new Point(startX, startY))); + game.State.mDisplay.AddProjectiles(new Projectile(game, projectileModel, + toShoot, new Point(startX, startY), mPlayerIndex)); } diff --git a/CarFire/CarFire/CarFire/Projectile.cs b/CarFire/CarFire/CarFire/Projectile.cs index 3f5b136..6603272 100644 --- a/CarFire/CarFire/CarFire/Projectile.cs +++ b/CarFire/CarFire/CarFire/Projectile.cs @@ -15,7 +15,6 @@ namespace CarFire public class Projectile { //Member Variables - Map theMap; Vector2 velocity; Texture2D projectileModel; int damage; @@ -27,6 +26,8 @@ namespace CarFire int pixelY; MovementManager mMotion; Point mPosition; + int mCharacterIndex; + Game mGame; /// /// The Constructor for a projectile object. @@ -38,13 +39,15 @@ namespace CarFire /// The starting Y position in the map grid /// The absolute X pixel position on the map /// The absolute Y pixel position on the map - public Projectile(Map _currentMap, + public Projectile(Game theGame, Texture2D _projectileModel, Vector2 _velocity, - Point _position) + Point _position, + int characterNumber) { - theMap = _currentMap; + mGame = theGame; + mCharacterIndex = characterNumber; projectileModel = _projectileModel; velocity = _velocity; mPosition = _position; @@ -79,7 +82,7 @@ namespace CarFire /// The map Y pixel position of the topLeft of the display public void Draw(SpriteBatch spriteBatch) { - Rectangle position = theMap.GetRectangleFromCoordinates(mMotion.Position); + Rectangle position = mGame.State.Map.GetRectangleFromCoordinates(mMotion.Position); spriteBatch.Draw(projectileModel, position, Color.White); } @@ -91,7 +94,6 @@ namespace CarFire public int GridY { get { return gridY; } set { gridY = value; } } public int PixelX { get { return pixelX; } set { pixelX = value; } } public int PixelY { get { return pixelY; } set { pixelY = value; } } - public Map TheMap { get { return theMap; } set { theMap = value; } } public int Damage { get { return damage; } set { damage = value; } } public Vector2 Position { get { return mMotion.Position; } } public Point Coordinates { get { return mMotion.Coordinates; } }