X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FMelee.cs;h=b597cb37a856cff74290d2f89c269f48a8831f98;hp=f461aa69e8110b8b855e342a7638dcfc5c5badd8;hb=3c616e65a6ecf3ebe7b494c9e22c96bc53a1a36f;hpb=6bc3a108ec8f47188a2bf377a23e8a64ec53eccb diff --git a/CarFire/CarFire/CarFire/Melee.cs b/CarFire/CarFire/CarFire/Melee.cs index f461aa6..b597cb3 100644 --- a/CarFire/CarFire/CarFire/Melee.cs +++ b/CarFire/CarFire/CarFire/Melee.cs @@ -18,8 +18,13 @@ namespace CarFire int coolDown; Texture2D charModel; Texture2D projectileModel; + int velocityX; + int velocityY; #endregion + //zac variable + AnimateMelee animateMelee; + #region Public Methods public Melee(Game theGame, String Name, Point position, int playerIndex) : base(theGame, Name, position, playerIndex, baseHealth, baseDamage) @@ -34,6 +39,10 @@ namespace CarFire charModel = contentManager.Load("cs"); //change to charModel when designed projectileModel = contentManager.Load("projectile"); //change to a projectile model later + /*Zac + */ + animateMelee = new AnimateMelee(contentManager, this); + } /// /// This method will draw a character to the screen. @@ -42,7 +51,11 @@ namespace CarFire public override void Draw(SpriteBatch spriteBatch) { Rectangle position = Game.State.Map.GetRectangleFromCoordinates(Motion.Position); - spriteBatch.Draw(charModel, position, Color.White); + Point aPosition = Game.State.Map.GetPointFromCoordinates(Motion.Position); + Vector2 drawPosition = new Vector2(aPosition.X, aPosition.Y); + //spriteBatch.Draw(charModel, position, Color.White); + animateMelee.AttackLeft(spriteBatch, drawPosition); + } public override void Attack(List keysPressed) @@ -51,9 +64,51 @@ namespace CarFire coolDown--; else if (coolDown == 0) { + if (keysPressed.Contains(Keys.Space)) { - + coolDown = hitCoolDown; + int startX = Coordinates.X; + int startY = Coordinates.Y; + if (Motion.Direction == Direction.Down || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.LowerRight) + { + startY = Coordinates.Y + 1; + } + else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight) + { + startY = Coordinates.Y - 1; + } + if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight) + { + startX = Coordinates.X + 1; + } + else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft) + { + startX = Coordinates.X - 1; + } + //Attack a monster + if (!Game.IsCellOpen(new Point(startX, startY))) + { + IEntity toKill = Game.GetEntityAtCoordinates(new Point(startX, startY)); + //See if it is a monster + if (toKill is IMonster) + { + IMonster hitMonster = (IMonster)toKill; + hitMonster.causeDamageTo(this.Damage); + if (hitMonster.Health > 0) + { + this.Score += Game.State.HitMonsterScore; + Console.WriteLine(this.Score); + } + else + { + this.Score += Game.State.KillMonsterScore; + Console.WriteLine(this.Score); + //Remove dead monsters + Game.State.Entities.Remove(toKill); + } + } + } } }