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 RightMoblinBoomerangSprite : AItemSprites { private Texture2D Texture; private int SpriteWidth; private int SpriteHeight; private int SpriteX; private int SpriteY; private int X; private int Y; private int removeCounter; private bool isReturning; private SpriteEffects horiz, vert; private int frameCounter; public RightMoblinBoomerangSprite(Texture2D texture, int x, int y) { IsRemoved = false; SpriteX = x; SpriteY = y; X = x; Y = y; Texture = texture; SpriteHeight = 31; SpriteWidth = 16; SpriteX = 609; SpriteY = 1160; removeCounter = 50; isReturning = false; horiz = SpriteEffects.None; vert = SpriteEffects.None; frameCounter = 0; } public override void draw() { Rectangle sourceRectangle = new Rectangle(SpriteX, SpriteY, SpriteWidth, SpriteHeight); Rectangle destinationRectangle = new Rectangle(X - 8, Y - 2, SpriteWidth, SpriteHeight); GlobalVars.spriteBatch.Draw(Texture, destinationRectangle, sourceRectangle, Color.White, 0f, Vector2.Zero, horiz | vert, 0f); } public override void update(GameTime gameTime) { removeCounter--; if (frameCounter == 64) { frameCounter = 0; } if (frameCounter == 0 || frameCounter == 8 || frameCounter == 32 || frameCounter == 40) { SpriteX += 9; } else if (frameCounter == 16 || frameCounter == 24 || frameCounter == 48 || frameCounter == 56) { SpriteX -= 9; } if (frameCounter == 16) { vert = SpriteEffects.FlipHorizontally; } if (frameCounter == 32) { horiz = SpriteEffects.FlipVertically; } if (frameCounter == 48) { vert = SpriteEffects.None; } if (frameCounter == 0) { horiz = SpriteEffects.None; } frameCounter++; if (!isReturning) { X += (int)(GlobalVars.gameTime.ElapsedGameTime.TotalMilliseconds * .3); } else { X -= (int)(GlobalVars.gameTime.ElapsedGameTime.TotalMilliseconds * .3); } if (removeCounter == 25) { isReturning = true; } if (removeCounter == 0) { IsRemoved = true; } } } }