using Microsoft.Xna.Framework.Graphics; using Sprint3_actual.StateFiles; using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using System.Text; using Sprint3_actual.SoundManagement; using Sprint3_actual.Everything_NPC; namespace Sprint3_actual.ActiveItems { public class MiniLightning : IActiveItem { private room room; public int ItemX; public int ItemY; private Rectangle itemRectangle; private bool hasCollided; private bool Removed; private int removeCounter; private const double speedmultiplier = 0.25; private const int removeTime = 120; private enum Direction { Up, Down, Left, Right } private Direction direction; private AItemSprites ItemSprite; public MiniLightning(int xPos, int yPos, room room) { this.room = room; Removed = true; hasCollided = false; ItemX = xPos+12; ItemY = yPos+12; removeCounter = removeTime; itemRectangle = new Rectangle(ItemX, ItemY, 24, 24); ItemSprite = new MiniLightningSprite(this, NPCSpriteFactory.Instance.CreateMiniLightning()); } public void ActiveItemDown() { if (Removed) { direction = Direction.Down; Removed = false; hasCollided = false; room.EnemyItems.Add(this); } } public void ActiveItemLeft() { if (Removed) { direction = Direction.Left; Removed = false; hasCollided = false; room.EnemyItems.Add(this); } } public void ActiveItemRight() { if (Removed) { direction = Direction.Right; Removed = false; hasCollided = false; room.EnemyItems.Add(this); } } public void ActiveItemUp() { if (Removed) { direction = Direction.Up; Removed = false; hasCollided = false; room.EnemyItems.Add(this); } } public Rectangle PositionRectangle() { return itemRectangle; } public float Collide() { //hasCollided = true; return 2.0f; } public bool HasCollided() { return hasCollided; } public void Draw() { if (!Removed) ItemSprite.draw(); } public bool IsRemoved() { return Removed; } public void Update() { if (!Removed) { if (!hasCollided) { if (direction == Direction.Up) { itemRectangle.Y -= (int)(GlobalVars.gameTime.ElapsedGameTime.TotalMilliseconds * speedmultiplier); } else if (direction == Direction.Down) { itemRectangle.Y += (int)(GlobalVars.gameTime.ElapsedGameTime.TotalMilliseconds * speedmultiplier); } else if (direction == Direction.Left) { itemRectangle.X -= (int)(GlobalVars.gameTime.ElapsedGameTime.TotalMilliseconds * speedmultiplier); } else { itemRectangle.X += (int)(GlobalVars.gameTime.ElapsedGameTime.TotalMilliseconds * speedmultiplier); } } ItemSprite.update(GlobalVars.gameTime); } removeCounter--; if (removeCounter == 0) { Removed = true; hasCollided = false; itemRectangle = Rectangle.Empty; } } public void Remove() { Removed = true; } public void ItemSound() { } } }