| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- using UnityEngine;
- using System.Collections;
- using System.Runtime.InteropServices;
- //using Newtonsoft.Json;
- #if UNITY_IOS
- using quicksdk;
- using System.Collections.Generic;
- public enum QKSDKInitState
- {
- None,
- Initing,
- Success,
- Fail,
- }
- public class ProductInfo
- {
- public string ID;
- public string Name;
- }
- public class QKGame {
- public static QKSDKInitState InitState = QKSDKInitState.None;
- public Dictionary<string, ProductInfo> ProductInfos = new Dictionary<string, ProductInfo>()
- {
- { "0.99",new ProductInfo(){ ID = "intention0.99",Name = "0.99禮包"} },
- { "1.99",new ProductInfo(){ ID = "intention1.99",Name = "1.99禮包"} },
- { "2.99",new ProductInfo(){ ID = "intention2.99",Name = "2.99禮包"} },
- { "4.99",new ProductInfo(){ ID = "intention4.99",Name = "4.99禮包"} },
- { "9.99",new ProductInfo(){ ID = "intention9.99",Name = "9.99禮包"} },
- { "14.99",new ProductInfo(){ ID = "intention14.99",Name = "14.99禮包"} },
- { "19.99",new ProductInfo(){ ID = "intention19.99",Name = "19.99禮包"} },
- { "49.99",new ProductInfo(){ ID = "intention49.99",Name = "49.99禮包"} },
- { "99.99",new ProductInfo(){ ID = "intention99.99",Name = "99.99禮包"} },
- };
- [DllImport("__Internal")]
- private static extern void LuluSetListener(string gameObjectName);
- public void loginKitSetListener(LoginKitListener listener)
- {
- Debug.Log("gameObject is " + listener.gameObject.name);
- if (listener == null)
- {
- Debug.LogError("set LoginKitListener error, listener is null");
- return;
- }
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- string gameObjectName = listener.gameObject.name;
- LuluSetListener(gameObjectName);
- }
- }
- [DllImport("__Internal")]
- private static extern void luLuInit();
- //init
- public static void txQKInit()
- {
- if (Application.platform != RuntimePlatform.OSXEditor || InitState == QKSDKInitState.None || InitState == QKSDKInitState.Fail)
- {
- InitState = QKSDKInitState.Initing;
- luLuInit();
- }
- }
- [DllImport("__Internal")]
- private static extern void luLuLogin(bool isShowMenu);
- //Login
- public static void txQKLogin(bool isShowMenu)
- {
- if (Application.platform != RuntimePlatform.OSXEditor )
- {
- luLuLogin(isShowMenu);
- }
- }
- [DllImport("__Internal")]
- private static extern void loginKitLoginWithType(int type);
- //Login
- public static void loginKitLoginWithType_Thread(int type)
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- loginKitLoginWithType(type);
- }
- }
- [DllImport("__Internal")]
- private static extern void luLuFastStartGame();
- //Login
- public static void txQKFastStartGame()
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- luLuFastStartGame();
- }
- }
- [DllImport("__Internal")]
- private static extern string luLuGetUserBindInfo();
- //luLuUserCenter
- //public static Dictionary<string, int> loginkitGetUserBindInfo()
- //{
- // if (Application.platform != RuntimePlatform.OSXEditor)
- // {
- // string jsonString = luLuGetUserBindInfo();
- // return JsonConvert.deserializeobject(jsonString);
- // }
- //}
- [DllImport("__Internal")]
- private static extern void luLuUserCenter();
- //luLuUserCenter
- public static void txQKCenter()
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- luLuUserCenter();
- }
- }
- [DllImport("__Internal")]
- private static extern void luLuLogout();
- //Logout
- public static void txQKLogout()
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- luLuLogout();
- }
- }
- [DllImport("__Internal")]
- private static extern void luLuBindAccount();
- //bindAccount
- public static void txQKBindAccount()
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- luLuBindAccount();
- }
- }
- [DllImport("__Internal")]
- private static extern void luLuBindAccountWithType(int type);
- //bindAccountType
- public static void txQKBindAccountWithType(int type)
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- luLuBindAccountWithType(type);
- }
- }
- [DllImport("__Internal")]
- private static extern void luLuUnbindAccountWithType(int type);
- //unbindAccountType
- public static void txQKUnbindAccountWithType(int type)
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- luLuUnbindAccountWithType(type);
- }
- }
- [DllImport("__Internal")]
- private static extern void luLuAccountDeletion();
- //accountDeletion
- public static void txQKAccountDeletion()
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- luLuAccountDeletion();
- }
- }
- [DllImport("__Internal")]
- private static extern void luLuShowMenu(float y);
- //luLuShowMenu
- public static void txQKShowMenu(float y)
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- luLuShowMenu(y);
- }
- }
- [DllImport("__Internal")]
- private static extern void luLuDismissMenu();
- //luLuDismissMenu
- public static void txQKDismissMenu()
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- luLuDismissMenu();
- }
- }
- [DllImport("__Internal")]
- private static extern void luluSetRoleInfo(string serverName,string serverId,string roleId,string roleName,string roleLevel,string roleVipLevel);
- //setRoleInfo,参数 游戏服名 游戏服id 角色名 角色id 角色等级 角色vip等级
- public static void txQKSetRoleInfo(string serverName,string serverId,string roleId,string roleName,string roleLevel,string roleVipLevel)
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- luluSetRoleInfo(serverName,serverId,roleId,roleName,roleLevel,roleLevel);
- }
- }
- [DllImport("__Internal")]
- private static extern void luLuCongzi(string productId,string productName,string amount,string orderNo,string callBackUrl,string extrasParams);
- //Pay RMB,参数 苹果商品ID 商品名称 价格 游戏订单号 游戏收单服务器地址 透传参数
- public static void txQKCongzi(string productId,string productName,string amount,string orderNo,string callBackUrl,string extrasParams)
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- luLuCongzi(productId,productName,amount,orderNo,callBackUrl,extrasParams);
- }
- }
- [DllImport("__Internal")]
- private static extern void luluRestoreNonConsumptionProducts();
- //lulurestoreNonConsumptionProducts
- public static void txQKRestoreNonConsumptionProducts()
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- luluRestoreNonConsumptionProducts();
- }
- }
- [DllImport("__Internal")]
- private static extern void luluFindProductInfo(string productIds);
- //luLuDismissMenu
- public static void txQKFindProductInfo(List<string> goodsIds)
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- luluFindProductInfo(string.Join(",", goodsIds.ToArray()));
- }
- }
- [DllImport("__Internal")]
- private static extern string LuluGetUserId();
- public string loginKitGetUserId()
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- return LuluGetUserId();
- }
- return "";
- }
- [DllImport("__Internal")]
- private static extern string LuluGetDeviceId();
- public string loginKitGetDeviceId()
- {
- if (Application.platform != RuntimePlatform.OSXEditor)
- {
- return LuluGetDeviceId();
- }
- return "";
- }
- }
- #endif
|