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);
61 public override void Attack(List<Keys> keysPressed)
65 else if (coolDown == 0)
68 if (keysPressed.Contains<Keys>(Keys.Space))
70 coolDown = hitCoolDown;
71 int startX = Coordinates.X;
72 int startY = Coordinates.Y;
73 if (Motion.Direction == Direction.Down || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.LowerRight)
75 startY = Coordinates.Y + 1;
77 else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight)
79 startY = Coordinates.Y - 1;
81 if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight)
83 startX = Coordinates.X + 1;
85 else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft)
87 startX = Coordinates.X - 1;
90 if (!Game.IsCellOpen(new Point(startX, startY)))
92 IEntity toKill = Game.GetEntityAtCoordinates(new Point(startX, startY));
93 //See if it is a monster
94 if (toKill is IMonster)
96 IMonster hitMonster = (IMonster)toKill;
97 hitMonster.causeDamageTo(this.Damage);
98 if (hitMonster.Health > 0)
100 this.Score += Game.State.HitMonsterScore;
101 Console.WriteLine(this.Score);
105 this.Score += Game.State.KillMonsterScore;
106 Console.WriteLine(this.Score);
107 //Remove dead monsters
108 Game.State.Entities.Remove(toKill);
117 public override void PlayAttackSound()
121 public override void PlayDieSound()