using CombatLibrary.CombatLibrary.CombatCore.CustomizeTimeLogic.FxLogic;
using GameLogic.Combat.Buff;
using GameLogic.Combat.CombatTool;
using GameLogic.Combat.Hero;
using UnityEngine;
using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
namespace GameLogic.Combat.Skill
{
    /// 
    /// 飞出{0}道巨龙,对敌人照成{1}火系伤害
    /// 如果敌人处于灼痛中对敌人照成胆摄,眩晕敌人2秒
    /// 飞龙数量+1,并对敌人施加1层灼烧
    ///飞龙命中目标后引发天雷,对敌人额外照成100%伤害
    /// 
    public class S1402 : SkillBasic
    {
        private static int[] zdPosIndex = new int[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 };
        protected override void ProUseSkill()
        {
            CombatHeroHitPoint combatHeroHitPoint = CombatHeroEntity.CombatAIBasic.currFocusTarget
                .GetThis()
                .GetMainHotPoin();
            BetterList currTarget = new BetterList();
            currTarget.Add(combatHeroHitPoint);
            ballisticsCount = (int)effectValue[0];
            for (int i = 0; i < effectValue[0]; i++)
            {
                float x = CombatCalculateTool.Instance.GetOdd(-100, 100);
                x = (x) / 200;
                Vector3 pos = new Vector3(x, 0.7f, -2f);
                pos = CombatHeroEntity.GameObject.transform.TransformPoint(pos);
                // SpecialDotInfo specialDotInfo = CombatHeroEntity.GetSpecialDotInfo(pos);
                ActivationTimeLineData("1402_fashe", currTarget: currTarget,
                    customizePos: new Vector3[] { pos }, indexCount: i, startTime: -0.2f * i);
            }
            ActivationTimeLineData("1402");
        }
        protected override void ProTimelineFxLogicInit(string groupName, ITimelineFxLogic timelineFxLogic,
            TriggerData triggerData)
        {
        }
        protected override void ProDefaultTimeLineTrigger(string groupName, CombatHeroHitPoint targetEntity,
            ITimelineFxLogic timelineFxLogic,
            TriggerData triggerData, ISkillFeatures skillFeatures)
        {
            long v = CombatCalculateTool.Instance.GetVlaueRatioForLong(CombatHeroEntity.CurrCombatHeroInfo.attack.Value,
                effectValue[1]);
            HarmReturnInfo harmReturnInfo = CombatCalculateTool.Instance.Harm(CombatHeroEntity, targetEntity, v,
                AttType.Skill, triggerData, wuXingType, skillFeatures,
                HarmType.Default);
            if (harmReturnInfo.isHitHero)
            {
                if (SelfSkillConfig.level > 3)
                {
                    BuffInfo buffInfo = BuffInfo.GetBuffInfo(10051, 1, this); //试驾灼热
                    targetEntity.combatHeroEntity.BuffControl.AddBuff(CombatHeroEntity, buffInfo);
                }
                if (SelfSkillConfig.level > 1)
                {
                    b_1005 b1010 = targetEntity.combatHeroEntity.BuffControl.GetBuffBasicForType();
                    if (b1010 != null)
                    {
                        int odd = CombatCalculateTool.Instance.GetOdd(0, 100);
                        int currOdd = (int)(b1010.buffCount * effectValue[2]);
                        if (currOdd <= odd)
                        {
                            BuffInfo buffInfo = BuffInfo.GetBuffInfo(10061, effectValue[3], 1, this); //眩晕敌人
                            targetEntity.combatHeroEntity.BuffControl.AddBuff(CombatHeroEntity, buffInfo);
                        }
                    }
                }
                if (SelfSkillConfig.level > 5)
                {
                    long v2 = CombatCalculateTool.Instance.GetVlaueRatioForLong(
                        CombatHeroEntity.CurrCombatHeroInfo.attack.Value,
                        effectValue[4]);
                    CombatCalculateTool.Instance.Harm(CombatHeroEntity, targetEntity, v2,
                        AttType.Skill, triggerData, wuXingType, skillFeatures,
                        HarmType.Default);
                }
            }
        }
    }
}