X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FMelee.cs;h=cb25ac81514530f916b051bb7125892163575eb2;hp=f52301219c667184ef107a0d4f1e3cc366329288;hb=e8ee0aa62a7e8b5dffa9e02c00c3e353a9e93b4c;hpb=fc34f843ea42a3496a7ff5dd04853695ba628e8b diff --git a/CarFire/CarFire/CarFire/Melee.cs b/CarFire/CarFire/CarFire/Melee.cs index f523012..cb25ac8 100644 --- a/CarFire/CarFire/CarFire/Melee.cs +++ b/CarFire/CarFire/CarFire/Melee.cs @@ -22,6 +22,9 @@ namespace CarFire 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) @@ -36,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 method will draw a character to the screen. @@ -44,7 +51,9 @@ namespace CarFire public override void Draw(SpriteBatch spriteBatch) { Rectangle position = Game.State.Map.GetRectangleFromCoordinates(Motion.Position); - spriteBatch.Draw(charModel, position, Color.White); + //spriteBatch.Draw(charModel, position, Color.White); + animateMelee.AttackLeft(spriteBatch); + } public override void Attack(List keysPressed) @@ -53,39 +62,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); + } } } }