#if UNITY_IOS using System.Runtime.InteropServices; using System.Collections; using System.Collections.Generic; using UnityEngine; using qsdk; public class YouYiSDKiOS : SDKBase { private YouYiListener m_YouYiListener; public QKGame qKGamesdk; private QSdkListener qListenter; public YouYiSDKiOS() { SDKName = "SDKYOUYI_IOS"; m_YouYiListener = SDKMgr.Instance.gameObject.AddComponent(); qListenter = SDKMgr.Instance.gameObject.AddComponent(); qKGamesdk = new QKGame(); //YouYi_SetCallbackGoName(SDKMgr.Instance.gameObject.name); qListenter.InitListener(m_YouYiListener); QSdkMgr.SetListener(qListenter.gameObject.name); } public override void Init() { base.Init(); //YouYi_Init(); if (QSdkMgr.InitState == QKSDKInitState.Success) { CallInitSuccessCB(); return; } QSdkMgr.Init(); } public override void OnApplicationFocus(bool focusStatus) { base.OnApplicationFocus(focusStatus); } public override void Login() { QSdkMgr.Login(); } public override void Logout() { //YouYi_Logout(); QSdkMgr.Logout(); } public override void SwitchAccount() { //YouYi_SwitchAccount(); } public override void Pay(int goodsId, string goodsName, string goodsDesc, int count, float amount, string cpOrderId, string extrasParams) { GameRoleInfo gameRoleInfo = SDKMgr.Instance.GetGameRoleInfo(); if (gameRoleInfo == null || !gameRoleInfo.Valid()) { Debug.LogError("[YISDK][Pay] GameRoleInfo is null or not valid !!!"); m_YouYiListener.OnPayFailed(); return; } Dictionary cfgs = SDKMgr.Instance.ProductInfos; int itemp = Mathf.FloorToInt(amount); string pice = ""; if ((itemp + 0.005f) > amount) { pice = itemp.ToString(); } else { pice = amount.ToString("F2"); } Debug.Log("价格 = " + pice); if (cfgs.ContainsKey(pice)) { Debug.Log("有 价格 = " + pice); SDKMgr.ProductInfo productInfo = cfgs[pice]; //Debug.Log($"=========================={productInfo.ID}======={productInfo.Name}"); QSdkMgr.Pay(productInfo.ID, productInfo.Name, amount.ToString(), cpOrderId, goodsName, extrasParams, Application.productName, gameRoleInfo.serverName, goodsDesc); } else { Debug.Log("没有 价格 = " + pice); m_YouYiListener.OnPayFailed(); } } public override void CreateRole() { } public override void EnterGame() { } public override void UpdateRoleLv() { } public override void ExitGame() { } public override bool Exit() { return false; } public override bool Quit() { return false; } public override void CallInitSuccessCB() { m_YouYiListener.OnInitSuccess(); } public override void CallLoginSuccessCB() { m_YouYiListener.StartCheckLogin(); } } #endif