]> Dogcows Code - chaz/carfire/blob - CarFire/CarFire/CarFire/AnimateMelee.cs
git-svn-id: https://bd85.net/svn/cs3505_group@169 92bb83a3-7c8f-8a45-bc97-515c4e399668
[chaz/carfire] / CarFire / CarFire / CarFire / AnimateMelee.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.Graphics;
7 using Microsoft.Xna.Framework.Content;
8
9 namespace CarFire
10 {
11 class AnimateMelee
12 {
13
14 //member variables
15 private AnimatedTexture SpriteTexture;
16 string[] fileNames = new string[] { "graphics/meleeAttack", "graphics/meleeDying",
17 "graphics/meleeExplosion", "graphics/meleeStanding", "graphics/meleeWalking" };
18 private ContentManager contentManager;
19 //private GraphicsDeviceManager graphics;
20 //private SpriteBatch spriteBatch;
21 private bool changedGraphic;
22 private string lastPh;
23 private int row;
24 private string ph;
25 private Vector2 position;
26 private SpriteBatch character;
27 Player Player;
28
29 public void Update(TimeSpan timeSpan)
30 {
31 SpriteTexture.UpdateFrame(timeSpan);
32 }
33 //constructor(s)
34 public AnimateMelee(ContentManager content, Player player)
35 {
36 SpriteTexture = new AnimatedTexture(Vector2.Zero, 0, 1.0f, 0.5f);
37 contentManager = content;
38 ph = fileNames[3];
39 position = Vector2.Zero;
40 Player = player;
41 changedGraphic = true;
42
43 }
44
45 //methods
46
47 public void AttackDown(SpriteBatch spriteBatch, Vector2 drawSpot)
48 {
49 ph = fileNames[0];
50 row = 0;
51 character = spriteBatch;
52 Animate(drawSpot);
53 }
54
55 public void AttackDownLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
56 {
57 ph = fileNames[0];
58 row = 1;
59 character = spriteBatch;
60 Animate(drawSpot);
61 }
62
63 public void AttackLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
64 {
65 ph = fileNames[0];
66 row = 2;
67 if (lastPh == ph)
68 changedGraphic = false;
69 else
70 changedGraphic = true;
71 lastPh = ph;
72 //graphics = graphicsDeviceManager;
73 //this.spriteBatch = spriteBatch;
74 //character = new SpriteBatch(spriteBatch.GraphicsDevice);
75 character = spriteBatch;
76 Animate(drawSpot);
77 }
78
79 public void AttackUpLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
80 {
81 ph = fileNames[0];
82 row = 4;
83 character = spriteBatch;
84 Animate(drawSpot);
85 }
86
87 public void AttackUp(SpriteBatch spriteBatch, Vector2 drawSpot)
88 {
89 ph = fileNames[0];
90 row = 4;
91 character = spriteBatch;
92 Animate(drawSpot);
93 }
94
95 public void AttackUpRight(SpriteBatch spriteBatch, Vector2 drawSpot)
96 {
97 ph = fileNames[0];
98 row = 5;
99 character = spriteBatch;
100 Animate(drawSpot);
101 }
102
103 public void AttackRight(SpriteBatch spriteBatch, Vector2 drawSpot)
104 {
105 ph = fileNames[0];
106 row = 6;
107 character = spriteBatch;
108 Animate(drawSpot);
109 }
110
111 public void AttackDownRight(SpriteBatch spriteBatch, Vector2 drawSpot)
112 {
113 ph = fileNames[0];
114 row = 7;
115 character = spriteBatch;
116 Animate(drawSpot);
117 }
118
119 // death
120
121 public void DieDown(SpriteBatch spriteBatch, Vector2 drawSpot)
122 {
123 ph = fileNames[1];
124 row = 0;
125 character = spriteBatch;
126 Animate(drawSpot);
127 }
128
129 public void DieDownLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
130 {
131 ph = fileNames[1];
132 row = 1;
133 character = spriteBatch;
134 Animate(drawSpot);
135 }
136
137 public void DieLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
138 {
139 ph = fileNames[1];
140 row = 2;
141 character = spriteBatch;
142 Animate(drawSpot);
143 }
144
145 public void DieUpLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
146 {
147 ph = fileNames[1];
148 row = 4;
149 character = spriteBatch;
150 Animate(drawSpot);
151 }
152
153 public void DieUp(SpriteBatch spriteBatch, Vector2 drawSpot)
154 {
155 ph = fileNames[1];
156 row = 4;
157 character = spriteBatch;
158 Animate(drawSpot);
159 }
160
161 public void DieUpRight(SpriteBatch spriteBatch, Vector2 drawSpot)
162 {
163 ph = fileNames[1];
164 row = 5;
165 character = spriteBatch;
166 Animate(drawSpot);
167 }
168
169 public void DieRight(SpriteBatch spriteBatch, Vector2 drawSpot)
170 {
171 ph = fileNames[1];
172 row = 6;
173 character = spriteBatch;
174 Animate(drawSpot);
175 }
176
177 public void DieDownRight(SpriteBatch spriteBatch, Vector2 drawSpot)
178 {
179 ph = fileNames[1];
180 row = 7;
181 character = spriteBatch;
182 Animate(drawSpot);
183 }
184
185 //melee explosion
186 public void ExplodeDown(SpriteBatch spriteBatch, Vector2 drawSpot)
187 {
188 ph = fileNames[2];
189 row = 0;
190 character = spriteBatch;
191 Animate(drawSpot);
192 }
193
194 public void ExplodeDownLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
195 {
196 ph = fileNames[2];
197 row = 1;
198 character = spriteBatch;
199 Animate(drawSpot);
200 }
201
202 public void ExplodeLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
203 {
204 ph = fileNames[2];
205 row = 2;
206 character = spriteBatch;
207 Animate(drawSpot);
208 }
209
210 public void ExplodeUpLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
211 {
212 ph = fileNames[2];
213 row = 4;
214 character = spriteBatch;
215 Animate(drawSpot);
216 }
217
218 public void ExplodeUp(SpriteBatch spriteBatch, Vector2 drawSpot)
219 {
220 ph = fileNames[2];
221 row = 4;
222 character = spriteBatch;
223 Animate(drawSpot);
224 }
225
226 public void ExplodeUpRight(SpriteBatch spriteBatch, Vector2 drawSpot)
227 {
228 ph = fileNames[2];
229 row = 5;
230 character = spriteBatch;
231 Animate(drawSpot);
232 }
233
234 public void ExplodeRight(SpriteBatch spriteBatch, Vector2 drawSpot)
235 {
236 ph = fileNames[2];
237 row = 6;
238 character = spriteBatch;
239 Animate(drawSpot);
240 }
241
242 public void ExplodeDownRight(SpriteBatch spriteBatch, Vector2 drawSpot)
243 {
244 ph = fileNames[2];
245 row = 7;
246 character = spriteBatch;
247 Animate(drawSpot);
248 }
249
250 //melee standing
251 /*
252 * to do
253 * change this from standard animation to only take into account one frame
254 */
255 public void StandDown(SpriteBatch spriteBatch, Vector2 drawSpot)
256 {
257 ph = fileNames[3];
258 row = 0;
259 character = spriteBatch;
260 Animate(drawSpot);
261 }
262
263 public void StandDownLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
264 {
265 ph = fileNames[3];
266 row = 1;
267 character = spriteBatch;
268 Animate(drawSpot);
269 }
270
271 public void StandLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
272 {
273 ph = fileNames[3];
274 row = 2;
275 character = spriteBatch;
276 Animate(drawSpot);
277 }
278
279 public void StandUpLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
280 {
281 ph = fileNames[3];
282 row = 4;
283 character = spriteBatch;
284 Animate(drawSpot);
285 }
286
287 public void StandUp(SpriteBatch spriteBatch, Vector2 drawSpot)
288 {
289 ph = fileNames[3];
290 row = 4;
291 character = spriteBatch;
292 Animate(drawSpot);
293 }
294
295 public void StandUpRight(SpriteBatch spriteBatch, Vector2 drawSpot)
296 {
297 ph = fileNames[3];
298 row = 5;
299 character = spriteBatch;
300 Animate(drawSpot);
301 }
302
303 public void StandRight(SpriteBatch spriteBatch, Vector2 drawSpot)
304 {
305 ph = fileNames[3];
306 row = 6;
307 character = spriteBatch;
308 Animate(drawSpot);
309 }
310
311 public void StandDownRight(SpriteBatch spriteBatch, Vector2 drawSpot)
312 {
313 ph = fileNames[3];
314 row = 7;
315 character = spriteBatch;
316 Animate(drawSpot);
317 }
318
319 //walking
320
321 public void WalkDown(SpriteBatch spriteBatch, Vector2 drawSpot)
322 {
323 ph = fileNames[4];
324 row = 0;
325 character = spriteBatch;
326 Animate(drawSpot);
327 }
328
329 public void WalkDownLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
330 {
331 ph = fileNames[4];
332 row = 1;
333 character = spriteBatch;
334 Animate(drawSpot);
335 }
336
337 public void WalkLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
338 {
339 ph = fileNames[4];
340 row = 2;
341 character = spriteBatch;
342 Animate(drawSpot);
343 }
344
345 public void WalkUpLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
346 {
347 ph = fileNames[4];
348 row = 4;
349 character = spriteBatch;
350 Animate(drawSpot);
351 }
352
353 public void WalkUp(SpriteBatch spriteBatch, Vector2 drawSpot)
354 {
355 ph = fileNames[4];
356 row = 4;
357 character = spriteBatch;
358 Animate(drawSpot);
359 }
360
361 public void WalkUpRight(SpriteBatch spriteBatch, Vector2 drawSpot)
362 {
363 ph = fileNames[4];
364 row = 5;
365 character = spriteBatch;
366 Animate(drawSpot);
367 }
368
369 public void WalkRight(SpriteBatch spriteBatch, Vector2 drawSpot)
370 {
371 ph = fileNames[4];
372 row = 6;
373 character = spriteBatch;
374 Animate(drawSpot);
375 }
376
377 public void WalkDownRight(SpriteBatch spriteBatch, Vector2 drawSpot)
378 {
379 ph = fileNames[4];
380 row = 7;
381 character = spriteBatch;
382 Animate(drawSpot);
383 }
384
385
386
387
388 public void Animate(Vector2 drawSpot)
389 {
390 //character = new SpriteBatch(graphics.GraphicsDevice);
391 // "character" is the name of the sprite asset in the project.
392 Console.WriteLine(ph);
393 //SpriteTexture.Load(character.GraphicsDevice, contentManager, ph, 8, 12, true, row);
394
395 if(changedGraphic)
396 SpriteTexture.Load(character.GraphicsDevice, contentManager, ph, 8, 12, true, 1);
397
398 //viewport = graphics.GraphicsDevice.Viewport;
399 position = new Vector2(Player.Coordinates.X*Map.PixelsToUnitSquares, Player.Coordinates.Y*Map.PixelsToUnitSquares);//viewport.Width / 2, 0);//viewport.Height / 2f);
400 Console.WriteLine(drawSpot);
401 //character.Begin();
402 SpriteTexture.DrawFrame(character, drawSpot);
403 //character.End();
404 }
405
406 }
407 }
This page took 0.053962 seconds and 5 git commands to generate.