using System.Collections.Generic;
using GameTimeLine.CustomizeTimeLogic;
using UnityEngine;
using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;

namespace GameLogic.Combat.Hero
{
    public class CombatHeroHitPoint : ILifetCycleHitPoint
    {
        public List<SpecialDotInfo> allSpecialDotInfo = new List<SpecialDotInfo>();

        public CombatHeroEntity combatHeroEntity;

        public ILifeCycle IfLifeCycle
        {
            get { return combatHeroEntity; }
        }

        public Vector3 Position
        {
            get { return _hitPointMono.transform.position; }
        }


        private HitPointMono _hitPointMono;

        public T This<T>()
        {
            return (T)(object)this;
        }

        public void Init(CombatHeroEntity combatHeroEntity, HitPointMono hitPointMono)
        {
            this.combatHeroEntity = combatHeroEntity;
            _hitPointMono = hitPointMono;
            SpecialDotMono[] specialDotMonos = combatHeroEntity.combatHeroGameObject.GameObjectPool.own
                .GetComponentsInChildren<SpecialDotMono>(true);
            for (int i = 0; i < specialDotMonos.Length; i++)
            {
                SpecialDotMono specialDotMono = specialDotMonos[i];
                SpecialDotInfo specialDotInfo = new SpecialDotInfo();
                specialDotInfo.dotName = specialDotMono.name;
                specialDotInfo.targetTran = specialDotMono.transform;
                specialDotInfo.heroEntity = combatHeroEntity;
                allSpecialDotInfo.Add(specialDotInfo);
            }
        }

        public SpecialDotInfo GetSpecialDotInfo(string specialDotName)
        {
            for (int i = 0; i < allSpecialDotInfo.Count; i++)
            {
                if (allSpecialDotInfo[i].dotName == specialDotName)
                {
                    return allSpecialDotInfo[i];
                }
            }

            return null;
        }
    }
}