YouYiSDKiOS.cs 3.2 KB

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