]> Dogcows Code - chaz/carfire/blob - CarFire/CarFire/CarFire/Melee.cs
git-svn-id: https://bd85.net/svn/cs3505_group@163 92bb83a3-7c8f-8a45-bc97-515c4e399668
[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 //zac variable
26 AnimateMelee animateMelee;
27
28 #region Public Methods
29 public Melee(Game theGame, String Name, Point position, int playerIndex)
30 : base(theGame, Name, position, playerIndex, baseHealth, baseDamage)
31 {
32 coolDown = hitCoolDown;
33 }
34 #endregion
35
36 #region Overridden Methods From Player
37 public override void LoadContent(ContentManager contentManager)
38 {
39 charModel = contentManager.Load<Texture2D>("cs"); //change to charModel when designed
40 projectileModel = contentManager.Load<Texture2D>("projectile"); //change to a projectile model later
41
42 /*Zac
43 */
44 animateMelee = new AnimateMelee(contentManager);
45
46 }
47 /// <summary>
48 /// This method will draw a character to the screen.
49 /// </summary>
50 /// <param name="spriteBatch"></param>
51 public override void Draw(SpriteBatch spriteBatch)
52 {
53 Rectangle position = Game.State.Map.GetRectangleFromCoordinates(Motion.Position);
54 //spriteBatch.Draw(charModel, position, Color.White);
55 animateMelee.AttackLeft(spriteBatch);
56
57 }
58
59 public override void Attack(List<Keys> keysPressed)
60 {
61 if (coolDown > 0)
62 coolDown--;
63 else if (coolDown == 0)
64 {
65
66 if (keysPressed.Contains<Keys>(Keys.Space))
67 {
68 coolDown = hitCoolDown;
69 int startX = Coordinates.X;
70 int startY = Coordinates.Y;
71 if (Motion.Direction == Direction.Down || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.LowerRight)
72 {
73 startY = Coordinates.Y + 1;
74 }
75 else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight)
76 {
77 startY = Coordinates.Y - 1;
78 }
79 if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight)
80 {
81 startX = Coordinates.X + 1;
82 }
83 else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft)
84 {
85 startX = Coordinates.X - 1;
86 }
87 //Attack a monster
88 if (!Game.IsCellOpen(new Point(startX, startY)))
89 {
90 IEntity toKill = Game.GetEntityAtCoordinates(new Point(startX, startY));
91 //See if it is a monster
92 if (toKill is IMonster)
93 {
94 IMonster hitMonster = (IMonster)toKill;
95 hitMonster.causeDamageTo(this.Damage);
96 if (hitMonster.Health > 0)
97 {
98 this.Score += Game.State.HitMonsterScore;
99 Console.WriteLine(this.Score);
100 }
101 else
102 {
103 this.Score += Game.State.KillMonsterScore;
104 Console.WriteLine(this.Score);
105 //Remove dead monsters
106 Game.State.Entities.Remove(toKill);
107 }
108 }
109 }
110 }
111 }
112
113
114 }
115 public override void PlayAttackSound()
116 {
117
118 }
119 public override void PlayDieSound()
120 {
121
122 }
123 #endregion
124 }
125 }
This page took 0.040103 seconds and 4 git commands to generate.