using Microsoft.Xna.Framework; using System; using Sprint3_actual.Everything_NPC; using Sprint3_actual.SoundManagement; using Sprint3_actual.Everything_NPC.OldWomanPhases; namespace Sprint3_actual { class OldWoman : INPC { private ISprite Sprite; private ISprite SmokeCloud; private ISprite StarEffect; private Rectangle posRect; private bool spawning, death; private int spawnTimer, deathTimer; private Random r; private int phaseOption; private bool removed; private const int posrectWH = 48; private room room; private Game1 game; private BossHealthHandler healthHandler; private int roomXMod, roomYMod; private bool onCooldown, inEndPhase; private IPhase currentPhase; public bool canTakeDirectDamage => false; public bool hasMultipleNodes => false; public OldWoman(int spawnX, int spawnY, room room, Game1 game) { this.removed = false; posRect = new Rectangle(spawnX, spawnY, posrectWH, posrectWH); Sprite = NPCSpriteFactory.Instance.CreateOldWoman(posRect.X, posRect.Y, this); SmokeCloud = NPCSpriteFactory.Instance.CreateSmokeCloud(posRect.X, posRect.Y, this); StarEffect = NPCSpriteFactory.Instance.CreateStarEffect(posRect.X, posRect.Y, this); r = new Random(); spawning = true; spawnTimer = 0; death = false; deathTimer = 0; this.room = room; this.game = game; this.roomXMod = (5 + 5 - GlobalVars.levelWidth) * GlobalVars.screenWidth; this.roomYMod = (6 + 2 - GlobalVars.levelHeight) * GlobalVars.viewBoxHeight + 168; this.currentPhase = new IntroPhase(this.room, this.game, roomXMod, roomYMod); this.onCooldown = true; this.healthHandler = new BossHealthHandler(this.room, this.game, roomXMod, roomYMod); } public Rectangle getRect() { return this.posRect; } public void SetPosition(int x, int y) { removed = true; } public void DrawNPC() { if (spawning) { SmokeCloud.draw(); } else if(death) { StarEffect.draw(); } else { Sprite.draw(); } } public void UpdateNPC() { if (spawning) { this.spawnTimer += GlobalVars.gameTime.ElapsedGameTime.Milliseconds; SmokeCloud.update(GlobalVars.gameTime); if (this.spawnTimer > 1000) { spawning = false; spawnTimer = 0; } currentPhase.Update(GlobalVars.gameTime); } else if (death) { if (deathTimer == 0) { SoundEngine.Instance.playEnemyDeath(); } this.deathTimer += GlobalVars.gameTime.ElapsedGameTime.Milliseconds; if(this.deathTimer > 600) { removed = true; } StarEffect.update(GlobalVars.gameTime); } else { currentPhase.Update(GlobalVars.gameTime); if(currentPhase.IsFinished() && !inEndPhase) { if (healthHandler.ZeroHealth() && !inEndPhase) { currentPhase = new EndPhase(this.room, this.game, roomXMod, roomYMod, this); inEndPhase = true; } else if (onCooldown) { this.phaseOption = r.Next(0, 3); if(phaseOption == 0) { currentPhase = new ElectrifyPhase(this.room, this.game, roomXMod, roomYMod); } else if(phaseOption == 1) { currentPhase = new SpikePhase(this.room, this.game, roomXMod, roomYMod); } else { currentPhase = new FallingBlockPhase(this.room, this.game, roomXMod, roomYMod); } onCooldown = false; } else { currentPhase = new DamagePhase(this.room, this.game, roomXMod, roomYMod, this); onCooldown = true; } } Sprite.update(GlobalVars.gameTime); } } public void Spawn() { spawning = true; } public void takeDamage(float damage) { healthHandler.TakeDamage(); } public float Collide() { return 0.5f; } public bool IsRemoved() { return removed; } public bool IsSpawning() { return spawning; } public bool IsDead() { return death; } } }