|
@@ -0,0 +1,323 @@
|
|
|
+using DouYouSdk;
|
|
|
+using UniFramework.Event;
|
|
|
+using Unity.Plastic.Newtonsoft.Json;
|
|
|
+using UnityEngine;
|
|
|
+
|
|
|
+namespace GFGGame.Launcher
|
|
|
+{
|
|
|
+ public class QDDouYouManagerInitIos : SingletonBase<QDDouYouManagerInitIos>
|
|
|
+ {
|
|
|
+ public IDouYouSDKListenerIos douYouSDKListenerIos;
|
|
|
+
|
|
|
+ public DouYouIosSDKHandler douYouIosSDKHandler;
|
|
|
+
|
|
|
+ public void InitSDK(string gameId, string adId, bool showLog)
|
|
|
+ {
|
|
|
+ if (douYouIosSDKHandler == null)
|
|
|
+ {
|
|
|
+ GameObject gameObject = new GameObject("DouYouSDKGameObject");
|
|
|
+ gameObject.AddComponent<DouYouIosSDKHandler>();
|
|
|
+ GameObject.DontDestroyOnLoad(gameObject);
|
|
|
+
|
|
|
+ douYouIosSDKHandler =
|
|
|
+ GameObject.Find("DouYouSDKGameObject")?.GetComponent<DouYouIosSDKHandler>();
|
|
|
+ }
|
|
|
+
|
|
|
+ Instance.InitWithDigitMap(gameId, adId, showLog);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 实例化sdk
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="gameId"></param>
|
|
|
+ /// <param name="adId"></param>
|
|
|
+ /// <param name="shouldLog"></param>
|
|
|
+ public void InitWithDigitMap(string gameId, string adId, bool shouldLog)
|
|
|
+ {
|
|
|
+ douYouIosSDKHandler?.SDKInitWithDigitMap(gameId, adId, shouldLog);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 显示登录
|
|
|
+ /// </summary>
|
|
|
+ public void ShowLogin()
|
|
|
+ {
|
|
|
+ douYouIosSDKHandler?.SDKLogin();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 退出登录
|
|
|
+ /// </summary>
|
|
|
+ public void Logout()
|
|
|
+ {
|
|
|
+ douYouIosSDKHandler?.SDKLogout();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 显示支付
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="cpOrderId">订单号</param>
|
|
|
+ /// <param name="productPrice">订单金额(元)</param>
|
|
|
+ /// <param name="productId">产品ID</param>
|
|
|
+ /// <param name="productName">产品名称</param>
|
|
|
+ /// <param name="productDesc">商品描述</param>
|
|
|
+ /// <param name="productCount">购买数量</param>
|
|
|
+ /// <param name="exchangeRate">比例(默认 - 1)</param>
|
|
|
+ /// <param name="currencyName">金币</param>
|
|
|
+ /// <param name="serverId">区服ID</param>
|
|
|
+ /// <param name="serverName">区服名称</param>
|
|
|
+ /// <param name="roleId">角色ID</param>
|
|
|
+ /// <param name="roleName">角色名称</param>
|
|
|
+ /// <param name="roleLevel">角色等级</param>
|
|
|
+ /// <param name="roleVip">角色VIP</param>
|
|
|
+ /// <param name="partyName">工会名称</param>
|
|
|
+ /// <param name="roleBalence">游戏币</param>
|
|
|
+ /// <param name="ext">透传参数</param>
|
|
|
+ public void ShowPay(string cpOrderId, string productPrice, string productId, string productName,
|
|
|
+ string productDesc, string productCount, string exchangeRate, string currencyName, string serverId,
|
|
|
+ string serverName, string roleId, string roleName, string roleLevel, string roleVip, string partyName,
|
|
|
+ string roleBalence, string ext)
|
|
|
+ {
|
|
|
+ var data = new
|
|
|
+ {
|
|
|
+ cp_order_id = HandleNullString(cpOrderId),
|
|
|
+ product_price = HandleNullString(productPrice),
|
|
|
+ product_id = HandleNullString(productId),
|
|
|
+ product_name = HandleNullString(productName),
|
|
|
+ product_desc = HandleNullString(productDesc),
|
|
|
+ product_count = HandleNullString(productCount),
|
|
|
+ exchange_rate = HandleNullString(exchangeRate),
|
|
|
+ currency_name = HandleNullString(currencyName),
|
|
|
+ server_id = HandleNullString(serverId),
|
|
|
+ server_name = HandleNullString(serverName),
|
|
|
+ role_id = HandleNullString(roleId),
|
|
|
+ role_name = HandleNullString(roleName),
|
|
|
+ role_level = HandleNullString(roleLevel),
|
|
|
+ role_vip = HandleNullString(roleVip),
|
|
|
+ party_name = HandleNullString(partyName),
|
|
|
+ role_balance = HandleNullString(roleBalence),
|
|
|
+ ext = HandleNullString(ext)
|
|
|
+ };
|
|
|
+
|
|
|
+ string paymentJson = JsonConvert.SerializeObject(data);
|
|
|
+ douYouIosSDKHandler?.SdkPaymentWithJson(paymentJson);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 上报角色信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="type">数据类型(1 - 进入游戏、2 - 创建角色、3 - 角色升级、4 - 退出、5 - 充值)</param>
|
|
|
+ /// <param name="serverId">区服ID</param>
|
|
|
+ /// <param name="serverName">区服名称</param>
|
|
|
+ /// <param name="roleId">角色ID</param>
|
|
|
+ /// <param name="roleName">角色名称</param>
|
|
|
+ /// <param name="roleLevel">角色等级</param>
|
|
|
+ /// <param name="roleVip">角色VIP</param>
|
|
|
+ /// <param name="partyName">工会名称</param>
|
|
|
+ /// <param name="roleBalence">游戏币</param>
|
|
|
+ public void ReportRoleInfo(string type, string serverId, string serverName, string roleId, string roleName,
|
|
|
+ string roleLevel, string roleVip, string partyName, string roleBalence)
|
|
|
+ {
|
|
|
+ var data = new
|
|
|
+ {
|
|
|
+ type = HandleNullString(type),
|
|
|
+ server_id = HandleNullString(serverId),
|
|
|
+ server_name = HandleNullString(serverName),
|
|
|
+ role_id = HandleNullString(roleId),
|
|
|
+ role_name = HandleNullString(roleName),
|
|
|
+ role_level = HandleNullString(roleLevel),
|
|
|
+ role_vip = HandleNullString(roleVip),
|
|
|
+ party_name = HandleNullString(partyName),
|
|
|
+ role_balence = HandleNullString(roleBalence),
|
|
|
+ };
|
|
|
+ string roleJson = JsonConvert.SerializeObject(data);
|
|
|
+ douYouIosSDKHandler?.SDKRoleInfo(roleJson);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 辅助方法:处理空值
|
|
|
+ private static string HandleNullString(string value)
|
|
|
+ {
|
|
|
+ return string.IsNullOrEmpty(value) ? "" : value;
|
|
|
+ }
|
|
|
+
|
|
|
+ //监听的回调
|
|
|
+ public class DouYouIosSDKHandler : AbDouYouSDKIosHandler
|
|
|
+ {
|
|
|
+ public override void SDKInitWithDigitMap(string gameId, string adId, bool shouldLog)
|
|
|
+ {
|
|
|
+ base.SDKInitWithDigitMap(gameId, adId, shouldLog);
|
|
|
+ Debug.Log($"DouYouIosSDKHandler SDKInitWithDigitMap:gameId:{gameId} adId:{adId} shouldLog:{shouldLog}");
|
|
|
+ }
|
|
|
+
|
|
|
+ //调起登陆
|
|
|
+ public override void SDKLogin()
|
|
|
+ {
|
|
|
+ base.SDKLogin();
|
|
|
+ Debug.Log($"DouYouIosSDKHandler SDKLogin");
|
|
|
+ }
|
|
|
+
|
|
|
+ //退出登陆
|
|
|
+ public override void SDKLogout()
|
|
|
+ {
|
|
|
+ base.SDKLogout();
|
|
|
+ Debug.Log($"DouYouIosSDKHandler SDKLogout");
|
|
|
+ }
|
|
|
+
|
|
|
+ //调起支付
|
|
|
+ public override void SdkPaymentWithJson(string paymentJson)
|
|
|
+ {
|
|
|
+ base.SdkPaymentWithJson(paymentJson);
|
|
|
+ Debug.Log($"DouYouIosSDKHandler SdkPaymentWithJson. paymentJson:{paymentJson}");
|
|
|
+ }
|
|
|
+
|
|
|
+ //角色升级上报
|
|
|
+ public override void SDKRoleInfo(string roleJson)
|
|
|
+ {
|
|
|
+ base.SDKRoleInfo(roleJson);
|
|
|
+ Debug.Log($"DouYouIosSDKHandler SDKRoleInfo. roleJson:{roleJson}");
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 初始化成功回调
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="message"></param>
|
|
|
+ public override void InitSuccessAb(string message)
|
|
|
+ {
|
|
|
+ UniEvent.SendMessage(new LauncherEvent.InitPlatformResult() { success = true });
|
|
|
+ QDDouYouManagerInitIos.Instance.douYouSDKListenerIos?.InitSuccessAb(message);
|
|
|
+ Debug.Log($"InitSuccessAb:{message}");
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 初始化失败回调
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="message"></param>
|
|
|
+ public override void InitErrorAb(string message)
|
|
|
+ {
|
|
|
+ Debug.Log("InitErrorAb: " + message);
|
|
|
+ QDDouYouManagerInitIos.Instance.douYouSDKListenerIos?.InitErrorAb(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 登录成功回调
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="message">登录成功</param>
|
|
|
+ public override void LoginSuccessAb(string message)
|
|
|
+ {
|
|
|
+ Debug.Log("LoginSuccessAb: " + message);
|
|
|
+ QDDouYouManagerInitIos.Instance.douYouSDKListenerIos?.LoginSuccessAb(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 登录失败回调
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="message"></param>
|
|
|
+ public override void LoginErrorAb(string message)
|
|
|
+ {
|
|
|
+ Debug.Log("LoginErrorAb: " + message);
|
|
|
+ QDDouYouManagerInitIos.Instance.douYouSDKListenerIos?.LoginErrorAb(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 切换账号回调
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="message"></param>
|
|
|
+ public override void SwitchAccountsAb(string message)
|
|
|
+ {
|
|
|
+ Debug.Log("SwitchAccountsAb" + message);
|
|
|
+ QDDouYouManagerInitIos.Instance.douYouSDKListenerIos?.SwitchAccountsAb(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 登出成功回调
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="message"></param>
|
|
|
+ public override void LogoutSuccessAb(string message)
|
|
|
+ {
|
|
|
+ Debug.Log("LogoutSuccessAb" + message);
|
|
|
+ QDDouYouManagerInitIos.Instance.douYouSDKListenerIos?.LogoutSuccessAb(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 登出失败回调
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="message"></param>
|
|
|
+ public override void LogoutErrorAb(string message)
|
|
|
+ {
|
|
|
+ Debug.Log("LogoutErrorAb" + message);
|
|
|
+ QDDouYouManagerInitIos.Instance.douYouSDKListenerIos?.LogoutErrorAb(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 支付成功回调
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="message"></param>
|
|
|
+ public override void PaySuccessAb(string message)
|
|
|
+ {
|
|
|
+ Debug.Log("PaySuccessAb" + message);
|
|
|
+ QDDouYouManagerInitIos.Instance.douYouSDKListenerIos?.PaySuccessAb(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 支付失败回调
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="message"></param>
|
|
|
+ public override void PayErrorAb(string message)
|
|
|
+ {
|
|
|
+ Debug.Log("PayErrorAb" + message);
|
|
|
+ QDDouYouManagerInitIos.Instance.douYouSDKListenerIos?.PayErrorAb(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 角色升级上报成功回调
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="message"></param>
|
|
|
+ public override void RoleInfoReportSuccessAb(string message)
|
|
|
+ {
|
|
|
+ Debug.Log("RoleInfoReportSuccessAb" + message);
|
|
|
+ QDDouYouManagerInitIos.Instance.douYouSDKListenerIos?.RoleInfoReportSuccessAb(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 角色升级上报失败回调
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="message"></param>
|
|
|
+ public override void RoleInfoReportErrorAb(string message)
|
|
|
+ {
|
|
|
+ Debug.Log("RoleInfoReportErrorAb" + message);
|
|
|
+ QDDouYouManagerInitIos.Instance.douYouSDKListenerIos?.RoleInfoReportErrorAb(message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 场景(1 - 进入游戏、2 - 创建角色、3 - 角色升级、4 - 退出、5 - 充值)
|
|
|
+ /// </summary>
|
|
|
+ public enum DouYouIosRoleLogReportType
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// 进入游戏
|
|
|
+ /// </summary>
|
|
|
+ EnterGame = 1,
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 创建角色
|
|
|
+ /// </summary>
|
|
|
+ CreateRole = 2,
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 角色升级
|
|
|
+ /// </summary>
|
|
|
+ LevelUp = 3,
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 退出
|
|
|
+ /// </summary>
|
|
|
+ ExitGame = 4,
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 充值
|
|
|
+ /// </summary>
|
|
|
+ Pay = 5
|
|
|
+ }
|
|
|
+}
|