QSDKMgr.cs 4.8 KB

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