|
@@ -1,4 +1,6 @@
|
|
|
+using Codice.Client.Common;
|
|
|
using System;
|
|
|
+using System.Collections.Generic;
|
|
|
using System.Diagnostics;
|
|
|
using System.Reflection;
|
|
|
|
|
@@ -10,8 +12,7 @@ namespace GFGGame
|
|
|
public int num;
|
|
|
public bool isOnceBonus;
|
|
|
|
|
|
- public int[] AddScoresArr;
|
|
|
- public int[] AddPercentArr;
|
|
|
+ public Dictionary<int, int> AttributesDic = new Dictionary<int, int>();
|
|
|
delegate object MemberGetDelegate(ItemCfg p);
|
|
|
|
|
|
public void Reset()
|
|
@@ -19,8 +20,7 @@ namespace GFGGame
|
|
|
id = 0;
|
|
|
num = 0;
|
|
|
isOnceBonus = false;
|
|
|
- AddScoresArr = null;
|
|
|
- AddPercentArr = null;
|
|
|
+ AttributesDic.Clear();
|
|
|
}
|
|
|
|
|
|
public int MainScore
|
|
@@ -28,22 +28,32 @@ namespace GFGGame
|
|
|
get
|
|
|
{
|
|
|
var cfg = ItemCfgArray.Instance.GetCfg(id);
|
|
|
- return GetScore(cfg.mainScore);
|
|
|
+ return GetScore(cfg.mainScore>0? cfg.mainScore:1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public int GetScore(int scoreType)
|
|
|
{
|
|
|
+ int valueBase = 0;
|
|
|
var cfg = ItemCfgArray.Instance.GetCfg(id);
|
|
|
- Type type = typeof(ItemCfg);
|
|
|
- PropertyInfo property = type.GetProperty("score" + scoreType);
|
|
|
- MemberGetDelegate memberGet = (MemberGetDelegate)System.Delegate.CreateDelegate(typeof(MemberGetDelegate), property.GetGetMethod());
|
|
|
- Stopwatch stopwatch = Stopwatch.StartNew();
|
|
|
- var scoreBase = (int)memberGet(cfg);
|
|
|
- int index = scoreType - 1;
|
|
|
- var scoreadd = AddScoresArr.Length == 0 ? 0 : AddScoresArr[index];
|
|
|
- var percentAdd = AddPercentArr.Length == 0 ? 0 : AddPercentArr[index];
|
|
|
- return CalculateUtil.GetItemScore(scoreBase, percentAdd, scoreadd);
|
|
|
+ switch(scoreType)
|
|
|
+ {
|
|
|
+ case (int)ConstItemAttributeType.FENG:
|
|
|
+ valueBase = cfg.score1;
|
|
|
+ break;
|
|
|
+ case (int)ConstItemAttributeType.HUA:
|
|
|
+ valueBase = cfg.score2;
|
|
|
+ break;
|
|
|
+ case (int)ConstItemAttributeType.XUE:
|
|
|
+ valueBase = cfg.score3;
|
|
|
+ break;
|
|
|
+ case (int)ConstItemAttributeType.YUE:
|
|
|
+ valueBase = cfg.score4;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ AttributesDic.TryGetValue(CalculateUtil.GetItemScoreKey(scoreType, (int)ConstItemAttributeActionType.ADD_VALUE), out var valueAdd);
|
|
|
+ AttributesDic.TryGetValue(CalculateUtil.GetItemScoreKey(scoreType, (int)ConstItemAttributeActionType.ADD_PERCENT), out var percentAdd);
|
|
|
+ return CalculateUtil.GetItemAttribute(valueBase, percentAdd, valueAdd);
|
|
|
}
|
|
|
}
|
|
|
}
|