using ActionGame.GameArtifacts.Models.Characters;
using ActionGame.GameArtifacts.Models.Items;
using ActionGame.GameArtifacts.Models.Maps;
using ActionGame.GameArtifacts.Models.WeaponSprites;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;


namespace ActionGame.GameArtifacts.Models.Game
{
    public class GameState
    {
        public Player Player { get; set; }
        public VariableState VariableState { get; set; }
        public IList<NonPlayerCharacter> ActiveNonPlayerCharacters { get; private set; }
        public IList<Door> ActiveDoors { get; private set; }
        public IList<IWeaponSprite> ActiveWeaponSprites { get; private set; }
        public IList<Enemy> ActiveEnemies { get; private set; }
        public IList<IWeaponSprite> ActiveDisplaySprites { get; private set; }
        public IList<ItemSprite> ActiveItemSprites { get; private set; }

        public NonPlayerCharacter ActivatedNonPlayerCharacter;
        public PlotItem ActivatedPlotItem;
        

        public GameState()
        {
            this.VariableState = new VariableState();
            this.ActiveNonPlayerCharacters = new List<NonPlayerCharacter>();
            this.ActiveDoors = new List<Door>();
            this.ActiveWeaponSprites = new List<IWeaponSprite>();
            this.ActiveEnemies = new List<Enemy>();
            this.ActiveDisplaySprites = new List<IWeaponSprite>();
            this.ActiveItemSprites = new List<ItemSprite>();
        }


        public Boolean IsPlotActive()
        {
            return ((this.ActivatedNonPlayerCharacter != null) || (this.ActivatedPlotItem != null));
        }


        public IList<IBattleObject> GetBattleObjectsInArea(Rectangle rect)
        {
            IList<IBattleObject> battleObjects = new List<IBattleObject>();

            //player
            if (rect.Intersects(Player.GetDamageCollisionArea())) battleObjects.Add(Player);

            //enemies
            foreach(Enemy enemy in ActiveEnemies)
            {
                if (rect.Intersects(enemy.GetDamageCollisionArea())) battleObjects.Add(enemy);
            }

            return battleObjects;
        }

    }
}
