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);
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 //spriteBatch.Draw(charModel, position, Color.White);
55 animateMelee.AttackLeft(spriteBatch);
59 public override void Attack(List<Keys> keysPressed)
63 else if (coolDown == 0)
66 if (keysPressed.Contains<Keys>(Keys.Space))
68 coolDown = hitCoolDown;
69 int startX = Coordinates.X;
70 int startY = Coordinates.Y;
71 if (Motion.Direction == Direction.Down || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.LowerRight)
73 startY = Coordinates.Y + 1;
75 else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight)
77 startY = Coordinates.Y - 1;
79 if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight)
81 startX = Coordinates.X + 1;
83 else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft)
85 startX = Coordinates.X - 1;
88 if (!Game.IsCellOpen(new Point(startX, startY)))
90 IEntity toKill = Game.GetEntityAtCoordinates(new Point(startX, startY));
91 //See if it is a monster
92 if (toKill is IMonster)
94 IMonster hitMonster = (IMonster)toKill;
95 hitMonster.causeDamageTo(this.Damage);
96 if (hitMonster.Health > 0)
98 this.Score += Game.State.HitMonsterScore;
99 Console.WriteLine(this.Score);
103 this.Score += Game.State.KillMonsterScore;
104 Console.WriteLine(this.Score);
105 //Remove dead monsters
106 Game.State.Entities.Remove(toKill);
115 public override void PlayAttackSound()
119 public override void PlayDieSound()