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}次,每次击中消耗一层感电额外照成{3}伤害。引雷可以击中弹道.持续{4}秒
    /// 
    public class S9053 : SkillBasic
    {
        private float _currTime;
        private int _hitCount;
        private bool _isUpdate;
        private float _jianGe;
        protected override void ProUseSkill()
        {
            ballisticsCount = (int)effectValue[0];
        }
        protected override void ProDefaultTimeLineTrigger(string groupName, CombatHeroHitPoint targetEntity,
            ITimelineFxLogic timelineFxLogic,
            TriggerData triggerData, ISkillFeatures skillFeatures)
        {
            float harmBl = effectValue[1];
            b_1018 b1018 = targetEntity.combatHeroEntity.BuffControl.GetBuffBasicForType();
            if (b1018 != null)//消耗一层感电,额外照成伤害
            {
                b1018.ReduceCount(1);
                harmBl += effectValue[3];
            }
            long v = CombatCalculateTool.Instance.GetVlaueRatioForLong(CombatHeroEntity.CurrCombatHeroInfo.attack.Value,
                harmBl);
            HarmReturnInfo harmReturnInfo = CombatCalculateTool.Instance.Harm(CombatHeroEntity, targetEntity, v,
                AttType.Skill, triggerData,
                wuXingType, skillFeatures,
                HarmType.Default);
            // if (harmReturnInfo.isHitHero)
            // {
            //     BuffInfo buffInfo = BuffInfo.GetBuffInfo(10181, 1);
            //     targetEntity.combatHeroEntity.BuffControl.AddBuff(CombatHeroEntity, buffInfo);
            // }
        }
        private void SetJianGe()
        {
            _jianGe = CombatCalculateTool.Instance.GetOdd(20, 100) / 100f;
        }
        protected override void ProCombatUpdate(float time)
        {
            if (!_isUpdate)
            {
                return;
            }
            _currTime += time;
            if (_currTime >= _jianGe)
            {
                _currTime = 0;
                SetJianGe();
                //发射一道闪电
                int odds = CombatCalculateTool.Instance.GetOdd(0, 100);
                if (odds <= effectValue[0])
                {
                    //击中目标
                }
            }
        }
    }
}