X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FMelee.cs;h=38be3038a5ae2e231affcf3ac3b9a29890173a65;hb=f67652c2fe85f9ba6c71dedbab26760775004e00;hp=299f2e79a794b9b2e18b04081eb0239cb4b8a5a6;hpb=0470a7b148c79aaacf0d8107b5bd40fa1e81ac0a;p=chaz%2Fcarfire diff --git a/CarFire/CarFire/CarFire/Melee.cs b/CarFire/CarFire/CarFire/Melee.cs index 299f2e7..38be303 100644 --- a/CarFire/CarFire/CarFire/Melee.cs +++ b/CarFire/CarFire/CarFire/Melee.cs @@ -15,15 +15,18 @@ namespace CarFire const int hitCoolDown = 18; const int baseHealth = 200; const int baseDamage = 30; + int coolDown; Texture2D charModel; Texture2D projectileModel; + int velocityX; + int velocityY; #endregion #region Public Methods public Melee(Game theGame, String Name, Point position, int playerIndex) : base(theGame, Name, position, playerIndex, baseHealth, baseDamage) { - projectileSpeed = 8; + coolDown = hitCoolDown; } #endregion @@ -46,17 +49,65 @@ namespace CarFire public override void Attack(List keysPressed) { - if (hitCoolDown > 0) - hitCoolDown--; - else if (hitCoolDown == 0) + if (coolDown > 0) + coolDown--; + else if (coolDown == 0) { if (keysPressed.Contains(Keys.Space)) { - + 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); + } + } + } } } + } + public override void PlayAttackSound() + { + + } + public override void PlayDieSound() + { + } #endregion }