|
|
@@ -64,6 +64,12 @@ namespace ET
|
|
|
this[nt] = value;
|
|
|
}
|
|
|
|
|
|
+ public void SetNoEvent(int numericType, long value)
|
|
|
+ {
|
|
|
+ this.Insert(numericType,value,false);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public long this[int numericType]
|
|
|
{
|
|
|
get
|
|
|
@@ -72,18 +78,39 @@ namespace ET
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
- long v = this.GetByKey(numericType);
|
|
|
- if (v == value)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+
|
|
|
+ this.Insert(numericType,value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Insert(int numericType, long value,bool isPublicEvent = true)
|
|
|
+ {
|
|
|
+ long oldValue = this.GetByKey(numericType);
|
|
|
+ if (oldValue == value)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- NumericDic[numericType] = value;
|
|
|
+ NumericDic[numericType] = value;
|
|
|
|
|
|
- Update(numericType);
|
|
|
+ if (numericType >= NumericType.Max)
|
|
|
+ {
|
|
|
+ Update(numericType,isPublicEvent);
|
|
|
+ return;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ if (isPublicEvent)
|
|
|
+ {
|
|
|
+ Game.EventSystem.Publish(new EventType.NumbericChange()
|
|
|
+ {
|
|
|
+ Parent = this.Parent,
|
|
|
+ NumericType = numericType,
|
|
|
+ Old = oldValue,
|
|
|
+ New = value
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private long GetByKey(int key)
|
|
|
{
|
|
|
long value = 0;
|
|
|
@@ -91,12 +118,8 @@ namespace ET
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
- public void Update(int numericType)
|
|
|
+ public void Update(int numericType,bool isPublicEvent)
|
|
|
{
|
|
|
- if (numericType < NumericType.Max)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
int final = (int) numericType / 10;
|
|
|
int bas = final * 10 + 1;
|
|
|
int add = final * 10 + 2;
|
|
|
@@ -106,16 +129,8 @@ namespace ET
|
|
|
|
|
|
// 一个数值可能会多种情况影响,比如速度,加个buff可能增加速度绝对值100,也有些buff增加10%速度,所以一个值可以由5个值进行控制其最终结果
|
|
|
// final = (((base + add) * (100 + pct) / 100) + finalAdd) * (100 + finalPct) / 100;
|
|
|
- long old = this.GetByKey(final);
|
|
|
long result = (long)(((this.GetByKey(bas) + this.GetByKey(add)) * (100 + this.GetAsFloat(pct)) / 100f + this.GetByKey(finalAdd)) * (100 + this.GetAsFloat(finalPct)) / 100f);
|
|
|
- this.NumericDic[final] = result;
|
|
|
- Game.EventSystem.Publish(new EventType.NumbericChange()
|
|
|
- {
|
|
|
- Parent = this.Parent,
|
|
|
- NumericType = final,
|
|
|
- Old = old,
|
|
|
- New = result
|
|
|
- });
|
|
|
+ this.Insert(final,result,isPublicEvent);
|
|
|
}
|
|
|
}
|
|
|
}
|