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;
26 AnimateMelee animateMelee;
28 #region Public Methods
29 public Melee(Game theGame, String Name, Point position, int playerIndex)
30 : base(theGame, Name, position, playerIndex, baseHealth, baseDamage)
32 coolDown = hitCoolDown;
36 #region Overridden Methods From Player
37 public override void LoadContent(ContentManager contentManager)
39 charModel = contentManager.Load<Texture2D>("cs"); //change to charModel when designed
40 projectileModel = contentManager.Load<Texture2D>("projectile"); //change to a projectile model later
44 animateMelee = new AnimateMelee(contentManager, this);
48 /// This method will draw a character to the screen.
50 /// <param name="spriteBatch"></param>
51 public override void Draw(SpriteBatch spriteBatch)
53 Rectangle position = Game.State.Map.GetRectangleFromCoordinates(Motion.Position);
54 Point aPosition = Game.State.Map.GetPointFromCoordinates(Motion.Position);
55 Vector2 drawPosition = new Vector2(aPosition.X, aPosition.Y);
56 //spriteBatch.Draw(charModel, position, Color.White);
57 animateMelee.AttackLeft(spriteBatch, drawPosition);
60 public override void UpdateFrame(TimeSpan timeSpan)
62 animateMelee.Update(timeSpan);
64 public override void Attack(List<Keys> keysPressed)
68 else if (coolDown == 0)
71 if (keysPressed.Contains<Keys>(Keys.Space))
73 coolDown = hitCoolDown;
74 int startX = Coordinates.X;
75 int startY = Coordinates.Y;
76 if (Motion.Direction == Direction.Down || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.LowerRight)
78 startY = Coordinates.Y + 1;
80 else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight)
82 startY = Coordinates.Y - 1;
84 if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight)
86 startX = Coordinates.X + 1;
88 else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft)
90 startX = Coordinates.X - 1;
93 if (!Game.IsCellOpen(new Point(startX, startY)))
95 IEntity toKill = Game.GetEntityAtCoordinates(new Point(startX, startY));
96 //See if it is a monster
97 if (toKill is IMonster)
99 IMonster hitMonster = (IMonster)toKill;
100 hitMonster.causeDamageTo(this.Damage);
101 if (hitMonster.Health > 0)
103 this.Score += Game.State.HitMonsterScore;
104 Console.WriteLine(this.Score);
108 this.Score += Game.State.KillMonsterScore;
109 Console.WriteLine(this.Score);
110 //Remove dead monsters
111 Game.State.Entities.Remove(toKill);
120 public override void PlayAttackSound()
124 public override void PlayDieSound()