c6fb6e82f6aa48ef4094d67628e0ece327d097dc
[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 public override void UpdateFrame(TimeSpan timeSpan)
61 {
62 animateMelee.Update(timeSpan);
63 }
64 public override void Attack(List<Keys> keysPressed)
65 {
66 if (coolDown > 0)
67 coolDown--;
68 else if (coolDown == 0)
69 {
70
71 if (keysPressed.Contains<Keys>(Keys.Space))
72 {
73 coolDown = hitCoolDown;
74 int startX = Coordinates.X;
75 int startY = Coordinates.Y;
76 if (Motion.Direction == Direction.Down || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.LowerRight)
77 {
78 startY = Coordinates.Y + 1;
79 }
80 else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight)
81 {
82 startY = Coordinates.Y - 1;
83 }
84 if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight)
85 {
86 startX = Coordinates.X + 1;
87 }
88 else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft)
89 {
90 startX = Coordinates.X - 1;
91 }
92 //Attack a monster
93 if (!Game.IsCellOpen(new Point(startX, startY)))
94 {
95 IEntity toKill = Game.GetEntityAtCoordinates(new Point(startX, startY));
96 //See if it is a monster
97 if (toKill is IMonster)
98 {
99 IMonster hitMonster = (IMonster)toKill;
100 hitMonster.causeDamageTo(this.Damage);
101 if (hitMonster.Health > 0)
102 {
103 this.Score += Game.State.HitMonsterScore;
104 Console.WriteLine(this.Score);
105 }
106 else
107 {
108 this.Score += Game.State.KillMonsterScore;
109 Console.WriteLine(this.Score);
110 //Remove dead monsters
111 Game.State.Entities.Remove(toKill);
112 }
113 }
114 }
115 }
116 }
117
118
119 }
120 public override void PlayAttackSound()
121 {
122
123 }
124 public override void PlayDieSound()
125 {
126
127 }
128 #endregion
129 }
130 }
This page took 0.046021 seconds and 3 git commands to generate.