diff options
author | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
commit | 6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch) | |
tree | 7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XMainClient/XTakeCostMgr.cs |
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/XTakeCostMgr.cs')
-rw-r--r-- | Client/Assets/Scripts/XMainClient/XTakeCostMgr.cs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/XTakeCostMgr.cs b/Client/Assets/Scripts/XMainClient/XTakeCostMgr.cs new file mode 100644 index 00000000..400b8ee6 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XTakeCostMgr.cs @@ -0,0 +1,58 @@ +using System;
+using System.Collections.Generic;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal class XTakeCostMgr : XSingleton<XTakeCostMgr>
+ {
+ private Dictionary<string, ICostHandler> m_CostCache = new Dictionary<string, ICostHandler>();
+
+ private static ICostHandler MakeCostHandler()
+ {
+ return new DragonCoinCostHandler();
+ }
+
+ public CostInfo QueryCost(string CostName, int Times)
+ {
+ CostInfo costInfo;
+ costInfo.type = (ItemEnum)0;
+ costInfo.count = 0u;
+ ICostHandler handler = this.GetHandler(CostName);
+ bool flag = handler == null;
+ CostInfo result;
+ if (flag)
+ {
+ XSingleton<XDebug>.singleton.AddErrorLog(string.Format("Can't find CostName: {0} in globalconfig.txt", CostName), null, null, null, null, null);
+ result = costInfo;
+ }
+ else
+ {
+ result = handler.GetCost(Times);
+ }
+ return result;
+ }
+
+ public ICostHandler GetHandler(string CostName)
+ {
+ ICostHandler costHandler = null;
+ bool flag = !this.m_CostCache.TryGetValue(CostName, out costHandler);
+ if (flag)
+ {
+ string value = XSingleton<XGlobalConfig>.singleton.GetValue(CostName);
+ bool flag2 = value != "";
+ if (flag2)
+ {
+ costHandler = XTakeCostMgr.MakeCostHandler();
+ bool flag3 = !costHandler.ParseCostConfigString(value);
+ if (flag3)
+ {
+ costHandler = null;
+ }
+ this.m_CostCache.Add(CostName, costHandler);
+ }
+ }
+ return costHandler;
+ }
+ }
+}
|