From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/Buff/XBuffLifeSteal.cs | 93 ++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/Buff/XBuffLifeSteal.cs (limited to 'Client/Assets/Scripts/XMainClient/Buff/XBuffLifeSteal.cs') diff --git a/Client/Assets/Scripts/XMainClient/Buff/XBuffLifeSteal.cs b/Client/Assets/Scripts/XMainClient/Buff/XBuffLifeSteal.cs new file mode 100644 index 00000000..a2250c2e --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Buff/XBuffLifeSteal.cs @@ -0,0 +1,93 @@ +using System; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XBuffLifeSteal : BuffEffect + { + private float m_Ratio; + + private float m_UpperBoundRatio; + + private double m_StealUpperBound = 0.0; + + private XBuff m_Buff; + + private XEntity m_Entity; + + public static bool TryCreate(BuffTable.RowData rowData, XBuff buff) + { + bool flag = rowData.LifeSteal[0] == 0f; + bool result; + if (flag) + { + result = false; + } + else + { + buff.AddEffect(new XBuffLifeSteal(ref rowData.LifeSteal, buff)); + result = true; + } + return result; + } + + public XBuffLifeSteal(ref SeqRef data, XBuff _Buff) + { + this.m_Ratio = data[0]; + this.m_Buff = _Buff; + this.m_UpperBoundRatio = data[1]; + } + + public override void OnAdd(XEntity entity, CombatEffectHelper pEffectHelper) + { + this.m_Entity = entity; + bool flag = this.m_UpperBoundRatio > 0f && entity != null && entity.Attributes != null; + if (flag) + { + this.m_StealUpperBound = entity.Attributes.GetAttr(XAttributeDefine.XAttr_MaxHP_Total) * (double)this.m_UpperBoundRatio; + } + } + + public override void OnRemove(XEntity entity, bool IsReplaced) + { + } + + public override void OnCastDamage(HurtInfo rawInput, ProjectDamageResult result) + { + bool flag = rawInput.SkillID == 0u; + if (!flag) + { + bool flag2 = this.m_Buff.RelevantSkills != null && this.m_Buff.RelevantSkills.Count != 0; + if (flag2) + { + bool flag3 = !this.m_Buff.RelevantSkills.Contains(rawInput.SkillID); + if (flag3) + { + return; + } + } + bool accept = result.Accept; + if (accept) + { + double num = result.Value * (double)this.m_Ratio; + bool flag4 = this.m_UpperBoundRatio > 0f; + if (flag4) + { + num = Math.Min(num, this.m_StealUpperBound); + this.m_StealUpperBound -= num; + } + bool flag5 = num > 0.0; + if (flag5) + { + XAttrChangeEventArgs @event = XEventPool.GetEvent(); + @event.AttrKey = XAttributeDefine.XAttr_CurrentHP_Basic; + @event.DeltaValue = num; + @event.Firer = this.m_Entity; + @event.bShowHUD = !this.m_Buff.BuffInfo.DontShowText; + XSingleton.singleton.FireEvent(@event); + } + } + } + } + } +} -- cgit v1.1-26-g67d0