ybx_Gdn 9 mesi fa
parent
commit
05fca3ef6e

+ 11 - 0
Assets/Content/Config/AndroidShopProductIDCfg.csv

@@ -0,0 +1,11 @@
+id,amount,productID,productName,other
+id,amount,productID,productName,other
+1,0.99,0.99,商品1,
+2,1.99,1.99,商品2,
+3,2.99,2.99,商品3,
+4,3.99,3.99,商品4,
+5,4.99,4.99,商品5,
+6,5.99,5.99,商品6,
+7,6.99,6.99,商品7,
+8,7.99,7.99,商品8,
+9,8.99,8.99,商品9,

+ 7 - 0
Assets/Content/Config/AndroidShopProductIDCfg.csv.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 0670ae81eaccb1046ac8b61862cbb064
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 52 - 0
Assets/Plugins/SDK/SDKMgr.cs

@@ -510,6 +510,58 @@ public partial class SDKMgr : MonoBehaviour
         BuglyAgent.SetUserId (userId);
 #endif
     }
+    public class ProductInfo
+    {
+        public string ID;
+        public string Name;
+        public string CID;
+        public string Other;
+    }
+
+    public Dictionary<string, ProductInfo> ProductInfos = new Dictionary<string, ProductInfo>()
+    {
+        { "0.99",new ProductInfo(){ CID = "1",Name = "0.99禮包"} },
+        { "1.99",new ProductInfo(){ CID = "2",Name = "1.99禮包"} },
+        { "2.99",new ProductInfo(){ CID = "3",Name = "2.99禮包"} },
+        { "4.99",new ProductInfo(){ CID = "4",Name = "4.99禮包"} },
+        { "9.99",new ProductInfo(){ CID = "5",Name = "9.99禮包"} },
+        { "14.99",new ProductInfo(){ CID = "6",Name = "14.99禮包"} },
+        { "19.99",new ProductInfo(){ CID = "7",Name = "19.99禮包"} },
+        { "49.99",new ProductInfo(){ CID = "8",Name = "49.99禮包"} },
+        { "99.99",new ProductInfo(){ CID = "9",Name = "99.99禮包"} },
+    };
+
+
+    public void InitProductCfg(Dictionary<string, Dictionary<string, string>> cfg)
+    {
+        foreach (var item in cfg)
+        {
+            string id = item.Key;
+            string pid = item.Value["productID"];
+            string name = item.Value["productName"];
+            string amount = item.Value["amount"];
+            string other = item.Value["other"];
+            if (ProductInfos.ContainsKey(amount))
+            {
+                ProductInfos[amount].ID = pid;
+                ProductInfos[amount].Name = name;
+                ProductInfos[amount].Other = other;
+            }
+            else
+            {
+                ProductInfos.Add(amount, new ProductInfo() 
+                {
+                    ID= pid,
+                    CID = id,
+                    Name = name,
+                    Other = other,
+                });
+            }
+
+            //Debug.Log($"=====  商品配置 {name}   ======");
+        }
+
+    }
 }
 public class MethodMaker
 {

+ 15 - 0
Assets/Src/GameLogic/GameMgr.cs

@@ -1046,9 +1046,24 @@ public class GameMgr : SingletonMono<GameMgr>
         mSdkCanEnterServerJudgeCB = func;
     }
 
+
+    public void InitSdkCfg()
+    {
+
+        string cname = "";
+#if UNITY_ANDROID
+        cname = "AndroidShopProductIDCfg";
+#elif UNITY_IOS
+			cname = "IOSShopProductIDCfg";
+#endif
+        Dictionary<string, Dictionary<string, string>> datas = ConfigMgr.Instance.getTable(cname);
+        if (datas != null)
+            SDKMgr.Instance.InitProductCfg(datas);
+    }
     public void SdkInit()
     {
         SDKMgr.Instance.Init();
+        InitSdkCfg();
     }
 
     public void SdkLogin()

+ 3 - 1
Assets/ToLua/Source/Generate/SDKMgrWrap.cs

@@ -1,5 +1,6 @@
-//this source code was auto-generated by tolua#, do not modify it
+//this source code was auto-generated by tolua#, do not modify it
 using System;
+using System.Collections.Generic;
 using LuaInterface;
 
 public class SDKMgrWrap
@@ -93,6 +94,7 @@ public class SDKMgrWrap
 			ToLua.CheckArgsCount(L, 1);
 			SDKMgr obj = (SDKMgr)ToLua.CheckObject<SDKMgr>(L, 1);
 			obj.Init();
+			GameMgr.Instance.InitSdkCfg();
 			return 0;
 		}
 		catch (Exception e)