]> Dogcows Code - chaz/carfire/blob - CarFire/CarFire/CarFire/Melee.cs
Implemented map tiles; started new Key entity; added missing variables to Melee.cs...
[chaz/carfire] / CarFire / CarFire / CarFire / Melee.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Content;
7 using Microsoft.Xna.Framework.Graphics;
8 using Microsoft.Xna.Framework.Input;
9
10 namespace CarFire
11 {
12 public class Melee : Player
13 {
14 #region Member Variables
15 const int hitCoolDown = 18;
16 const int baseHealth = 200;
17 const int baseDamage = 30;
18 int coolDown;
19 Texture2D charModel;
20 Texture2D projectileModel;
21 int velocityX;
22 int velocityY;
23 #endregion
24
25 #region Public Methods
26 public Melee(Game theGame, String Name, Point position, int playerIndex)
27 : base(theGame, Name, position, playerIndex, baseHealth, baseDamage)
28 {
29 coolDown = hitCoolDown;
30 }
31 #endregion
32
33 #region Overridden Methods From Player
34 public override void LoadContent(ContentManager contentManager)
35 {
36 charModel = contentManager.Load<Texture2D>("cs"); //change to charModel when designed
37 projectileModel = contentManager.Load<Texture2D>("projectile"); //change to a projectile model later
38
39 }
40 /// <summary>
41 /// This method will draw a character to the screen.
42 /// </summary>
43 /// <param name="spriteBatch"></param>
44 public override void Draw(SpriteBatch spriteBatch)
45 {
46 Rectangle position = Game.State.Map.GetRectangleFromCoordinates(Motion.Position);
47 spriteBatch.Draw(charModel, position, Color.White);
48 }
49
50 public override void Attack(List<Keys> keysPressed)
51 {
52 if (coolDown > 0)
53 coolDown--;
54 else if (coolDown == 0)
55 {
56 if (keysPressed.Contains<Keys>(Keys.Space))
57 {
58 int startX = Coordinates.X;
59 int startY = Coordinates.Y;
60 if (Motion.Direction == Direction.Down || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.LowerRight)
61 {
62 velocityY = 1;
63 startY = Coordinates.Y + 1;
64 }
65 else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight)
66 {
67 velocityY = -1;
68 startY = Coordinates.Y - 1;
69 }
70 if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight)
71 {
72 velocityX = 1;
73 startX = Coordinates.X + 1;
74 }
75 else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft)
76 {
77 velocityX = -1;
78 startX = Coordinates.X - 1;
79 }
80 //Attack a monster
81 if (!Game.IsCellOpen(new Point(startX, startY)))
82 {
83 foreach (IEntity entity in Game.State.Entities)
84 {
85 //See if it is a monster
86
87 //Damage the monster
88
89 }
90 }
91 }
92 }
93
94
95 }
96 public override void PlayAttackSound()
97 {
98
99 }
100 public override void PlayDieSound()
101 {
102
103 }
104 #endregion
105 }
106 }
This page took 0.039696 seconds and 5 git commands to generate.