diff --git a/FantasyNetTest.sln.DotSettings.user b/FantasyNetTest.sln.DotSettings.user index 059cde6..bfe1e53 100644 --- a/FantasyNetTest.sln.DotSettings.user +++ b/FantasyNetTest.sln.DotSettings.user @@ -1,10 +1,12 @@  ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded diff --git a/FantasyNetTest/Config.json b/FantasyNetTest/Config.json index 9dde6ee..6de0053 100644 --- a/FantasyNetTest/Config.json +++ b/FantasyNetTest/Config.json @@ -1,5 +1,5 @@ { "Server": "127.0.0.1:20001", "Heartbeat": 5, - "ProtocolScriptPath": "D:\\work\\Fishing2\\Assets\\Scripts\\Generate" + "ProtocolScriptPath": "D:\\myself\\Games\\Fishing2\\Assets\\Scripts\\Generate\\NetworkProtocol" } \ No newline at end of file diff --git a/FantasyNetTest/Form1.cs b/FantasyNetTest/Form1.cs index b47d723..275b880 100644 --- a/FantasyNetTest/Form1.cs +++ b/FantasyNetTest/Form1.cs @@ -46,7 +46,7 @@ public partial class Form1 : Form _scriptLoader = new ScriptLoader(); - + SetAccountComboBox(); var time = UnityEngine.Time.time; Log.Init(logTextBox); InitProtocol(); @@ -57,7 +57,7 @@ public partial class Form1 : Form LoadProtocol(); StartAsync().Coroutine(); } - + private void SwitchLoginButtonState() { if (_session == null) @@ -141,6 +141,16 @@ public partial class Form1 : Form private Session? _session; + private void SetAccountComboBox() + { + comboBoxAccount.Items.Clear(); + + foreach (var type in _config.Accounts) + { + comboBoxAccount.Items.Add(type); + } + } + private async FTask OnLoginButtonClick(string account) { // 根据用户名来选择目标的鉴权服务器 @@ -240,40 +250,6 @@ public partial class Form1 : Form Log.Succeed($"登录到Gate服务器成功!ErrorCode:{responseGate.ErrorCode}"); - // // 发送登录的请求给服务器 - // var response = (A2C_LoginResponse)await _session.Call(new C2A_LoginRequest() - // { - // Username = acc, - // Password = acc, - // LoginType = 1 - // }); - // - // if (response.ErrorCode != 0) - // { - // Log.Error($"登录发生错误{response.ErrorCode}"); - // return; - // } - // - // if (!_scene.GetComponent().Parse(response.ToKen, out var payload)) - // { - // return; - // } - // - // // 根据ToKen返回的Address登录到Gate服务器 - // _session = SessionHelper.CreateSession(_scene, payload.Address, OnConnectComplete, OnConnectFail, - // OnConnectDisconnect); - // // 发送登录请求到Gate服务器 - // var loginResponse = (G2C_LoginResponse)await _session.Call(new C2G_LoginRequest() - // { - // ToKen = response.ToKen - // }); - // if (loginResponse.ErrorCode != 0) - // { - // Log.Error($"登录发生错误{loginResponse.ErrorCode}"); - // return; - // } - // - // Log.Succeed($"登录到Gate服务器成功!ErrorCode:{loginResponse.ErrorCode}"); SwitchLoginButtonState(); } @@ -315,6 +291,10 @@ public partial class Form1 : Form _config.Server = cfg.Server; _config.Heartbeat = cfg.Heartbeat; _config.ProtocolScriptPath = cfg.ProtocolScriptPath; + foreach (var cfgAccount in cfg.Accounts) + { + _config.Accounts.Add(cfgAccount); + } } } } @@ -326,6 +306,7 @@ public partial class Form1 : Form var configPath = Path.Combine(Application.StartupPath, "Config.json"); var json = JsonSerializer.Serialize(_config); File.WriteAllText(configPath, json); + SetAccountComboBox(); } #endregion @@ -478,38 +459,17 @@ public partial class Form1 : Form }; inputControl = checkbox; } - else if (property.PropertyType == typeof(int) || property.PropertyType == typeof(long) || - property.PropertyType == typeof(double) || - property.PropertyType == typeof(decimal) || property.PropertyType == typeof(float)) + else if (property.PropertyType == typeof(int) || property.PropertyType == typeof(decimal) || + property.PropertyType == typeof(uint) || property.PropertyType == typeof(double) || + property.PropertyType == typeof(float) || property.PropertyType == typeof(long) || + property.PropertyType == typeof(short)) { var numericBox = new NumericUpDown { - Value = Convert.ToDecimal(property.GetValue(configObject)), - Dock = DockStyle.Fill, Minimum = decimal.MinValue, - Maximum = decimal.MaxValue - }; - inputControl = numericBox; - } - else if (property.PropertyType == typeof(uint)) - { - var numericBox = new NumericUpDown - { + Maximum = decimal.MaxValue, Value = Convert.ToDecimal(property.GetValue(configObject)), Dock = DockStyle.Fill, - Minimum = uint.MinValue, - Maximum = uint.MaxValue - }; - inputControl = numericBox; - } - else if (property.PropertyType == typeof(short)) - { - var numericBox = new NumericUpDown - { - Value = Convert.ToDecimal(property.GetValue(configObject)), - Dock = DockStyle.Fill, - Minimum = short.MinValue, - Maximum = short.MaxValue }; inputControl = numericBox; } @@ -613,6 +573,8 @@ public partial class Form1 : Form property.SetValue(configObject, (float)numericBox.Value); else if (property.PropertyType == typeof(short)) property.SetValue(configObject, (short)numericBox.Value); + else if (property.PropertyType == typeof(long)) + property.SetValue(configObject, (long)numericBox.Value); } else if (inputControl is TextBox textBox) { diff --git a/FantasyNetTest/NBC.zip b/FantasyNetTest/NBC.zip deleted file mode 100644 index 786802e..0000000 Binary files a/FantasyNetTest/NBC.zip and /dev/null differ diff --git a/FantasyNetTest/Network.zip b/FantasyNetTest/Network.zip deleted file mode 100644 index 95eccaf..0000000 Binary files a/FantasyNetTest/Network.zip and /dev/null differ