QSDKMgr.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using UnityEngine;
  4. namespace qsdk
  5. {
  6. public class SDKOrderExtraInfo
  7. {
  8. public int serverId;
  9. public string platform;
  10. public string subPlatform;
  11. public string orderNo;
  12. }
  13. public class SdkPayOderInfo
  14. {
  15. public string extends_info_data;
  16. public string game_area;
  17. public string game_level;
  18. public string game_orderid;
  19. public string game_currency;
  20. public string game_price;
  21. public string game_role_id;
  22. public string game_role_name;
  23. public string game_guid;
  24. public string notify_id;
  25. public string subject;
  26. public string game_sign;
  27. public string game_access_version;
  28. }
  29. public class QSdkMgr
  30. {
  31. public static QKSDKInitState InitState = QKSDKInitState.None;
  32. public static void SetListener(string listener)
  33. {
  34. #if UNITY_IOS
  35. QSDK_SetListener(listener);
  36. #endif
  37. }
  38. public static void Init()
  39. {
  40. #if UNITY_IOS
  41. QSDK_Init();
  42. #endif
  43. }
  44. public static void Login()
  45. {
  46. #if UNITY_IOS
  47. QSDK_login();
  48. #endif
  49. }
  50. public static void Pay(string productId, string productName, string amount, string orderNo,
  51. string callBackUrl, string extrasParams,
  52. string gameName, string serverName, string productDesc, string serverID, string accountID, string roleID, string roleLv)
  53. {
  54. #if UNITY_IOS
  55. object infoObj =JsonUtility.FromJson(callBackUrl, typeof(SdkPayOderInfo));
  56. if (infoObj != null)
  57. {
  58. SdkPayOderInfo info = (SdkPayOderInfo)infoObj;
  59. QSDK_Pay_x7( info.extends_info_data,
  60. info. game_area,
  61. info. game_level,
  62. info. game_orderid,
  63. info. game_currency,
  64. info. game_price,
  65. info. game_role_id,
  66. info. game_role_name,
  67. info. game_guid,
  68. info. notify_id,
  69. info. subject,
  70. info. game_sign,
  71. info. game_access_version);
  72. }
  73. else
  74. {
  75. QSDK_Pay( productId, productName, amount, orderNo,
  76. callBackUrl, extrasParams,
  77. gameName, serverName, productDesc,
  78. serverID,accountID,roleID,roleLv);
  79. }
  80. #endif
  81. }
  82. public static void Logout()
  83. {
  84. #if UNITY_IOS
  85. QSDK_logout();
  86. #endif
  87. }
  88. public static void UpdateRoleInfo(int type,GameRoleInfo roleInfo,string extra)
  89. {
  90. #if UNITY_IOS
  91. QSDK_UpdateRoleInfo_X7(type,
  92. roleInfo.openId,
  93. roleInfo.serverName,
  94. roleInfo.serverId.ToString() ,
  95. roleInfo.roleId,
  96. roleInfo.roleName,
  97. roleInfo.roleLv.ToString() ,
  98. roleInfo.fightPower.ToString(),
  99. "-1",
  100. "-1",
  101. string.IsNullOrEmpty(roleInfo.guildName)?"-1": roleInfo.guildName,
  102. roleInfo.guildId.ToString(),extra);
  103. #endif
  104. }
  105. #if UNITY_IOS
  106. [DllImport("__Internal")]
  107. private static extern void QSDK_SetListener(string callbackGoName);
  108. [DllImport("__Internal")]
  109. private static extern void QSDK_Init();
  110. [DllImport("__Internal")]
  111. private static extern void QSDK_login();
  112. [DllImport("__Internal")]
  113. private static extern void QSDK_Pay(string productId, string productName, string amount, string orderNo,
  114. string callBackUrl, string extrasParams,
  115. string gameName, string serverName, string productDesc,
  116. string serverID, string accountID, string roleID, string roleLv);
  117. [DllImport("__Internal")]
  118. private static extern void QSDK_Pay_x7( string extends_info_data,
  119. string game_area,
  120. string game_level,
  121. string game_orderid,
  122. string game_currency,
  123. string game_price,
  124. string game_role_id,
  125. string game_role_name,
  126. string game_guid,
  127. string notify_id,
  128. string subject,
  129. string game_sign,
  130. string game_access_version);
  131. [DllImport("__Internal")]
  132. private static extern void QSDK_logout();
  133. //[DllImport("__Internal")]
  134. //private static extern void QSDK_UpdateRoleInfo(int type,string roleName,string roleId,string roleLv, string serverName,string serverId,string extra);
  135. [DllImport("__Internal")]
  136. private static extern void QSDK_UpdateRoleInfo_X7(int type,
  137. string game_guid,
  138. string game_area,
  139. string game_area_id ,
  140. string game_role_id ,
  141. string game_role_name ,
  142. string roleLevel ,
  143. string roleCE,
  144. string roleStage,
  145. string roleRechargeAmount ,
  146. string roleGuild ,
  147. string roleGuildId,
  148. string extra);
  149. #endif
  150. }
  151. }