12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using UnityEngine;
- using XGame.Database;
- using XGame.Framework.Time;
- namespace FL.Battle.Buffs
- {
- public class DotDebuff : Buff
- {
- /// <summary>
- /// buff事件触发定时器
- /// dot类型使用
- /// </summary>
- private ITimer _tickTimer;
- protected override void OnInited()
- {
- _tickTimer = Context.Time.AddLooperTimer(Table.BuffTypeNum[1], OnBuffTick);
- }
- protected override void OnDispose()
- {
- _tickTimer?.Cancel();
- _tickTimer = null;
- }
- private void OnBuffTick(int times)
- {
- // 已经死亡
- if (Context.Entity.IsDead)
- return;
- var damage = Mathf.RoundToInt(Layers * Table.BuffTypeNum[0].ToRealFloat() * Context.Entity.Attr.HpLimit);
- Context.Calculation.Damage(-damage, ElementType);
- //Log.Debug($"OnBuffTick EntityId:{Context.Entity.EntityId} BuffId:{buff.TableId} Overlay:{buff.Overlays} Damage:{damage}");
- }
- public bool TryTickLayer5()
- {
- // 毒的5层直接引爆伤害
- if (ElementType != EElementType.Poison || Layers < LayerLimit)
- return false;
- //伤害:dot总跳数*层数*单层伤害值
- var count = Duration / Table.BuffTypeNum[1];
- var damage = Mathf.RoundToInt(count * Layers * Table.BuffTypeNum[0].ToRealFloat() * Context.Entity.Attr.HpLimit);
- Context.Calculation.Damage(-damage, ElementType);
- Listener?.OnCompleted(TableId);
- return true;
- }
- }
- }
|