]> Dogcows Code - chaz/carfire/blob - CarFire/CarFire/CarFire/Melee.cs
git-svn-id: https://bd85.net/svn/cs3505_group@164 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, this);
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 Point aPosition = Game.State.Map.GetPointFromCoordinates(Motion.Position);
55 Vector2 drawPosition = new Vector2(aPosition.X, aPosition.Y);
56 //spriteBatch.Draw(charModel, position, Color.White);
57 animateMelee.AttackLeft(spriteBatch, drawPosition);
58
59 }
60
61 public override void Attack(List<Keys> keysPressed)
62 {
63 if (coolDown > 0)
64 coolDown--;
65 else if (coolDown == 0)
66 {
67
68 if (keysPressed.Contains<Keys>(Keys.Space))
69 {
70 coolDown = hitCoolDown;
71 int startX = Coordinates.X;
72 int startY = Coordinates.Y;
73 if (Motion.Direction == Direction.Down || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.LowerRight)
74 {
75 startY = Coordinates.Y + 1;
76 }
77 else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight)
78 {
79 startY = Coordinates.Y - 1;
80 }
81 if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight)
82 {
83 startX = Coordinates.X + 1;
84 }
85 else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft)
86 {
87 startX = Coordinates.X - 1;
88 }
89 //Attack a monster
90 if (!Game.IsCellOpen(new Point(startX, startY)))
91 {
92 IEntity toKill = Game.GetEntityAtCoordinates(new Point(startX, startY));
93 //See if it is a monster
94 if (toKill is IMonster)
95 {
96 IMonster hitMonster = (IMonster)toKill;
97 hitMonster.causeDamageTo(this.Damage);
98 if (hitMonster.Health > 0)
99 {
100 this.Score += Game.State.HitMonsterScore;
101 Console.WriteLine(this.Score);
102 }
103 else
104 {
105 this.Score += Game.State.KillMonsterScore;
106 Console.WriteLine(this.Score);
107 //Remove dead monsters
108 Game.State.Entities.Remove(toKill);
109 }
110 }
111 }
112 }
113 }
114
115
116 }
117 public override void PlayAttackSound()
118 {
119
120 }
121 public override void PlayDieSound()
122 {
123
124 }
125 #endregion
126 }
127 }
This page took 0.034498 seconds and 4 git commands to generate.