| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 | 
							- using ET;
 
- using TapTap.Bootstrap;
 
- using TapTap.Common;
 
- using TapTap.TapDB;
 
- using Plugins.AntiAddictionUIKit;
 
- using System;
 
- using UnityEngine;
 
- namespace GFGGame
 
- {
 
-     public class PlatformTapManager : SingletonBase<PlatformTapManager>
 
-     {
 
-         private readonly string ClientID = "K7bDyPGYlVx2AAtk6q";
 
-         public void InitSDK()
 
-         {
 
-             Log.Debug($"tap InitSDK");
 
-             if (!PlatformManager.IsTaptap)
 
-             {
 
-                 return;
 
-             }
 
-             var config = new TapConfig.Builder()
 
-                 .ClientID(ClientID)
 
-                 .ClientToken("fjwWBtibB4Dj3UjyRQxK2tZ3f8fGNgg14tcRW38D")
 
-                 .ServerURL("https://k7bdypgy.cloud.tds1.tapapis.cn")
 
-                 .RegionType(RegionType.CN)
 
-                 .TapDBConfig(true, "tap", null, true)
 
-                 .ConfigBuilder();
 
-             TapBootstrap.Init(config);
 
-         }
 
-         public async ETTask<bool> LoginCache()
 
-         {
 
-             Log.Debug($"tap LoginCache");
 
-             if (!PlatformManager.IsTaptap)
 
-             {
 
-                 return false;
 
-             }
 
-             TDSUser tdsUser = await TDSUser.GetCurrent();
 
-             if (null != tdsUser)
 
-             {
 
-                 InitAntiAddiction(tdsUser.ObjectId);
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-         public async ETTask<bool> Login()
 
-         {
 
-             Log.Debug($"tap login");
 
-             if (!PlatformManager.IsTaptap)
 
-             {
 
-                 return false;
 
-             }
 
-             try
 
-             {
 
-                 var tdsUser = await TDSUser.LoginWithTapTap();
 
-                 Log.Debug($"tap login Success:{tdsUser}");
 
-                 InitAntiAddiction(tdsUser.ObjectId);
 
-                 return true;
 
-             }
 
-             catch (Exception e)
 
-             {
 
-                 if (e is TapException error)
 
-                 {
 
-                     Log.Error($"Login Error:{error.code} message:{error.message}");
 
-                     PromptController.Instance.ShowFloatTextPrompt(error.message);
 
-                 }
 
-                 else
 
-                 {
 
-                     Log.Error($"Login Error:{e}");
 
-                     PromptController.Instance.ShowFloatTextPrompt("登录异常");
 
-                 }
 
-             }
 
-             return false;
 
-         }
 
-         public void InitAntiAddiction(string objectId)
 
-         {
 
-             Log.Debug($"tap InitAntiAddiction objectId {objectId}");
 
-             string gameIdentifier = ClientID;
 
-             // 是否启用时长限制功能
 
-             bool useTimeLimit = true;
 
-             // 是否启用消费限制功能
 
-             bool usePaymentLimit = false;
 
-             // 是否显示切换账号按钮
 
-             bool showSwitchAccount = true;
 
-             AntiAddictionUIKit.Init(gameIdentifier, useTimeLimit, usePaymentLimit, showSwitchAccount,
 
-                 (antiAddictionCallbackData) =>
 
-                 {
 
-                     int code = antiAddictionCallbackData.code;
 
-                     MsgExtraParams extras = antiAddictionCallbackData.extras;
 
-                     Log.Debug($"tap antiAddictionCallbackData code {code} extras title \n{extras?.title} description \n{extras?.description}");
 
-                     // 根据 code 不同提示玩家不同信息,详见下面的说明
 
-                     if (code == 500)
 
-                     {
 
-                         ET.Log.Debug("玩家登录后判断当前玩家可以进行游戏");
 
-                         // 开始计时
 
-                         AntiAddictionUIKit.EnterGame();
 
-                         LoginController.LoginTest(objectId).Coroutine();
 
-                     }
 
-                     else if(code == 1030)
 
-                     {
 
-                         ET.Log.Debug("未成年玩家当前无法进行游戏");
 
-                     }
 
-                     else if (code == 1095)
 
-                     {
 
-                         ET.Log.Debug("未成年允许游戏弹窗");
 
-                     }
 
-                     else if (code == 1000)
 
-                     {
 
-                         ET.Log.Debug("退出账号");
 
-                     }
 
-                     else if (code == 9002)
 
-                     {
 
-                         ET.Log.Debug("实名过程中点击了关闭实名窗");
 
-                         AntiAddictionUIKit.Startup(true, objectId);
 
-                     }
 
-                     else if (code == 1001)
 
-                     {
 
-                         ET.Log.Debug("点击切换账号按钮(v1.0.2 新增)");
 
-                         GameController.QuitToLoginView(true);
 
-                     }
 
-                 },
 
-                 (exception) =>
 
-                 {
 
-                     // 处理异常
 
-                     Log.Debug($"tap exception {exception.ToString()}");
 
-                 }
 
-             );
 
-             AntiAddictionUIKit.Startup(true, objectId);
 
-         }
 
-         public void OnEnterGame()
 
-         {
 
-             Log.Debug($"tap OnEnterGame");
 
-             if (!PlatformManager.IsTaptap)
 
-             {
 
-                 return;
 
-             }
 
-             var serverInfosComponent = GameGlobal.zoneScene.GetComponent<ServerInfosComponent>();
 
-             var accountInfoComponent = GameGlobal.zoneScene.GetComponent<AccountInfoComponent>();
 
-             var roleInfosComponent = GameGlobal.zoneScene.GetComponent<RoleInfosComponent>();
 
-             var currentRole = roleInfosComponent.GetCurrentRole();
 
-             TapDB.SetUser(accountInfoComponent.Account);
 
-             TapDB.SetName(currentRole.Name);
 
-             TapDB.SetLevel(RoleDataManager.lvl);
 
-             TapDB.SetServer(serverInfosComponent.GetCurrentServerInfo().ServerName);
 
-             Log.Debug($"tap TapDB \nSetUser {accountInfoComponent.Account} \nSetName {currentRole.Name} \nSetLevel {RoleDataManager.lvl} \nSetServer {serverInfosComponent.GetCurrentServerInfo().ServerName}");
 
-         }
 
-         public void OnQuitGame()
 
-         {
 
-             Log.Debug($"tap OnQuitGame");
 
-             if (!PlatformManager.IsTaptap)
 
-             {
 
-                 return;
 
-             }
 
-             TapDB.ClearUser(); 
 
-             AntiAddictionUIKit.LeaveGame();
 
-             AntiAddictionUIKit.Logout();
 
-         }
 
-     }
 
- }
 
 
  |