QKGame.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Runtime.InteropServices;
  4. //using Newtonsoft.Json;
  5. #if UNITY_IOS
  6. using quicksdk;
  7. using System.Collections.Generic;
  8. public enum QKSDKInitState
  9. {
  10. None,
  11. Initing,
  12. Success,
  13. Fail,
  14. }
  15. public class ProductInfo
  16. {
  17. public string ID;
  18. public string Name;
  19. }
  20. public class QKGame {
  21. public static QKSDKInitState InitState = QKSDKInitState.None;
  22. public Dictionary<string, ProductInfo> ProductInfos = new Dictionary<string, ProductInfo>()
  23. {
  24. { "0.99",new ProductInfo(){ ID = "intention0.99",Name = "0.99禮包"} },
  25. { "1.99",new ProductInfo(){ ID = "intention1.99",Name = "1.99禮包"} },
  26. { "2.99",new ProductInfo(){ ID = "intention2.99",Name = "2.99禮包"} },
  27. { "4.99",new ProductInfo(){ ID = "intention4.99",Name = "4.99禮包"} },
  28. { "9.99",new ProductInfo(){ ID = "intention9.99",Name = "9.99禮包"} },
  29. { "14.99",new ProductInfo(){ ID = "intention14.99",Name = "14.99禮包"} },
  30. { "19.99",new ProductInfo(){ ID = "intention19.99",Name = "19.99禮包"} },
  31. { "49.99",new ProductInfo(){ ID = "intention49.99",Name = "49.99禮包"} },
  32. { "99.99",new ProductInfo(){ ID = "intention99.99",Name = "99.99禮包"} },
  33. };
  34. [DllImport("__Internal")]
  35. private static extern void LuluSetListener(string gameObjectName);
  36. public void loginKitSetListener(LoginKitListener listener)
  37. {
  38. Debug.Log("gameObject is " + listener.gameObject.name);
  39. if (listener == null)
  40. {
  41. Debug.LogError("set LoginKitListener error, listener is null");
  42. return;
  43. }
  44. if (Application.platform != RuntimePlatform.OSXEditor)
  45. {
  46. string gameObjectName = listener.gameObject.name;
  47. LuluSetListener(gameObjectName);
  48. }
  49. }
  50. [DllImport("__Internal")]
  51. private static extern void luLuInit();
  52. //init
  53. public static void txQKInit()
  54. {
  55. if (Application.platform != RuntimePlatform.OSXEditor || InitState == QKSDKInitState.None || InitState == QKSDKInitState.Fail)
  56. {
  57. InitState = QKSDKInitState.Initing;
  58. luLuInit();
  59. }
  60. }
  61. [DllImport("__Internal")]
  62. private static extern void luLuLogin(bool isShowMenu);
  63. //Login
  64. public static void txQKLogin(bool isShowMenu)
  65. {
  66. if (Application.platform != RuntimePlatform.OSXEditor )
  67. {
  68. luLuLogin(isShowMenu);
  69. }
  70. }
  71. [DllImport("__Internal")]
  72. private static extern void loginKitLoginWithType(int type);
  73. //Login
  74. public static void loginKitLoginWithType_Thread(int type)
  75. {
  76. if (Application.platform != RuntimePlatform.OSXEditor)
  77. {
  78. loginKitLoginWithType(type);
  79. }
  80. }
  81. [DllImport("__Internal")]
  82. private static extern void luLuFastStartGame();
  83. //Login
  84. public static void txQKFastStartGame()
  85. {
  86. if (Application.platform != RuntimePlatform.OSXEditor)
  87. {
  88. luLuFastStartGame();
  89. }
  90. }
  91. [DllImport("__Internal")]
  92. private static extern string luLuGetUserBindInfo();
  93. //luLuUserCenter
  94. //public static Dictionary<string, int> loginkitGetUserBindInfo()
  95. //{
  96. // if (Application.platform != RuntimePlatform.OSXEditor)
  97. // {
  98. // string jsonString = luLuGetUserBindInfo();
  99. // return JsonConvert.deserializeobject(jsonString);
  100. // }
  101. //}
  102. [DllImport("__Internal")]
  103. private static extern void luLuUserCenter();
  104. //luLuUserCenter
  105. public static void txQKCenter()
  106. {
  107. if (Application.platform != RuntimePlatform.OSXEditor)
  108. {
  109. luLuUserCenter();
  110. }
  111. }
  112. [DllImport("__Internal")]
  113. private static extern void luLuLogout();
  114. //Logout
  115. public static void txQKLogout()
  116. {
  117. if (Application.platform != RuntimePlatform.OSXEditor)
  118. {
  119. luLuLogout();
  120. }
  121. }
  122. [DllImport("__Internal")]
  123. private static extern void luLuBindAccount();
  124. //bindAccount
  125. public static void txQKBindAccount()
  126. {
  127. if (Application.platform != RuntimePlatform.OSXEditor)
  128. {
  129. luLuBindAccount();
  130. }
  131. }
  132. [DllImport("__Internal")]
  133. private static extern void luLuBindAccountWithType(int type);
  134. //bindAccountType
  135. public static void txQKBindAccountWithType(int type)
  136. {
  137. if (Application.platform != RuntimePlatform.OSXEditor)
  138. {
  139. luLuBindAccountWithType(type);
  140. }
  141. }
  142. [DllImport("__Internal")]
  143. private static extern void luLuUnbindAccountWithType(int type);
  144. //unbindAccountType
  145. public static void txQKUnbindAccountWithType(int type)
  146. {
  147. if (Application.platform != RuntimePlatform.OSXEditor)
  148. {
  149. luLuUnbindAccountWithType(type);
  150. }
  151. }
  152. [DllImport("__Internal")]
  153. private static extern void luLuAccountDeletion();
  154. //accountDeletion
  155. public static void txQKAccountDeletion()
  156. {
  157. if (Application.platform != RuntimePlatform.OSXEditor)
  158. {
  159. luLuAccountDeletion();
  160. }
  161. }
  162. [DllImport("__Internal")]
  163. private static extern void luLuShowMenu(float y);
  164. //luLuShowMenu
  165. public static void txQKShowMenu(float y)
  166. {
  167. if (Application.platform != RuntimePlatform.OSXEditor)
  168. {
  169. luLuShowMenu(y);
  170. }
  171. }
  172. [DllImport("__Internal")]
  173. private static extern void luLuDismissMenu();
  174. //luLuDismissMenu
  175. public static void txQKDismissMenu()
  176. {
  177. if (Application.platform != RuntimePlatform.OSXEditor)
  178. {
  179. luLuDismissMenu();
  180. }
  181. }
  182. [DllImport("__Internal")]
  183. private static extern void luluSetRoleInfo(string serverName,string serverId,string roleId,string roleName,string roleLevel,string roleVipLevel);
  184. //setRoleInfo,参数 游戏服名 游戏服id 角色名 角色id 角色等级 角色vip等级
  185. public static void txQKSetRoleInfo(string serverName,string serverId,string roleId,string roleName,string roleLevel,string roleVipLevel)
  186. {
  187. if (Application.platform != RuntimePlatform.OSXEditor)
  188. {
  189. luluSetRoleInfo(serverName,serverId,roleId,roleName,roleLevel,roleLevel);
  190. }
  191. }
  192. [DllImport("__Internal")]
  193. private static extern void luLuCongzi(string productId,string productName,string amount,string orderNo,string callBackUrl,string extrasParams);
  194. //Pay RMB,参数 苹果商品ID 商品名称 价格 游戏订单号 游戏收单服务器地址 透传参数
  195. public static void txQKCongzi(string productId,string productName,string amount,string orderNo,string callBackUrl,string extrasParams)
  196. {
  197. if (Application.platform != RuntimePlatform.OSXEditor)
  198. {
  199. luLuCongzi(productId,productName,amount,orderNo,callBackUrl,extrasParams);
  200. }
  201. }
  202. [DllImport("__Internal")]
  203. private static extern void luluRestoreNonConsumptionProducts();
  204. //lulurestoreNonConsumptionProducts
  205. public static void txQKRestoreNonConsumptionProducts()
  206. {
  207. if (Application.platform != RuntimePlatform.OSXEditor)
  208. {
  209. luluRestoreNonConsumptionProducts();
  210. }
  211. }
  212. [DllImport("__Internal")]
  213. private static extern void luluFindProductInfo(string productIds);
  214. //luLuDismissMenu
  215. public static void txQKFindProductInfo(List<string> goodsIds)
  216. {
  217. if (Application.platform != RuntimePlatform.OSXEditor)
  218. {
  219. luluFindProductInfo(string.Join(",", goodsIds.ToArray()));
  220. }
  221. }
  222. [DllImport("__Internal")]
  223. private static extern string LuluGetUserId();
  224. public string loginKitGetUserId()
  225. {
  226. if (Application.platform != RuntimePlatform.OSXEditor)
  227. {
  228. return LuluGetUserId();
  229. }
  230. return "";
  231. }
  232. [DllImport("__Internal")]
  233. private static extern string LuluGetDeviceId();
  234. public string loginKitGetDeviceId()
  235. {
  236. if (Application.platform != RuntimePlatform.OSXEditor)
  237. {
  238. return LuluGetDeviceId();
  239. }
  240. return "";
  241. }
  242. }
  243. #endif