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;
25 #region Public Methods
26 public Melee(Game theGame, String Name, Point position, int playerIndex)
27 : base(theGame, Name, position, playerIndex, baseHealth, baseDamage)
29 coolDown = hitCoolDown;
33 #region Overridden Methods From Player
34 public override void LoadContent(ContentManager contentManager)
36 charModel = contentManager.Load<Texture2D>("cs"); //change to charModel when designed
37 projectileModel = contentManager.Load<Texture2D>("projectile"); //change to a projectile model later
41 /// This method will draw a character to the screen.
43 /// <param name="spriteBatch"></param>
44 public override void Draw(SpriteBatch spriteBatch)
46 Rectangle position = Game.State.Map.GetRectangleFromCoordinates(Motion.Position);
47 spriteBatch.Draw(charModel, position, Color.White);
50 public override void Attack(List<Keys> keysPressed)
54 else if (coolDown == 0)
57 if (keysPressed.Contains<Keys>(Keys.Space))
59 coolDown = hitCoolDown;
60 int startX = Coordinates.X;
61 int startY = Coordinates.Y;
62 if (Motion.Direction == Direction.Down || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.LowerRight)
64 startY = Coordinates.Y + 1;
66 else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight)
68 startY = Coordinates.Y - 1;
70 if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight)
72 startX = Coordinates.X + 1;
74 else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft)
76 startX = Coordinates.X - 1;
79 if (!Game.IsCellOpen(new Point(startX, startY)))
81 IEntity toKill = Game.GetEntityAtCoordinates(new Point(startX, startY));
82 //See if it is a monster
83 if (toKill is IMonster)
85 IMonster hitMonster = (IMonster)toKill;
86 hitMonster.causeDamageTo(this.Damage);
87 if (hitMonster.Health > 0)
89 this.Score += Game.State.HitMonsterScore;
90 Console.WriteLine(this.Score);
94 this.Score += Game.State.KillMonsterScore;
95 Console.WriteLine(this.Score);
96 //Remove dead monsters
97 Game.State.Entities.Remove(toKill);
106 public override void PlayAttackSound()
110 public override void PlayDieSound()