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
23 const int baseProjectileSpeed = 18;
25 int projectileCoolDown;
28 #region Public Methods
29 public Ranged(Game theGame, String Name, Point position, int playerIndex)
30 : base(theGame, Name, position, playerIndex, baseHealth, baseDamage)
32 projectileSpeed = baseProjectileSpeed;
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 /// This method will draw a character to the screen.
46 /// <param name="spriteBatch"></param>
47 public override void Draw(SpriteBatch spriteBatch)
49 Rectangle position = Game.State.Map.GetRectangleFromCoordinates(Motion.Position);
50 spriteBatch.Draw(charModel, position, Color.White);
53 public override void Attack(List<Keys> keysPressed)
55 if (projectileCoolDown > 0)
57 else if (projectileCoolDown == 0)
59 if (keysPressed.Contains<Keys>(Keys.Space))
63 int startX = Coordinates.X;
64 int startY = Coordinates.Y;
65 if (Motion.Direction == Direction.Down || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.LowerRight)
68 startY = Coordinates.Y + 1;
70 else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight)
73 startY = Coordinates.Y - 1;
75 if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight)
78 startX = Coordinates.X + 1;
80 else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft)
83 startX = Coordinates.X - 1;
85 Vector2 toShoot = new Vector2(velocityX, velocityY);
87 toShoot *= projectileSpeed;
88 projectileCoolDown = shootCoolDown;
89 Game.State.mProjectiles.Add(new Projectile(Game, projectileModel,
90 toShoot, new Point(startX, startY), PlayerIndex, Damage));
96 public override void PlayAttackSound()
100 public override void PlayDieSound()