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.ActiveItems; using Sprint3_actual.Everything_NPC; using Sprint3_actual.SoundManagement; namespace Sprint3_actual { public class StoneStatueRight : INPC { private enum state { Down, Up, Right, Left } private ISprite StoneStatueSprite; private ISprite SmokeCloud; private Rectangle posRect; private int attackCountdown; private bool spawning; private int spawnTimer; private Random r; private IActiveItem Fireball; private Texture2D texture; private bool removed; private const int posrectWH = 48; private room Room; private Game1 game; public bool hasMultipleNodes => false; public bool canTakeDirectDamage => false; public StoneStatueRight(int spawnX, int spawnY, Texture2D fireballTexture, Game1 game) { this.game = game; this.removed = false; posRect = new Rectangle(spawnX, spawnY, posrectWH, posrectWH); StoneStatueSprite = NPCSpriteFactory.Instance.CreateStoneStatueRight(posRect.X, posRect.Y, this); SmokeCloud = NPCSpriteFactory.Instance.CreateSmokeCloud(posRect.X, posRect.Y, this); r = new Random(); attackCountdown = r.Next(400, 500); texture = fireballTexture; spawning = true; spawnTimer = 0; this.Room = game.currentRoom; } public Rectangle getRect() { return posRect; } public void SetPosition(int x, int y) { posRect.X = x; posRect.Y = y; } public void DrawNPC() { if (spawning) { SmokeCloud.draw(); } else { StoneStatueSprite.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 { attackCountdown -= 5; if (attackCountdown <= 0) { attackCountdown = r.Next(400, 500); attack(); } StoneStatueSprite.update(GlobalVars.gameTime); } } public void Spawn() { spawning = true; } public void takeDamage(float damage) { //NO-OP } public float Collide() { return 0.0f; } public bool IsRemoved() { return removed; } public bool IsSpawning() { return spawning; } public bool IsDead() { return false; } private void attack() { Vector2 temp = game.Player.Position(); Vector2 AngleVector = new Vector2(temp.X + 12 - posRect.X, temp.Y + 12 - posRect.Y); AngleVector.Normalize(); Fireball = new Dungeon2Fireball(texture, posRect.X + 16, posRect.Y + 16, AngleVector, game.currentRoom); Fireball.ActiveItemLeft(); } } }