using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Content; using System; using System.Collections.Generic; using System.Text; using Sprint3_actual.Everything_NPC; using Sprint3_actual.SoundManagement; namespace Sprint3_actual { class Aquamentus : INPC { public Texture2D Texture { get; set; } private ISprite AquamentusSprite; private ISprite SmokeCloud; private ISprite StarEffect; private Rectangle posRect; private int spriteSpeed, attackCountdown; private bool moving, spawning; private int moveTimer, direction, spawnTimer; private Random r; private ActiveItems.IActiveItem f1, f2, f3; private bool removed; private room Room; private float life; private int canTakeDamage; public bool canTakeDirectDamage => true; public bool hasMultipleNodes => false; public Aquamentus(int spawnX, int spawnY, Texture2D fireballTexture, room room) { this.removed = false; Texture = fireballTexture; posRect = new Rectangle(spawnX, spawnY, 72, 96); AquamentusSprite = NPCSpriteFactory.Instance.CreateAquamentus(posRect.X, posRect.Y, this); SmokeCloud = NPCSpriteFactory.Instance.CreateSmokeCloud(posRect.X, posRect.Y, this); StarEffect = NPCSpriteFactory.Instance.CreateStarEffect(posRect.X, posRect.Y, this); attackCountdown = 1000; moveTimer = 100; r = new Random(); moving = false; spriteSpeed = 80; direction = -1; this.Room = room; life = 6.0f; canTakeDamage = 0; } public Rectangle getRect() { return posRect; } public void SetPosition(int x, int y) { posRect.X = x; posRect.Y = y; } public void DrawNPC() { AquamentusSprite.draw(); } public void UpdateNPC() { if (spawning) { this.spawnTimer += GlobalVars.gameTime.ElapsedGameTime.Milliseconds; if (this.spawnTimer > 1000) { spawning = false; spawnTimer = 0; } SmokeCloud.update(GlobalVars.gameTime); } else { AquamentusSprite.update(GlobalVars.gameTime); if (moveTimer == 0 || (!moving)) { moving = true; moveTimer = 100; int number = r.Next(1, 101); if (number <= 50) { direction = -1; } else { direction = 1; } } else { moveTimer -= 4; if (direction == -1) { posRect.X -= (int)(spriteSpeed * GlobalVars.gameTime.ElapsedGameTime.TotalSeconds); } else { posRect.X += (int)(spriteSpeed * GlobalVars.gameTime.ElapsedGameTime.TotalSeconds); } } if (canTakeDamage > 0) { canTakeDamage--; } attackCountdown -= 5; if (attackCountdown <= 0) { attackCountdown = 1000; attack(); SoundEngine.Instance.playBossRoar(); } } } public void Spawn() { spawning = true; } public void takeDamage(float damage) { if (canTakeDamage <= 0) { life -= damage; removed = (life <= 0.0); if(removed) { SoundEngine.Instance.playBossDeath(); Inventory.Instance.incrementKills(); Inventory.Instance.dropRank4(posRect, this.Room); } canTakeDamage = 15; } } public float Collide() { return 2.0f; } public bool IsRemoved() { return removed; } public bool IsSpawning() { return spawning; } public bool IsDead() { return false; } private void attack() { Vector2 AngleVector = new Vector2(-2, 1); Vector2 AngleVector1 = new Vector2(-2, -1); Vector2 AngleVector2 = new Vector2(-2, 0); f1 = new ActiveItems.Fireball(Texture, posRect.X - 18, posRect.Y - 8, AngleVector1, Room); f2 = new ActiveItems.Fireball(Texture, posRect.X - 18, posRect.Y + 23, AngleVector2, Room); f3 = new ActiveItems.Fireball(Texture, posRect.X - 18, posRect.Y + 51, AngleVector, Room); f1.ActiveItemLeft(); f2.ActiveItemLeft(); f3.ActiveItemLeft(); } } }