Przeglądaj źródła

增加内网进入克隆服入口

guodong 1 rok temu
rodzic
commit
bc93641558

+ 43 - 26
GameClient/Assets/Game/HotUpdate/Views/Login/LoginInputView.cs

@@ -1,6 +1,9 @@
 using UI.Login;
 using FairyGUI;
 using UnityEngine;
+using System.ComponentModel;
+using System;
+using System.Collections.Generic;
 
 namespace GFGGame
 {
@@ -36,6 +39,8 @@ namespace GFGGame
             {
                 _ui.m_inputPassword.promptText = "[color=#B8A492]当前支持免密登录[/color]";
             }
+
+
         }
 
         protected override void OnShown()
@@ -46,9 +51,7 @@ namespace GFGGame
             {
                 _ui.m_inputAccount.text = account;
             }
-
-            _ui.m_boxChooseCanal.items = new string[] { "TapTap" , "好游快爆", "Bilibil", "华为", "UC九游(阿里游戏)", "小米", "VIVO", "OPPO", "4399", "联想", "应用宝", "酷派", "魅族", "雷电游戏", "QuickGame_安卓", "WAN665", "AppStore", "抖音", "测试"};
-            _ui.m_boxChooseCanal.onChanged.Add(onChangedCanal);
+            InitChanelBox();
         }
 
         protected override void OnHide()
@@ -71,8 +74,18 @@ namespace GFGGame
 
         private void onChangedCanal()
         {
-            ET.Log.Debug("打印测试======选择的渠道==========" + (_ui.m_boxChooseCanal.selectedIndex + 1));
-
+            LauncherConfig.ChannelId = int.Parse(_ui.m_boxChooseCanal.value);
+            ET.Log.Debug("打印测试======选择的渠道==========" + (_ui.m_boxChooseCanal.value));
+            if(_ui.m_boxChooseCanal.value == (int)ChannelID.Test + "")
+            {
+                AlertSystem.Show("切换其他渠道后不支持切回测试渠道,请重启游戏!")
+                    .SetRightButton(true, "退出游戏", (obj) => { Application.Quit(); });
+            }
+            else
+            {
+                GameConfig.LoginAddress = "http://10.108.64.127:10005";
+            }
+            ET.Log.Debug($"===选择的渠道=== {_ui.m_boxChooseCanal.value} {GameConfig.LoginAddress}");
         }
 
         private void OnClickBtnSure()
@@ -103,27 +116,6 @@ namespace GFGGame
             this.Hide();
         }
 
-        //private void OnClickBtnTourist()
-        //{
-        //    if (GameGlobal.isOfflineVisitor)
-        //    {
-        //        LoginProxy.LoginAsVisitor();
-        //    }
-        //    else
-        //    {
-        //        Alert.Show("游客账号无法保证您的账号安全,且受到充值和时长限制,无法体验全部游戏内容。强烈建议您注册账号登录游戏。")
-        //        .SetLeftButton(true, "进入游戏", (object data) =>
-        //        {
-        //            LoginProxy.LoginAsVisitor();
-        //        })
-        //        .SetRightButton(true, "前往注册", (object data) =>
-        //        {
-        //            ViewManager.Show<RegisterView>();
-        //        })
-        //        .SetClickBlankToClose(true);
-        //    }
-        //}
-
         private void OnClickBtnRegister()
         {
             ViewManager.Show<RegisterView>();
@@ -135,5 +127,30 @@ namespace GFGGame
             _ui.m_inputAccount.text = account;
         }
 
+        private void InitChanelBox()
+        {
+            _ui.m_boxChooseCanal.visible = LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL;
+            if (!_ui.m_boxChooseCanal.visible) return;
+
+            var enumType = typeof(ChannelID);
+            var arr = Enum.GetValues(enumType);
+            List<string> items = new List<string>();
+            List<string> numbers = new List<string>();
+            foreach (var value in arr)
+            {
+                var fieldInfo = enumType.GetField((value).ToString());
+
+                if (fieldInfo != null && Attribute.IsDefined(fieldInfo, typeof(DescriptionAttribute)))
+                {
+                    DescriptionAttribute attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute));
+                    items.Add(attribute.Description);
+                    numbers.Add(Convert.ToInt32(value).ToString());
+                }
+            }
+            _ui.m_boxChooseCanal.items = items.ToArray();
+            _ui.m_boxChooseCanal.values = numbers.ToArray();
+            _ui.m_boxChooseCanal.value = LauncherConfig.ChannelId + "";
+            _ui.m_boxChooseCanal.onChanged.Add(onChangedCanal);
+        }
     }
 }