using System; using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework; using Sprint3_actual.BorderElements; using Sprint3_actual.Text; using Sprint3_actual.SoundManagement; using Sprint3_actual.Blocks; namespace Sprint3_actual.Everything_NPC.OldWomanPhases { class FallingBlockPhase : IPhase { private room room; private Game1 game; private int roomXMod, roomYMod, blockX; private bool finished; private int currentTime, blockTimer; private const int phaseTime = 14000; private const int textFinishTime = 4000; private const int blockCooldown = 100; private bool textFinished; private IBorder textBox; private Random rand; public FallingBlockPhase(room room, Game1 game, int roomXMod, int roomYMod) { this.room = room; this.game = game; this.roomXMod = roomXMod; this.roomYMod = roomYMod; this.textBox = BorderElementsFactory.Instance.CreateTextBox(96 + roomXMod, 432 + roomYMod); this.currentTime = 0; room.Addons[0] = textBox; rand = new Random(); this.finished = false; room.TextList.Add(TextFactory.Instance.CreateText(18, 225 + this.roomXMod, 468 + this.roomYMod)); } public void Update(GameTime gameTime) { this.currentTime += GlobalVars.gameTime.ElapsedGameTime.Milliseconds; if (!textFinished) { if (currentTime > textFinishTime) { room.Addons[0] = null; textFinished = true; SoundEngine.Instance.playFlameShot(); for (int i = 0; i < 12; i++) { room.NPCList.Add(new TimedFire(96 + this.roomXMod + i * 48, 96 + this.roomYMod + 6 * 48, phaseTime - textFinishTime)); } } } else { this.blockTimer += GlobalVars.gameTime.ElapsedGameTime.Milliseconds; if (this.currentTime < phaseTime) { if (blockTimer > blockCooldown) { blockX = roomXMod + rand.Next(0, 12) * 48; room.BlockList.Add(new FallingBlock(96 + blockX, roomYMod + 48 + 96)); this.blockTimer = 0; } } else { SoundEngine.Instance.playFlameShot(); finished = true; } } } public bool IsFinished() { return this.finished; } } }