X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FHuman.cs;h=a6397166a24fa5b4b8437b6a7100d5842583a39c;hp=8a94fd3822745dcac308baf3e3243d960b615b2f;hb=1cff093c4d0b0e30919d20d51a3749caed86b98e;hpb=b32b73746f5bf95771eb5f9db95763ce2a44049f
diff --git a/CarFire/CarFire/CarFire/Human.cs b/CarFire/CarFire/CarFire/Human.cs
index 8a94fd3..a639716 100644
--- a/CarFire/CarFire/CarFire/Human.cs
+++ b/CarFire/CarFire/CarFire/Human.cs
@@ -11,18 +11,10 @@ namespace CarFire
{
public class Human : IPlayer
{
- public enum State
- {
- left,
- right,
- up,
- down
- };
//The number of frames between each projectile is spawned.
const int shootCoolDown = 10;
- State state;
String CharName;
- Map theMap;
+ Game game;
Texture2D charModel;
Texture2D projectileModel;
int health;
@@ -40,22 +32,20 @@ namespace CarFire
int projectileCoolDown;
- public Human(Map _theMap, String Name, Texture2D model, Texture2D projectile, Display mDisplay, Point position)
+ public Human(Game theGame, String Name, Texture2D model, Texture2D projectile, Display mDisplay, Point position)
{
- theMap = _theMap;
+ game = theGame;
CharName = Name;
theDisplay = mDisplay;
health = 100;
score = 0;
visible = false;
- //default state
- state = State.up;
charModel = model;
projectileModel = projectile;
projectileSpeed = 30;
// Speed is the number of grid cells you can move through per second.
- mMotion = new MovementManager(position, 5.0f);
+ mMotion = new MovementManager(position, 8.0f);
}
public void LoadContent(ContentManager contentManager)
@@ -65,26 +55,18 @@ namespace CarFire
}
- public void UnloadContent()
- {
- }
-
- public long Update(GameTime gameTime, NetworkManager networkGame)
+ public void Update(TimeSpan timeSpan)
{
- return 0;
-
}
///
/// This method will draw a character to the screen.
///
///
- ///
- public long Draw(SpriteBatch spriteBatch)
+ public void Draw(SpriteBatch spriteBatch)
{
- Rectangle position = theMap.GetRectangleFromCoordinates(mMotion.Position);
+ Rectangle position = game.State.Map.GetRectangleFromCoordinates(mMotion.Position);
spriteBatch.Draw(charModel, position, Color.White);
- return 0;
}
public int Health { get { return health; } }
@@ -112,23 +94,21 @@ namespace CarFire
bool moveRight = keysPressed.Contains(Keys.Right);
bool moveUp = keysPressed.Contains(Keys.Up);
bool moveDown = keysPressed.Contains(Keys.Down);
- if (moveLeft)
- state = State.left;
- else if (moveRight)
- state = State.right;
- else if (moveUp)
- state = State.up;
- else if (moveDown)
- state = State.down;
-
Point destination = MovementManager.GetNeighborCell(mMotion.Coordinates, moveLeft, moveRight, moveUp, moveDown);
- if (theMap.IsCellOpen(destination))
+ if (!keysPressed.Contains(Keys.LeftControl))
{
- mMotion.Update(timeSpan, moveLeft, moveRight, moveUp, moveDown);
+ if (game.IsCellOpen(destination))
+ {
+ mMotion.Update(timeSpan, moveLeft, moveRight, moveUp, moveDown);
+ }
+ else
+ {
+ mMotion.Update(timeSpan);
+ }
}
else
{
- mMotion.Update(timeSpan);
+ mMotion.LockUpdate(timeSpan, moveLeft, moveRight, moveUp, moveDown);
}
@@ -166,35 +146,10 @@ namespace CarFire
toShoot.Normalize();
toShoot *= projectileSpeed;
projectileCoolDown = shootCoolDown;
- theDisplay.AddProjectiles(new Projectile(theMap, projectileModel,
+ theDisplay.AddProjectiles(new Projectile(game.State.Map, projectileModel,
toShoot, new Point(startX, startY)));
- /*
- if (state == State.up)
- {
- projectileCoolDown = shootCoolDown;
- theDisplay.AddProjectiles(new Projectile(theMap, projectileModel,
- new Vector2(0, -projectileSpeed), new Point(Coordinates.X, Coordinates.Y - 1)));
- }
- if (state == State.down)
- {
- projectileCoolDown = shootCoolDown;
- theDisplay.AddProjectiles(new Projectile(theMap, projectileModel,
- new Vector2(0, projectileSpeed), new Point(Coordinates.X, Coordinates.Y + 1)));
- }
- if (state == State.right)
- {
- projectileCoolDown = shootCoolDown;
- theDisplay.AddProjectiles(new Projectile(theMap, projectileModel,
- new Vector2(projectileSpeed, 0), new Point (Coordinates.X + 1, Coordinates.Y)));
- }
- if (state == State.left)
- {
- projectileCoolDown = shootCoolDown;
- theDisplay.AddProjectiles(new Projectile(theMap, projectileModel,
- new Vector2(-projectileSpeed, 0), new Point(Coordinates.X - 1, Coordinates.Y)));
- }
- */
+
}
}
}