Esempio n. 1
0
        public override void OnExecute()
        {
            try
            {
                //Log.Info("进入持续伤害的Execute");
                this.m_CurrentDamageValue = BuffDataCalculateHelper.CalculateCurrentData(this, this.BuffData);
                //强制类型转换为伤害Buff数据
                SustainDamageBuffData temp = (SustainDamageBuffData)this.BuffData;

                //TODO 对受方的伤害结算,此时finalDamageValue为最终值

                this.TheUnitBelongto.GetComponent <HeroDataComponent>().CurrentLifeValue -= this.m_CurrentDamageValue;
                Game.EventSystem.Run(EventIdType.ChangeHP, this.TheUnitBelongto.Id, -this.m_CurrentDamageValue);
                //Log.Info($"来自持续伤害ExeCute的数据:{this.currentDamageValue}");
                //设置下一个时间点
                this.m_SelfNextimer = TimeHelper.Now() + temp.WorkInternal;
                //Log.Info($"作用间隔为{selfNextimer - TimeHelper.Now()},持续时间为{temp.SustainTime},持续到{this.selfNextimer}");
                this.BuffState = BuffState.Running;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Esempio n. 2
0
        public override void OnUpdate()
        {
            //只有不是永久Buff的情况下才会执行Update判断
            if (this.BuffData.SustainTime + 1 > 0)
            {
                //Log.Info($"执行持续伤害的Update,当前时间是{TimeHelper.Now()}");
                if (TimeHelper.Now() > MaxLimitTime)
                {
                    this.BuffState = BuffState.Finished;
                    //Log.Info("持续伤害结束了");
                }
                else if (TimeHelper.Now() > this.m_SelfNextimer)
                {
                    try
                    {
                        this.m_CurrentDamageValue = BuffDataCalculateHelper.CalculateCurrentData(this, this.BuffData);
                        //强制类型转换为伤害Buff数据
                        SustainDamageBuffData temp = (SustainDamageBuffData)this.BuffData;

                        //TODO 对受方的伤害结算,此时finalDamageValue为最终值

                        this.TheUnitBelongto.GetComponent <HeroDataComponent>().CurrentLifeValue -= this.m_CurrentDamageValue;
                        Game.EventSystem.Run(EventIdType.ChangeHP, this.TheUnitBelongto.Id, -this.m_CurrentDamageValue);
                        //Log.Info($"来自持续伤害Update的数据:{this.currentDamageValue},结束时间为{MaxLimitTime},当前层数为{this.CurrentOverlay}");
                        //设置下一个时间点
                        this.m_SelfNextimer = TimeHelper.Now() + temp.WorkInternal;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                }
            }
        }
Esempio n. 3
0
        private void ExcuteDamage()
        {
            //强制类型转换为伤害Buff数据
            SustainDamageBuffData temp = (SustainDamageBuffData)this.BuffData;

            DamageData damageData = ReferencePool.Acquire <DamageData>().InitData(temp.BuffDamageTypes,
                                                                                  BuffDataCalculateHelper.CalculateCurrentData(this, this.BuffData), this.TheUnitFrom, this.TheUnitBelongto);

            damageData.DamageValue *= temp.DamageFix;

            this.TheUnitFrom.GetComponent <CastDamageComponent>().BaptismDamageData(damageData);

            float finalDamage = this.TheUnitBelongto.GetComponent <ReceiveDamageComponent>().BaptismDamageData(damageData);

            if (finalDamage >= 0)
            {
                this.TheUnitBelongto.GetComponent <HeroDataComponent>().NumericComponent.ApplyChange(NumericType.Hp, -finalDamage);
                //抛出伤害事件
                Game.Scene.GetComponent <BattleEventSystem>().Run($"{EventIdType.ExcuteDamage}{this.TheUnitFrom.Id}", damageData);
                //抛出受伤事件
                Game.Scene.GetComponent <BattleEventSystem>().Run($"{EventIdType.TakeDamage}{this.GetBuffTarget().Id}", damageData);
            }

            //设置下一个时间点
            this.m_SelfNextimer = TimeHelper.Now() + temp.WorkInternal;
        }