using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; namespace CarFire { public class Melee : Player { #region Member Variables const int hitCoolDown = 18; const int baseHealth = 200; const int baseDamage = 30; int coolDown; Texture2D charModel; Texture2D projectileModel; #endregion #region Public Methods public Melee(Game theGame, String Name, Point position, int playerIndex) : base(theGame, Name, position, playerIndex, baseHealth, baseDamage) { coolDown = hitCoolDown; } #endregion #region Overridden Methods From Player public override void LoadContent(ContentManager contentManager) { charModel = contentManager.Load("cs"); //change to charModel when designed projectileModel = contentManager.Load("projectile"); //change to a projectile model later } /// /// This method will draw a character to the screen. /// /// public override void Draw(SpriteBatch spriteBatch) { Rectangle position = Game.State.Map.GetRectangleFromCoordinates(Motion.Position); spriteBatch.Draw(charModel, position, Color.White); } public override void Attack(List keysPressed) { 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) { 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) { //See if it is a monster //Damage the monster } } } } } public override void PlayAttackSound() { } public override void PlayDieSound() { } #endregion } }