using GameLogic.Combat.Hero;
using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;

namespace GameLogic.Combat.CombatTool
{
    public class CombatHeroController
    {
        private BetterList<CombatHeroEntity> myHero = new BetterList<CombatHeroEntity>();
        private BetterList<CombatHeroEntity> enemyHero = new BetterList<CombatHeroEntity>();
        
        private BetterList<ILifetCycleHitPoint> myHeroHitPoint = new BetterList<ILifetCycleHitPoint>();
        private BetterList<ILifetCycleHitPoint> enemyHeroHitPoint = new BetterList<ILifetCycleHitPoint>();

        public void Update(float t)
        {
            for (int i = 0; i < myHero.Count; i++)
            {
                myHero[i].Update(t);
            }

            for (int i = 0; i < enemyHero.Count; i++)
            {
                enemyHero[i].Update(t);
            }
        }

        public void AddHero(CombatHeroEntity hero)
        {
            if (hero.IsEnemy)
            {
                enemyHero.Add(hero);
            }
            else
            {
                myHero.Add(hero);
            }
        }

        public void RemoveHero(CombatHeroEntity hero)
        {
            if (hero.IsEnemy)
            {
                enemyHero.Remove(hero);
            }
            else
            {
                myHero.Remove(hero);
            }
        }

        public void AddHeroHitPoint(bool isEnemy, ILifetCycleHitPoint hitPoint)
        {
            if (isEnemy)
            {
                myHeroHitPoint.Add(hitPoint);
            }
            else
            {
                enemyHeroHitPoint.Add(hitPoint);
            }
        }

        public void RemoveHeroHitPoint(bool isEnemy, ILifetCycleHitPoint hitPoint)
        {
            if (isEnemy)
            {
                myHeroHitPoint.Remove(hitPoint);
            }
            else
            {
                enemyHeroHitPoint.Remove(hitPoint);
            }
        }

        public void Dispose()
        {
            myHero.Dispose();
            enemyHero.Dispose();
        }

        public CombatHeroEntity[] GetHero(bool isEnemy)
        {
            if (isEnemy)
            {
                return enemyHero.ToArray();
            }
            else
            {
                return myHero.ToArray();
            }
        }

       
    }
}