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/XBuffReduceDamage.cs | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/Buff/XBuffReduceDamage.cs (limited to 'Client/Assets/Scripts/XMainClient/Buff/XBuffReduceDamage.cs') diff --git a/Client/Assets/Scripts/XMainClient/Buff/XBuffReduceDamage.cs b/Client/Assets/Scripts/XMainClient/Buff/XBuffReduceDamage.cs new file mode 100644 index 00000000..e58fb48d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Buff/XBuffReduceDamage.cs @@ -0,0 +1,79 @@ +using System; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XBuffReduceDamage : BuffEffect + { + public override XBuffEffectPrioriy Priority + { + get + { + return XBuffEffectPrioriy.BEP_ReduceDamage; + } + } + + private int _buffID; + + private XPieceWiseDataMgr m_Data = new XPieceWiseDataMgr(); + + private XEntity _entity; + + public static bool TryCreate(BuffTable.RowData rowData, XBuff buff) + { + bool flag = rowData.DamageReduce.Count == 0; + bool result; + if (flag) + { + result = false; + } + else + { + buff.AddEffect(new XBuffReduceDamage(ref rowData.DamageReduce, rowData.BuffID)); + result = true; + } + return result; + } + + public XBuffReduceDamage(ref SeqListRef reducePecents, int buffID) + { + this._buffID = buffID; + this.m_Data.SetRange(0.0, 1.0, 1.0, 0.0); + this.m_Data.Init(ref reducePecents); + } + + public override void OnAdd(XEntity entity, CombatEffectHelper pEffectHelper) + { + this._entity = entity; + } + + public override void OnRemove(XEntity entity, bool IsReplaced) + { + } + + public override void OnAttributeChanged(XAttrChangeEventArgs e) + { + bool flag = e.AttrKey == XAttributeDefine.XAttr_CurrentHP_Basic; + if (flag) + { + bool flag2 = this.m_Data.GetData(this._entity.Attributes.HPPercent) < 1E-06; + if (flag2) + { + XBuffRemoveEventArgs @event = XEventPool.GetEvent(); + @event.xBuffID = this._buffID; + @event.Firer = this._entity; + XSingleton.singleton.FireEvent(@event); + XSingleton.singleton.AddGreenLog("delete reduce damage buff", null, null, null, null, null); + } + } + } + + public override void OnBuffEffect(HurtInfo rawInput, ProjectDamageResult result) + { + int num = (int)result.Value; + double hppercent = rawInput.Target.Attributes.HPPercent; + result.Value *= 1.0 - this.m_Data.GetData(hppercent); + int num2 = (int)result.Value; + } + } +} -- cgit v1.1-26-g67d0