YouYiSDKiOS.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #if UNITY_IOS
  2. using System.Runtime.InteropServices;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using System.Runtime.InteropServices;
  7. public class YouYiSDKiOS : SDKBase
  8. {
  9. private YouYiListener m_YouYiListener;
  10. public YouYiSDKiOS()
  11. {
  12. SDKName = "SDKYOUYI_IOS";
  13. m_YouYiListener = SDKMgr.Instance.gameObject.AddComponent<YouYiListener>();
  14. YouYi_SetCallbackGoName(SDKMgr.Instance.gameObject.name);
  15. }
  16. public override void Init()
  17. {
  18. base.Init();
  19. YouYi_Init();
  20. }
  21. public override void OnApplicationFocus(bool focusStatus)
  22. {
  23. base.OnApplicationFocus(focusStatus);
  24. }
  25. public override void Login()
  26. {
  27. YouYi_Login();
  28. }
  29. public override void Logout()
  30. {
  31. YouYi_Logout();
  32. }
  33. public override void SwitchAccount()
  34. {
  35. YouYi_SwitchAccount();
  36. }
  37. public override void Pay(int goodsId, string goodsName, string goodsDesc, int count, float amount, string cpOrderId, string extrasParams)
  38. {
  39. GameRoleInfo gameRoleInfo = SDKMgr.Instance.GetGameRoleInfo();
  40. if (gameRoleInfo == null || !gameRoleInfo.Valid())
  41. {
  42. Debug.LogError("[YISDK][Pay] GameRoleInfo is null or not valid !!!");
  43. m_YouYiListener.OnPayFailed();
  44. return;
  45. }
  46. YouYi_Pay(cpOrderId, goodsId.ToString(), goodsName, gameRoleInfo.roleId.ToString(), gameRoleInfo.roleName, gameRoleInfo.roleLv.ToString(), gameRoleInfo.serverId.ToString(), gameRoleInfo.serverName, amount.ToString(), extrasParams);
  47. }
  48. public override void CreateRole()
  49. {
  50. GameRoleInfo gameRoleInfo = SDKMgr.Instance.GetGameRoleInfo();
  51. if (gameRoleInfo == null || !gameRoleInfo.Valid())
  52. {
  53. Debug.LogError("[YISDK][CreateRole] GameRoleInfo is null or not valid !!!");
  54. return;
  55. }
  56. YouYi_CreateRoleReportData(gameRoleInfo.roleId.ToString(), gameRoleInfo.roleName, gameRoleInfo.roleLv.ToString(), gameRoleInfo.serverId.ToString(), gameRoleInfo.serverName);
  57. }
  58. public override void EnterGame()
  59. {
  60. GameRoleInfo gameRoleInfo = SDKMgr.Instance.GetGameRoleInfo();
  61. if (gameRoleInfo == null || !gameRoleInfo.Valid())
  62. {
  63. Debug.LogError("[YISDK][EnterGame] GameRoleInfo is null or not valid !!!");
  64. return;
  65. }
  66. YouYi_RoleEnterGameReportData(gameRoleInfo.roleId.ToString(), gameRoleInfo.roleName, gameRoleInfo.roleLv.ToString(), gameRoleInfo.serverId.ToString(), gameRoleInfo.serverName);
  67. }
  68. public override void UpdateRoleLv()
  69. {
  70. GameRoleInfo gameRoleInfo = SDKMgr.Instance.GetGameRoleInfo();
  71. if (gameRoleInfo == null || !gameRoleInfo.Valid())
  72. {
  73. Debug.LogError("[YISDK][UpdateRoleLv] GameRoleInfo is null or not valid !!!");
  74. return;
  75. }
  76. YouYi_RoleUpLevelReportData(gameRoleInfo.roleId.ToString(), gameRoleInfo.roleName, gameRoleInfo.roleLv.ToString(), gameRoleInfo.serverId.ToString(), gameRoleInfo.serverName);
  77. }
  78. public override void ExitGame()
  79. {
  80. }
  81. public override bool Exit()
  82. {
  83. return false;
  84. }
  85. public override bool Quit()
  86. {
  87. return false;
  88. }
  89. public override void CallInitSuccessCB()
  90. {
  91. m_YouYiListener.OnInitSuccess();
  92. }
  93. public override void CallLoginSuccessCB()
  94. {
  95. m_YouYiListener.StartCheckLogin();
  96. }
  97. [DllImport("__Internal")]
  98. private static extern void YouYi_SetCallbackGoName(string callbackGoName);
  99. [DllImport("__Internal")]
  100. private static extern void YouYi_Init();
  101. [DllImport("__Internal")]
  102. private static extern void YouYi_Login();
  103. [DllImport("__Internal")]
  104. private static extern void YouYi_Logout();
  105. [DllImport("__Internal")]
  106. private static extern void YouYi_SwitchAccount();
  107. [DllImport("__Internal")]
  108. private static extern void YouYi_Pay(string cpOrderId, string goodsId, string goodsName, string roleId, string roleName, string roleLevel, string serverId, string serverName, string amount, string extrasParams);
  109. [DllImport("__Internal")]
  110. private static extern void YouYi_CreateRoleReportData(string roleId, string roleName, string roleLevel, string serverId, string serverName);
  111. [DllImport("__Internal")]
  112. private static extern void YouYi_RoleEnterGameReportData(string roleId, string roleName, string roleLevel, string serverId, string serverName);
  113. [DllImport("__Internal")]
  114. private static extern void YouYi_RoleUpLevelReportData(string roleId, string roleName, string roleLevel, string serverId, string serverName);
  115. }
  116. #endif