using ActionGame.GameArtifacts.Models.Characters;
using ActionGame.GameArtifacts.Models.Game;
using ActionGame.GameArtifacts.Operators.Items;
using ActionGame.RawResources.Manager;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;

namespace ActionGame.GameArtifacts.Intelligence.EnemyAttack
{
    public class FireThrowerAttack : IEnemyAttack
    {
        private IBattleObject user;
        private IRawContentManager rawContentManager;
        private GameData gameData;
        private Double attackSpeed;

        private TimeSpan lastAttack;


        public FireThrowerAttack(IBattleObject user, Double attackSpeed, IRawContentManager rawContentManager, GameData gameData)
        {
            this.user = user;
            this.rawContentManager = rawContentManager;
            this.gameData = gameData;
            this.attackSpeed = attackSpeed;
        }


        public void Act(GameTime gameTime)
        {
            if (lastAttack == null)
            {
                lastAttack = gameTime.TotalGameTime;
            }

            if ((gameTime.TotalGameTime - lastAttack).TotalSeconds > attackSpeed)
            {
                IList<IBattleObject> currentEnemies = new List<IBattleObject>();
                foreach (Enemy enemy in gameData.GameState.ActiveEnemies) currentEnemies.Add(enemy);

                FireThrower fireThrower = new FireThrower(rawContentManager, gameData, true, user.CharacterStats.Attack, currentEnemies);
                fireThrower.Do(this.user);

                lastAttack = gameTime.TotalGameTime;
            }
        }



    }
}
