X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FMelee.cs;h=f113824b4b250ba3119bebf2714a4f38dea65faa;hb=a716edefa6148bb1847b7029356d610a1886821f;hp=4c053a6a8c26a7efd14b9786ed5bb56594a12334;hpb=b5eebc2087c00bb67b3a3b9ddcec4743aa7a8cdb;p=chaz%2Fcarfire diff --git a/CarFire/CarFire/CarFire/Melee.cs b/CarFire/CarFire/CarFire/Melee.cs index 4c053a6..f113824 100644 --- a/CarFire/CarFire/CarFire/Melee.cs +++ b/CarFire/CarFire/CarFire/Melee.cs @@ -18,6 +18,8 @@ namespace CarFire int coolDown; Texture2D charModel; Texture2D projectileModel; + int velocityX; + int velocityY; #endregion #region Public Methods @@ -51,39 +53,49 @@ 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) { - velocityY = 1; startY = Coordinates.Y + 1; } else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight) { - velocityY = -1; startY = Coordinates.Y - 1; } if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight) { - velocityX = 1; startX = Coordinates.X + 1; } else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft) { - velocityX = -1; startX = Coordinates.X - 1; } //Attack a monster if (!Game.IsCellOpen(new Point(startX, startY))) { - foreach (IEntity entity in Game.State.Entities) + IEntity toKill = Game.GetEntityAtCoordinates(new Point(startX, startY)); + //See if it is a monster + if (toKill is IMonster) { - //See if it is a monster - - //Damage the monster - + 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); + } } } }