2 using System.Collections.Generic;
5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Content;
7 using Microsoft.Xna.Framework.Graphics;
8 using Microsoft.Xna.Framework.Input;
12 public class Melee : Player
14 #region Member Variables
15 const int hitCoolDown = 18;
16 const int baseHealth = 200;
17 const int baseDamage = 30;
20 Texture2D projectileModel;
27 AnimateMelee animateMelee;
29 #region Public Methods
30 public Melee(Game theGame, String Name, Point position, int playerIndex)
31 : base(theGame, Name, position, playerIndex, baseHealth, baseDamage)
33 coolDown = hitCoolDown;
37 #region Overridden Methods From Player
38 public override void LoadContent(ContentManager contentManager)
40 charModel = contentManager.Load<Texture2D>("cs"); //change to charModel when designed
41 projectileModel = contentManager.Load<Texture2D>("projectile"); //change to a projectile model later
46 animateMelee = new AnimateMelee(contentManager, this);
50 /// This method will draw a character to the screen.
52 /// <param name="spriteBatch"></param>
53 public override void Draw(SpriteBatch spriteBatch)
55 Rectangle position = Game.State.Map.GetRectangleFromCoordinates(Motion.Position);
56 Point aPosition = Game.State.Map.GetPointFromCoordinates(Motion.Position);
57 Vector2 drawPosition = new Vector2(aPosition.X, aPosition.Y);
58 //spriteBatch.Draw(charModel, position, Color.White);
60 animateMelee.AttackLeft(spriteBatch, drawPosition);
63 public override void UpdateFrame(TimeSpan timeSpan)
65 animateMelee.Update(timeSpan);
67 public override void Attack(List<Keys> keysPressed)
71 else if (coolDown == 0)
74 if (keysPressed.Contains<Keys>(Keys.Space))
77 coolDown = hitCoolDown;
78 int startX = Coordinates.X;
79 int startY = Coordinates.Y;
80 if (Motion.Direction == Direction.Down || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.LowerRight)
82 startY = Coordinates.Y + 1;
84 else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight)
86 startY = Coordinates.Y - 1;
88 if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight)
90 startX = Coordinates.X + 1;
92 else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft)
94 startX = Coordinates.X - 1;
97 if (!Game.IsCellOpen(new Point(startX, startY)))
99 IEntity toKill = Game.GetEntityAtCoordinates(new Point(startX, startY));
100 //See if it is a monster
101 if (toKill is IMonster)
103 IMonster hitMonster = (IMonster)toKill;
104 hitMonster.causeDamageTo(this.Damage);
105 if (hitMonster.Health > 0)
107 this.Score += Game.State.HitMonsterScore;
108 Console.WriteLine(this.Score);
112 this.Score += Game.State.KillMonsterScore;
113 Console.WriteLine(this.Score);
114 //Remove dead monsters
115 Game.State.Entities.Remove(toKill);
124 public override void PlayAttackSound()
128 public override void PlayDieSound()