From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/XTakeCostMgr.cs | 58 +++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XTakeCostMgr.cs (limited to 'Client/Assets/Scripts/XMainClient/XTakeCostMgr.cs') 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 + { + private Dictionary m_CostCache = new Dictionary(); + + 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.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.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; + } + } +} -- cgit v1.1-26-g67d0