using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; using System.Text; namespace Sprint3_actual.ActiveItems { class ActiveBombSprite : AItemSprites { public Texture2D Texture { get; set; } private int Sprite1Width; private int Sprite1Height; private int Sprite1X; private int SpriteY; private int SmokeWidth; private int SmokeHeight; private int Sprite2X; private int X; private int Y; private bool itsLit; private bool lessSmoke; private bool barelyAnySmoke; private int timer; private const int multiplier = 3; private const int litshift = 8; private const int smokeshift = 34; private const int elseshift = 17; public ActiveBombSprite(Vector2 pos, Texture2D texture) { IsRemoved = false; X = (int)pos.X; Y = (int)pos.Y; Texture = texture; Sprite1Height = 15; Sprite1Width = 8; Sprite1X = 129; SpriteY = 185; SmokeHeight = 16; SmokeWidth = 16; Sprite2X = 138; barelyAnySmoke = true; lessSmoke = true; itsLit = true; timer = 50; } public override void draw() { Rectangle srcRectangle; Rectangle destRectangle; if (itsLit) { srcRectangle = new Rectangle(Sprite1X, SpriteY, Sprite1Width, Sprite1Height); destRectangle = new Rectangle(X+litshift, Y, multiplier*Sprite1Width, multiplier*Sprite1Height); } else if(lessSmoke) { srcRectangle = new Rectangle(Sprite2X, SpriteY, SmokeWidth, SmokeHeight); destRectangle = new Rectangle(X, Y, multiplier * SmokeWidth, multiplier * SmokeHeight); } else if (barelyAnySmoke) { srcRectangle = new Rectangle(Sprite2X + smokeshift, SpriteY, SmokeWidth, SmokeHeight); destRectangle = new Rectangle(X, Y, multiplier * SmokeWidth, multiplier * SmokeHeight); } else { srcRectangle = new Rectangle(Sprite2X + elseshift, SpriteY, SmokeWidth, SmokeHeight); destRectangle = new Rectangle(X, Y, multiplier * SmokeWidth, multiplier * SmokeHeight); } GlobalVars.spriteBatch.Draw(Texture, destRectangle, srcRectangle, Color.White); } public override void update(GameTime gameTime) { //Check to see if these are also magic numbers timer--; if(timer < 10 && timer > 5) { itsLit = false; } if(timer <= 5 && timer > 3) { lessSmoke = false; } if(timer <= 3) { barelyAnySmoke = false; } if(timer == 0) { IsRemoved = true; } } } }