123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- using System;
- using ET;
- using UnityEngine;
- using GFGGame.Launcher;
- namespace GFGGame
- {
- public class QDDouYouManager : SingletonBase<QDDouYouManager>
- {
- public bool isLogining;
- public string uid;
- public string token;
- public void Init()
- {
- Debug.Log("实例化DouYouSDKListener");
- QDDouYouManagerInit.Instance.douYouSDKListener = new DouYouSDKListener();
- }
- public void Login()
- {
- // if (!string.IsNullOrEmpty(uid))
- // {
- // EventAgent.DispatchEvent(ConstMessage.ON_PLATFORM_SDK_LOGINED, uid);
- // return;
- // }
- // if (isLogining) return;
- // Debug.Log($"quick Login");
- // isLogining = true;
- QDDouYouManagerInit.Instance.ShowLogin();
- }
- public void OnCreateRole()
- {
- QDManager.PushRoleAction(DouYouRoleLogReportType.CreateRole);
- }
- public void OnEnterGame()
- {
- var zoneScene = GameGlobal.zoneScene;
- if (zoneScene == null) return;
-
- if (zoneScene.GetComponent<RoleInfosComponent>() == null ||
- zoneScene.GetComponent<RoleInfosComponent>().IsDisposed) return;
-
- var roleInfo = zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole();
- if (roleInfo == null) return;
-
- if (GameGlobal.myNumericComponent == null) return;
- int lvl = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
-
- if (zoneScene.GetComponent<ServerInfosComponent>() == null) return;
- if (zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo == null) return;
- string serverName = zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
- QDDouYouManagerInit.Instance.ReportRoleLogin(roleInfo.Id.ToString(), lvl.ToString(), roleInfo.Name,
- roleInfo.ServerId.ToString(), serverName);
- QDManager.PushRoleAction(DouYouRoleLogReportType.EnterGame);
- }
- public void OnQuitToLoginView()
- {
- Debug.Log($"DouYou OnQuitToLoginView");
- }
- public void Logout()
- {
- Debug.Log($"Game.HotUpdate DouYou Logout");
- QDDouYouManagerInit.Instance.ShowLogout();
- }
- public void LoginOutBefore()
- {
- QDManager.PushRoleAction(DouYouRoleLogReportType.ExitGame);
- }
- public void Pay(int buyID, int count, string orderID, long price)
- {
- ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(buyID);
- if (shopCfg == null)
- {
- Log.Error($"recharge {buyID} config not found!");
- return;
- }
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
- if (itemCfg == null)
- {
- Log.Error($"recharge {buyID} itemCfgId:{shopCfg.itemId} config not found!");
- return;
- }
- var zoneScene = GameGlobal.zoneScene;
- if (zoneScene == null) return;
-
- if (zoneScene.GetComponent<RoleInfosComponent>() == null ||
- zoneScene.GetComponent<RoleInfosComponent>().IsDisposed) return;
-
- var roleInfo = zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole();
- if (roleInfo == null) return;
-
- if (GameGlobal.myNumericComponent == null) return;
- int lvl = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
-
- if (zoneScene.GetComponent<ServerInfosComponent>() == null) return;
- if (zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo == null) return;
- string serverName = zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
- //自定义参数
- string other = orderID + "|gfg|" + roleInfo.Id;
- QDDouYouManagerInit.Instance.ShowSwitchPayment(orderID, price.ToString(), buyID.ToString(),
- shopCfg.itemName, itemCfg.desc,
- roleInfo.ServerId.ToString(), serverName, roleInfo.Id.ToString(), roleInfo.Name, lvl.ToString(), other);
- }
- public void Exit()
- {
- QDManager.PushRoleAction(DouYouRoleLogReportType.ExitGame);
- QDDouYouManagerInit.Instance.ExitApp();
- }
- }
- /// <summary>
- /// SDK回调
- /// </summary>
- public class DouYouSDKListener : IDouYouSDKListener
- {
- // /// <summary>
- // /// 测试消息
- // /// </summary>
- // /// <param name="message"></param>
- // public void ReceiveMessageAb(string message)
- // {
- // Debug.Log($"Game.HotUpdate ReceiveMessageAb:{message}");
- // }
- /// <summary>
- /// SDK实例化成功
- /// </summary>
- /// <param name="message">SDK 实例化成功</param>
- public void InitSuccessAb(string message)
- {
- Debug.Log("Game.HotUpdate InitSuccessAb: " + message);
- }
- /// <summary>
- /// 登录成功
- /// </summary>
- /// <param name="message">resUid + "|gfg|" + token</param>
- public void LoginSuccessAb(string message)
- {
- Debug.Log("Game.HotUpdate LoginSuccessAb: " + message);
- string[] result = message.Split(new string[] { "|gfg|" }, StringSplitOptions.None);
- QDDouYouManager.Instance.isLogining = false;
- QDDouYouManager.Instance.uid = result[0];
- QDDouYouManager.Instance.token = result[1];
- //登录成功的回调
- EventAgent.DispatchEvent(ConstMessage.ON_PLATFORM_SDK_LOGINED, result[0]);
- }
- /// <summary>
- /// 切换账号或退出登录后
- /// </summary>
- /// <param name="message">退出登录成功!</param>
- public void OutLoginSuccessAb(string message)
- {
- Debug.Log("Game.HotUpdate OutLoginSuccessAb: " + message);
- GameController.QuitToLoginView(true);
- EventAgent.DispatchEvent(ConstMessage.OUT_LOGIN);
- }
- /// <summary>
- /// 支付失败
- /// </summary>
- /// <param name="message">code + "|gfg|" + params.toString()</param>
- public void PayFailAb(string message)
- {
- Debug.Log("Game.HotUpdate PayFailAb: " + message);
- //改变临时订单状态为失败
- }
- /// <summary>
- /// 支付成功
- /// </summary>
- /// <param name="message">code + "|gfg|" + params.toString()</param>
- public void PaySuccessAb(string message)
- {
- Debug.Log("Game.HotUpdate PaySuccessAb" + message);
- //改变临时订单状态为支付成功
- QDManager.PushRoleAction(DouYouRoleLogReportType.Pay);
- }
- #region SDK 生命周期函数
- public void SdkOnStartAb(string message)
- {
- Debug.Log($"Game.HotUpdate SdkOnStartAb:{message}");
- }
- public void SdkOnPauseAb(string message)
- {
- Debug.Log($"Game.HotUpdate SdkOnPauseAb:{message}");
- }
- public void SdkOnResumeAb(string message)
- {
- Debug.Log($"Game.HotUpdate SdkOnResumeAb:{message}");
- }
- public void SdkOnStopAb(string message)
- {
- Debug.Log($"Game.HotUpdate SdkOnStopAb:{message}");
- }
- public void SdkOnDestroyAb(string message)
- {
- Debug.Log($"Game.HotUpdate SdkOnDestroyAb:{message}");
- }
- public void SdkOnRestartAb(string message)
- {
- Debug.Log($"Game.HotUpdate SdkOnRestartAb:{message}");
- }
- public void SdkOnBackPressedAb(string message)
- {
- Debug.Log($"Game.HotUpdate SdkOnBackPressedAb:{message}");
- }
- public void SdkOnNewIntentAb(string message)
- {
- Debug.Log($"Game.HotUpdate SdkOnNewIntentAb:{message}");
- }
- public void SdkOnConfigurationChangedAb(string message)
- {
- Debug.Log($"Game.HotUpdate SdkOnConfigurationChangedAb:{message}");
- }
- public void SdkOnSaveInstanceStateAb(string message)
- {
- Debug.Log($"Game.HotUpdate SdkOnSaveInstanceStateAb:{message}");
- }
- public void SdkOnActivityResultAb(string message)
- {
- Debug.Log($"Game.HotUpdate SdkOnActivityResultAb:{message}");
- }
- public void SdkOnRequestPermissionResultAb(string message)
- {
- Debug.Log($"Game.HotUpdate SdkOnRequestPermissionResultAb:{message}");
- }
- public void SdkOnWindowFocusChangedAb(string message)
- {
- Debug.Log($"Game.HotUpdate SdkOnWindowFocusChangedAb:{message}");
- }
- #endregion
- }
- }
|