Game-Design / Sprint3_actual / Everything_NPC / TimedFire.cs
TimedFire.cs
Raw
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.Everything_NPC
{
    public class TimedFire : INPC
    {
        private ISprite FireSprite;
        private Rectangle posRect;
        private bool removed;
        private int rectWH = 48;
        private int maxTime;
        private int timer;
        public bool canTakeDirectDamage => false;

        public bool hasMultipleNodes => false;

        public TimedFire(int spawnx, int spawny, int time)
        {
            this.removed = false;
            posRect = new Rectangle(spawnx, spawny, rectWH, rectWH);
            FireSprite = NPCSpriteFactory.Instance.CreateFire(posRect.X, posRect.Y, this);
            this.timer = 0;
            this.maxTime = time;
        }

        public Rectangle getRect()
        {
            return posRect;
        }

        public void SetPosition(int x, int y)
        {
            posRect.X = x;
            posRect.Y = y;
        }

        public void DrawNPC()
        {
            FireSprite.draw();
        }

        public void UpdateNPC()
        {
            FireSprite.update(GlobalVars.gameTime);
            this.timer += GlobalVars.gameTime.ElapsedGameTime.Milliseconds;
            if (this.timer > this.maxTime)
            {
                this.removed = true;
            }
        }

        public void Spawn()
        {
        }
        public void takeDamage(float damage)
        {
        }
        public float Collide()
        {
            return 0.5f;
        }

        public bool IsRemoved()
        {
            return removed;
        }

        public bool IsSpawning()
        {
            return false;
        }

        public bool IsDead()
        {
            return false;
        }

    }
}