YouYiSDKiOS.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #if UNITY_IOS
  2. using System.Runtime.InteropServices;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using qsdk;
  7. public class YouYiSDKiOS : SDKBase
  8. {
  9. private YouYiListener m_YouYiListener;
  10. public QKGame qKGamesdk;
  11. private QSdkListener qListenter;
  12. public YouYiSDKiOS()
  13. {
  14. SDKName = "MIAN_YOU_IOS";
  15. m_YouYiListener = SDKMgr.Instance.gameObject.AddComponent<YouYiListener>();
  16. qListenter = SDKMgr.Instance.gameObject.AddComponent<QSdkListener>();
  17. qKGamesdk = new QKGame();
  18. //YouYi_SetCallbackGoName(SDKMgr.Instance.gameObject.name);
  19. qListenter.InitListener(m_YouYiListener);
  20. QSdkMgr.SetListener(qListenter.gameObject.name);
  21. }
  22. public override void Init()
  23. {
  24. base.Init();
  25. //YouYi_Init();
  26. if (QSdkMgr.InitState == QKSDKInitState.Success)
  27. {
  28. CallInitSuccessCB();
  29. return;
  30. }
  31. QSdkMgr.Init();
  32. }
  33. public override void OnApplicationFocus(bool focusStatus)
  34. {
  35. base.OnApplicationFocus(focusStatus);
  36. }
  37. public override void Login()
  38. {
  39. QSdkMgr.Login();
  40. }
  41. public override void Logout()
  42. {
  43. //YouYi_Logout();
  44. QSdkMgr.Logout();
  45. }
  46. public override void SwitchAccount()
  47. {
  48. //YouYi_SwitchAccount();
  49. }
  50. public override void Pay(int goodsId, string goodsName, string goodsDesc, int count, float amount, string cpOrderId, string extrasParams)
  51. {
  52. GameRoleInfo gameRoleInfo = SDKMgr.Instance.GetGameRoleInfo();
  53. if (gameRoleInfo == null || !gameRoleInfo.Valid())
  54. {
  55. Debug.LogError("[YISDK][Pay] GameRoleInfo is null or not valid !!!");
  56. m_YouYiListener.OnPayFailed();
  57. return;
  58. }
  59. Dictionary<string, SDKMgr.ProductInfo> cfgs = SDKMgr.Instance.ProductInfos;
  60. int itemp = Mathf.FloorToInt(amount);
  61. string pice = "";
  62. if ((itemp + 0.005f) > amount)
  63. {
  64. pice = itemp.ToString();
  65. }
  66. else
  67. {
  68. pice = amount.ToString("F2");
  69. }
  70. Debug.Log("价格 = " + pice);
  71. if (cfgs.ContainsKey(pice))
  72. {
  73. Debug.Log("有 价格 = " + pice);
  74. SDKMgr.ProductInfo productInfo = cfgs[pice];
  75. //Debug.Log($"=========================={productInfo.ID}======={productInfo.Name}");
  76. QSdkMgr.Pay(productInfo.ID, productInfo.Name, amount.ToString(), cpOrderId, goodsName,
  77. extrasParams, Application.productName, gameRoleInfo.serverName, goodsDesc,
  78. gameRoleInfo.serverId.ToString(), m_YouYiListener.UID,gameRoleInfo.roleId,gameRoleInfo.roleLv.ToString());
  79. }
  80. else
  81. {
  82. Debug.Log("没有 价格 = " + pice);
  83. m_YouYiListener.OnPayFailed();
  84. }
  85. }
  86. public override void CreateRole()
  87. {
  88. }
  89. public override void EnterGame()
  90. {
  91. }
  92. public override void UpdateRoleLv()
  93. {
  94. }
  95. public override void ExitGame()
  96. {
  97. }
  98. public override bool Exit()
  99. {
  100. return false;
  101. }
  102. public override bool Quit()
  103. {
  104. return false;
  105. }
  106. public override void CallInitSuccessCB()
  107. {
  108. m_YouYiListener.OnInitSuccess();
  109. }
  110. public override void CallLoginSuccessCB()
  111. {
  112. m_YouYiListener.StartCheckLogin();
  113. }
  114. }
  115. #endif