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 Ranged : Player
14 #region Member Variables
15 //The number of frames between each projectile is spawned.
16 const int shootCoolDown = 18;
17 const int baseHealth = 100;
18 const int baseDamage = 20;
20 Texture2D projectileModel;
22 //Used to draw projectiles
24 int projectileCoolDown;
27 #region Public Methods
28 public Ranged(Game theGame, String Name, Point position, int playerIndex)
29 : base(theGame, Name, position, playerIndex, baseHealth, baseDamage)
35 #region Overridden Methods From Player
36 public override void LoadContent(ContentManager contentManager)
38 charModel = contentManager.Load<Texture2D>("cs"); //change to charModel when designed
39 projectileModel = contentManager.Load<Texture2D>("projectile"); //change to a projectile model later
43 /// This method will draw a character to the screen.
45 /// <param name="spriteBatch"></param>
46 public override void Draw(SpriteBatch spriteBatch)
48 Rectangle position = Game.State.Map.GetRectangleFromCoordinates(Motion.Position);
49 spriteBatch.Draw(charModel, position, Color.White);
52 public override void Attack(List<Keys> keysPressed)
54 if (projectileCoolDown > 0)
56 else if (projectileCoolDown == 0)
58 if (keysPressed.Contains<Keys>(Keys.Space))
62 int startX = Coordinates.X;
63 int startY = Coordinates.Y;
64 if (Motion.Direction == Direction.Down || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.LowerRight)
67 startY = Coordinates.Y + 1;
69 else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight)
72 startY = Coordinates.Y - 1;
74 if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight)
77 startX = Coordinates.X + 1;
79 else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft)
82 startX = Coordinates.X - 1;
84 Vector2 toShoot = new Vector2(velocityX, velocityY);
86 toShoot *= projectileSpeed;
87 projectileCoolDown = shootCoolDown;
88 Game.State.mProjectiles.Add(new Projectile(Game, projectileModel,
89 toShoot, new Point(startX, startY), PlayerIndex, Damage));
95 public override void PlayAttackSound()
99 public override void PlayDieSound()