X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FMelee.cs;h=c6fb6e82f6aa48ef4094d67628e0ece327d097dc;hp=299f2e79a794b9b2e18b04081eb0239cb4b8a5a6;hb=692a2af57c7f1586b8513106acf47ddc0ac12748;hpb=0470a7b148c79aaacf0d8107b5bd40fa1e81ac0a diff --git a/CarFire/CarFire/CarFire/Melee.cs b/CarFire/CarFire/CarFire/Melee.cs index 299f2e7..c6fb6e8 100644 --- a/CarFire/CarFire/CarFire/Melee.cs +++ b/CarFire/CarFire/CarFire/Melee.cs @@ -15,15 +15,21 @@ 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 + //zac variable + AnimateMelee animateMelee; + #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 @@ -33,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. @@ -41,22 +51,79 @@ 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 UpdateFrame(TimeSpan timeSpan) + { + animateMelee.Update(timeSpan); } - 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)) { - + 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); + } + } + } } } + } + public override void PlayAttackSound() + { + + } + public override void PlayDieSound() + { + } #endregion }