git-svn-id: https://bd85.net/svn/cs3505_group@167 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 string ph;
24 private Vector2 position;
25 private SpriteBatch character;
26 Player Player;
27
28 public void Update(TimeSpan timeSpan)
29 {
30 SpriteTexture.UpdateFrame(timeSpan);
31 }
32 //constructor(s)
33 public AnimateMelee(ContentManager content, Player player)
34 {
35 SpriteTexture = new AnimatedTexture(Vector2.Zero, 0, 1.0f, 0.5f);
36 contentManager = content;
37 ph = fileNames[3];
38 position = Vector2.Zero;
39 Player = player;
40 changedGraphic = true;
41
42 }
43
44 //methods
45
46 public void AttackLeft(SpriteBatch spriteBatch, Vector2 drawSpot)
47 {
48 ph = fileNames[0];
49 if (lastPh == ph)
50 changedGraphic = false;
51 else
52 changedGraphic = true;
53 lastPh = ph;
54 //graphics = graphicsDeviceManager;
55 //this.spriteBatch = spriteBatch;
56 //character = new SpriteBatch(spriteBatch.GraphicsDevice);
57 character = spriteBatch;
58 Animate(drawSpot);
59
60
61 // SpriteTexture.Load(graphics.GraphicsDevice, contentManager, "fileNames[0]", 8, 12, true, 1);
62 }
63
64 public void Animate(Vector2 drawSpot)
65 {
66 //character = new SpriteBatch(graphics.GraphicsDevice);
67 // "character" is the name of the sprite asset in the project.
68 Console.WriteLine(ph);
69 if(changedGraphic)
70 SpriteTexture.Load(character.GraphicsDevice, contentManager, ph, 8, 12, true, 1);
71 //viewport = graphics.GraphicsDevice.Viewport;
72 position = new Vector2(Player.Coordinates.X*Map.PixelsToUnitSquares, Player.Coordinates.Y*Map.PixelsToUnitSquares);//viewport.Width / 2, 0);//viewport.Height / 2f);
73 Console.WriteLine(drawSpot);
74 //character.Begin();
75 SpriteTexture.DrawFrame(character, drawSpot);
76 //character.End();
77 }
78
79 }
80 }
This page took 0.043426 seconds and 4 git commands to generate.