소스 검색

tap登录

# Conflicts:
#	GameClient/Assets/Game/HotUpdate/Views/Login/LoginView.cs
guodong 3 년 전
부모
커밋
869ba181dc

+ 1 - 1
FGUIProject/assets/Login/LoginUI.xml

@@ -28,7 +28,7 @@
     <component id="n13_es2q" name="btnAge" src="es2q5i" fileName="components/Button5.xml" xy="924,1740">
       <relation target="" sidePair="right-right,bottom-bottom"/>
     </component>
-    <component id="n15_pwpm" name="btnTapLogin" src="pwpm5k" fileName="components/ButtonTapLogin.xml" xy="333,1837">
+    <component id="n15_pwpm" name="btnTapLogin" src="pwpm5k" fileName="components/ButtonTapLogin.xml" xy="333,1549">
       <relation target="" sidePair="bottom-bottom"/>
     </component>
   </displayList>

+ 2 - 6
GameClient/Assets/Game/HotUpdate/Controller/GameController.cs

@@ -95,7 +95,7 @@ namespace GFGGame
 
         public static async ETTask PreEnterGameAsync()
         {
-            PlatformTapManager.OnEnterGame();
+            PlatformTapManager.Instance.OnEnterGame();
             RoleDataHandler.StartUpdate();
 
             GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("CommonGame"));
@@ -139,7 +139,7 @@ namespace GFGGame
 
         public static void QuitToLoginView(bool logout)
         {
-            PlatformTapManager.OnQuitGame();
+            PlatformTapManager.Instance.OnQuitGame();
             GameGlobal.isVisitor = false;
             GameGlobal.antiAddiction = true;
             GameGlobal.userId = 0;
@@ -167,10 +167,6 @@ namespace GFGGame
                 Logout().Coroutine();
             }
             ViewManager.Show<LoginView>(null, null, true);
-            if (logout)
-            {
-                ViewManager.Show<LoginInputView>();
-            }
             LoginController.Logout();
         }
 

+ 1 - 2
GameClient/Assets/Game/HotUpdate/Controller/LoginController.cs

@@ -124,8 +124,7 @@ namespace GFGGame
             ViewManager.Hide<ModalStatusView>();
             if (ErrorCodeController.Handler(errorCode))
             {
-                PlatformTapManager.OnQuitGame();
-                ViewManager.Show<LoginInputView>();
+                GameController.QuitToLoginView(true);
             }
         }
 

+ 2 - 1
GameClient/Assets/Game/HotUpdate/Game.HotUpdate.asmdef

@@ -3,7 +3,8 @@
     "rootNamespace": "",
     "references": [
         "GUID:065d51621aad9d6498c45bc251a1d8e4",
-        "GUID:7a41fac89c3ce014e99efb3723e6a98e"
+        "GUID:7a41fac89c3ce014e99efb3723e6a98e",
+        "GUID:7b430a36dc40f416cbc65566155a0e56"
     ],
     "includePlatforms": [
         "Editor"

+ 1 - 0
GameClient/Assets/Game/HotUpdate/GameConfig.cs

@@ -13,6 +13,7 @@ namespace GFGGame
 
         public static void InitData(string json)
         {
+            ET.Log.Debug($"gamecfg \n{json}");
             var result = JsonMapper.ToObject<Result>(json);
             LoginAddress = result.loginApiUrl;
             PlatformName = result.platformName;

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Platform/PlatformManager.cs

@@ -7,7 +7,7 @@
             switch(GameConfig.PlatformName)
             {
                 case PlatformName.TapTap:
-                    PlatformTapManager.InitSDK();
+                    PlatformTapManager.Instance.InitSDK();
                     break;
             }
         }

+ 114 - 27
GameClient/Assets/Game/HotUpdate/Platform/PlatformTapManager.cs

@@ -2,57 +2,140 @@
 using TapTap.Bootstrap;
 using TapTap.Common;
 using TapTap.TapDB;
-//using Plugins.AntiAddictionUIKit;
+using Plugins.AntiAddictionUIKit;
+using System;
+using UnityEngine;
 
 namespace GFGGame
 {
-    public class PlatformTapManager
+    public class PlatformTapManager : SingletonBase<PlatformTapManager>
     {
-        public static void InitSDK()
+        private readonly string ClientID = "K7bDyPGYlVx2AAtk6q";
+        public void InitSDK()
         {
+            Log.Debug($"tap InitSDK");
             if (!PlatformManager.IsTaptap)
             {
                 return;
             }
             var config = new TapConfig.Builder()
-                .ClientID("K7bDyPGYlVx2AAtk6q")
+                .ClientID(ClientID)
                 .ClientToken("fjwWBtibB4Dj3UjyRQxK2tZ3f8fGNgg14tcRW38D")
                 .ServerURL("https://k7bdypgy.cloud.tds1.tapapis.cn")
                 .RegionType(RegionType.CN)
                 .TapDBConfig(true, "tap", null, true)
                 .ConfigBuilder();
             TapBootstrap.Init(config);
+        }
 
-            string gameIdentifier = "游戏的 Client ID";
+        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 = true;
+            bool usePaymentLimit = false;
             // 是否显示切换账号按钮
-            bool showSwitchAccount = false;
+            bool showSwitchAccount = true;
 
-            //AntiAddictionUIKit.Init(gameIdentifier, useTimeLimit, usePaymentLimit, showSwitchAccount,
-            //    (antiAddictionCallbackData) => {
-            //        int code = antiAddictionCallbackData.code;
-            //        MsgExtraParams extras = antiAddictionCallbackData.extras;
-            //    // 根据 code 不同提示玩家不同信息,详见下面的说明
-            //    if (code == 500)
-            //        {
-            //        // 开始计时
-            //        AntiAddictionUIKit.EnterGame();
-            //            Debug.Log("玩家登录后判断当前玩家可以进行游戏");
-            //        }
+            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()}");
+                }
+            );
 
-            //    },
-            //    (exception) => {
-            //    // 处理异常
-            //}
-            //);
+            AntiAddictionUIKit.Startup(true, objectId);
         }
 
-        public static void OnEnterGame()
+        public void OnEnterGame()
         {
-            if(!PlatformManager.IsTaptap)
+            Log.Debug($"tap OnEnterGame");
+            if (!PlatformManager.IsTaptap)
             {
                 return;
             }
@@ -64,15 +147,19 @@ namespace GFGGame
             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 static void OnQuitGame()
+        public void OnQuitGame()
         {
+            Log.Debug($"tap OnQuitGame");
             if (!PlatformManager.IsTaptap)
             {
                 return;
             }
-            TapDB.ClearUser();
+            TapDB.ClearUser(); 
+            AntiAddictionUIKit.LeaveGame();
+            AntiAddictionUIKit.Logout();
         }
     }
 }

+ 15 - 38
GameClient/Assets/Game/HotUpdate/Views/Login/LoginView.cs

@@ -84,29 +84,23 @@ namespace GFGGame
         {
             if (PlatformManager.IsTaptap)//taptap平台
             {
-                TDSUser currentUser = await TDSUser.GetCurrent();
-                if (null == currentUser)
+                var success = await PlatformTapManager.Instance.LoginCache();
+                _ui.m_btnTapLogin.visible = !success;
+                _ui.m_btnStart.visible = success;
+            }
+            else//自有登录
+            {
+                _ui.m_btnStart.visible = true;
+                //尝试自动登录
+                if (serverInfosComponent.ServerInfoList.Count <= 0)
                 {
-                    _ui.m_btnTapLogin.visible = true;
+                    OnClickBtnStart();
                 }
-                else
+                if (!_ui.m_btnLogout.visible)
                 {
-                    LoginController.LoginTest(currentUser.ObjectId).Coroutine();
+                    ViewManager.Show<LoginInputView>();
                 }
             }
-            //else//自有登录
-            //{
-            _ui.m_btnStart.visible = true;
-            //尝试自动登录
-            if (serverInfosComponent.ServerInfoList.Count <= 0)
-            {
-                OnClickBtnStart();
-            }
-            if (!_ui.m_btnLogout.visible)
-            {
-                ViewManager.Show<LoginInputView>();
-            }
-            //}
         }
 
         private void OnClickBtnTabLogin()
@@ -116,26 +110,9 @@ namespace GFGGame
 
         private async ETTask OnClickBtnTabLoginAsync()
         {
-            try
-            {
-                var tdsUser = await TDSUser.LoginWithTapTap();
-                Log.Debug($"tap login Success:{tdsUser}");
-                _ui.m_btnTapLogin.visible = false;
-                LoginController.LoginTest(tdsUser.ObjectId).Coroutine();
-            }
-            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("登录异常");
-                }
-            }
+            var success = await PlatformTapManager.Instance.Login();
+            _ui.m_btnTapLogin.visible = !success;
+            _ui.m_btnStart.visible = success;
         }
 
         private void UpdateServer(ServerInfo info)

+ 4 - 1
GameClient/Assets/Game/Launcher/LauncherConfig.cs

@@ -26,6 +26,7 @@ namespace GFGGame
         public static string apkVersion;
         public static int serverStatus;
         public static int onDebug;
+        public static string manifest_v;
 
         public static string resKey
         {
@@ -47,7 +48,7 @@ namespace GFGGame
             cfgName = "cfg_dev";
 #elif PT_TEMP
             netType = EnumNetType.TEMP;
-            cfgName = "cfg_temp1";
+            cfgName = "cfg_temp";
 #else
             netType = EnumNetType.LOCAL;
             cfgName = "cfg_local";
@@ -69,6 +70,7 @@ namespace GFGGame
             LauncherConfig.serverStatus = int.Parse(result.serverStatus);
             LauncherConfig.platformId = int.Parse(result.platformId);
             LauncherConfig.onDebug = int.Parse(result.onDebug);
+            LauncherConfig.manifest_v = result.manifest_v;
             ET.Log.Debug($"platformId {LauncherConfig.platformId}");
         }
 
@@ -82,6 +84,7 @@ namespace GFGGame
             public string serverStatus;
             public string platformId;
             public string onDebug;
+            public string manifest_v;
         }
 
     }

BIN
GameClient/Assets/ResIn/UI/Login/Login_fui.bytes