using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Sprint2_actual.StateFiles; using System; using System.Collections.Generic; using System.Text; namespace Sprint2_actual.ActiveItems { class LeftArrowSprite : AItemSprites { public Texture2D Texture { get; set; } public int SpriteWidth { get; set; } private int SpriteHeight { get; set; } public int SpriteX { get; set; } public int SpriteY { get; set; } private int X; private int Y; private int removeCounter; private bool isFlying; public LeftArrowSprite(Vector2 pos, Texture2D texture) { IsRemoved = false; X = (int)pos.X; Y = (int)pos.Y; Texture = texture; SpriteHeight = 5; SpriteWidth = 16; SpriteX = 10; SpriteY = 190; removeCounter = 50; isFlying = true; } public override void draw() { Rectangle sourceRectangle; Rectangle destinationRectangle; if (isFlying) { sourceRectangle = new Rectangle(SpriteX, SpriteY, SpriteWidth, SpriteHeight); destinationRectangle = new Rectangle(X - 8, Y - 2, 2 * SpriteWidth, 2 * SpriteHeight); } else { sourceRectangle = new Rectangle(53, 189, 8, 8); destinationRectangle = new Rectangle(X - 8, Y - 2, 2 * 8, 2 * 8); } GlobalVars.spriteBatch.Draw(Texture, destinationRectangle, sourceRectangle, Color.White, 0f, Vector2.Zero, SpriteEffects.FlipHorizontally, 0f); } public override void update(GameTime gameTime) { if (isFlying) { X -= (int)(gameTime.ElapsedGameTime.TotalMilliseconds * 0.5); } removeCounter--; if (removeCounter == 0) { IsRemoved = true; } if (removeCounter < 10) { isFlying = false; } } } }