diff --git a/Assets/Resources/Fgui/Common/Common_fui.bytes b/Assets/Resources/Fgui/Common/Common_fui.bytes
index c3a454bfd..b3599cc62 100644
Binary files a/Assets/Resources/Fgui/Common/Common_fui.bytes and b/Assets/Resources/Fgui/Common/Common_fui.bytes differ
diff --git a/Assets/Resources/Fgui/Main/Main_fui.bytes b/Assets/Resources/Fgui/Main/Main_fui.bytes
index be3fd8958..da95ae219 100644
Binary files a/Assets/Resources/Fgui/Main/Main_fui.bytes and b/Assets/Resources/Fgui/Main/Main_fui.bytes differ
diff --git a/Assets/Scripts/NBC/Runtime/Core/Network/Message/Dispatcher/Interface/IMessageHandler.cs b/Assets/Scripts/NBC/Runtime/Core/Network/Message/Dispatcher/Interface/IMessageHandler.cs
index 2ff697fd3..047660f05 100644
--- a/Assets/Scripts/NBC/Runtime/Core/Network/Message/Dispatcher/Interface/IMessageHandler.cs
+++ b/Assets/Scripts/NBC/Runtime/Core/Network/Message/Dispatcher/Interface/IMessageHandler.cs
@@ -55,6 +55,7 @@ namespace NBC.Network.Interface
{
try
{
+
await Run(session, (T) message);
}
catch (Exception e)
diff --git a/Assets/Scripts/NBC/Runtime/Core/Network/Message/Dispatcher/MessageDispatcherComponent.cs b/Assets/Scripts/NBC/Runtime/Core/Network/Message/Dispatcher/MessageDispatcherComponent.cs
index 421cb5545..2ae6d013f 100644
--- a/Assets/Scripts/NBC/Runtime/Core/Network/Message/Dispatcher/MessageDispatcherComponent.cs
+++ b/Assets/Scripts/NBC/Runtime/Core/Network/Message/Dispatcher/MessageDispatcherComponent.cs
@@ -274,67 +274,6 @@ namespace NBC.Network.Interface
messageHandler.Handle(session, rpcId, protocolCode, message).Coroutine();
}
- // 如果编译符号FANTASY_NET存在,定义处理路由消息的方法
-#if FANTASY_NET
- ///
- /// 处理路由消息,将消息分发给相应的路由消息处理器。
- ///
- /// 会话对象
- /// 消息类型
- /// 实体对象
- /// 消息对象
- /// RPC标识
- public async FTask RouteMessageHandler(Session session, Type type, Entity entity, object message, uint rpcId)
- {
- if (!_routeMessageHandlers.TryGetValue(type, out var routeMessageHandler))
- {
- Log.Warning($"Scene:{session.Scene.Id} Found Unhandled RouteMessage: {message.GetType()}");
-
- if (message is IRouteRequest request)
- {
- FailRouteResponse(session, request.GetType(), InnerErrorCode.ErrEntityNotFound, rpcId);
- }
-
- return;
- }
-
- var runtimeId = entity.RuntimeId;
- var sessionRuntimeId = session.RuntimeId;
-
- if (entity is Scene)
- {
- // 如果是Scene的话、就不要加锁了、如果加锁很一不小心就可能会造成死锁
- await routeMessageHandler.Handle(session, entity, rpcId, message);
- return;
- }
-
- // 使用协程锁来确保多线程安全
- using (await _receiveRouteMessageLock.Wait(runtimeId))
- {
- if (sessionRuntimeId != session.RuntimeId)
- {
- return;
- }
-
- if (runtimeId != entity.RuntimeId)
- {
- if (message is IRouteRequest request)
- {
- FailRouteResponse(session, request.GetType(), InnerErrorCode.ErrEntityNotFound, rpcId);
- }
-
- return;
- }
-
- await routeMessageHandler.Handle(session, entity, rpcId, message);
- }
- }
-
- internal bool GetCustomRouteType(long protocolCode, out int routeType)
- {
- return _customRouteMap.TryGetValue(protocolCode, out routeType);
- }
-#endif
internal void FailRouteResponse(Session session, Type requestType, uint error, uint rpcId)
{
var response = CreateRouteResponse(requestType, error);
diff --git a/Assets/Scripts/Net/Net.cs b/Assets/Scripts/Net/Net.cs
new file mode 100644
index 000000000..f488db1e7
--- /dev/null
+++ b/Assets/Scripts/Net/Net.cs
@@ -0,0 +1,75 @@
+using Assets.Scripts.Entity;
+using Assets.Scripts.Hotfix;
+using NBC;
+using NBC.Network;
+using NBC.Network.Interface;
+
+namespace NBF
+{
+ public class Net : EventDispatcher
+ {
+ public static Session Session { get; private set; }
+
+ public const int HeartbeatInterval = 5000;
+
+ #region 单例
+
+ private static Net _inst;
+
+ public static Net Inst => _inst ??= new Net();
+
+ public Net()
+ {
+ }
+
+ #endregion
+
+ #region 连接创建和回调
+
+ public static Session CreateSession(string address)
+ {
+ var session = SessionHelper.CreateSession(App.Main, address, OnConnectComplete,
+ OnConnectFail,
+ OnConnectDisconnect);
+
+ Session = session;
+ return session;
+ }
+
+ private static void OnConnectComplete()
+ {
+ Log.Debug("连接成功");
+ Session.AddComponent().Start(HeartbeatInterval);
+ }
+
+ private static void OnConnectFail()
+ {
+ Log.Debug("连接失败");
+ // SetLoginState(false);
+ }
+
+ private static void OnConnectDisconnect()
+ {
+ Log.Debug("连接断开");
+ // SetLoginState(false);
+ }
+
+ #endregion
+
+ #region 消息收发
+
+ public static FTask Call(IRequest request, long routeId = 0)
+ {
+ // var response = await Session.Call(request, routeId);
+ // response.DispatchMessage();
+ return Session.Call(request, routeId);;
+ }
+
+ public static void Send(IMessage message, uint rpcId = 0, long routeId = 0)
+ {
+ Session.Send(message, rpcId, routeId);
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Net/Net.cs.meta b/Assets/Scripts/Net/Net.cs.meta
new file mode 100644
index 000000000..901c251c4
--- /dev/null
+++ b/Assets/Scripts/Net/Net.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 1fe56eeffd614eaea7055d1c65f6859f
+timeCreated: 1755701226
\ No newline at end of file
diff --git a/Assets/Scripts/Net/NetExtends.cs b/Assets/Scripts/Net/NetExtends.cs
new file mode 100644
index 000000000..01a66a128
--- /dev/null
+++ b/Assets/Scripts/Net/NetExtends.cs
@@ -0,0 +1,12 @@
+using NBC.Network.Interface;
+
+namespace NBF
+{
+ public static class NetExtends
+ {
+ public static void DispatchMessage(this IResponse response)
+ {
+ Net.Inst.DispatchEventWith(response.OpCode().ToString(), response);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Net/NetExtends.cs.meta b/Assets/Scripts/Net/NetExtends.cs.meta
new file mode 100644
index 000000000..bca84f9d5
--- /dev/null
+++ b/Assets/Scripts/Net/NetExtends.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 25d56f7c87744a199e926365a516b85f
+timeCreated: 1755702255
\ No newline at end of file
diff --git a/Assets/Scripts/Startup/Init.cs b/Assets/Scripts/Startup/Init.cs
index 67364d641..39da618d1 100644
--- a/Assets/Scripts/Startup/Init.cs
+++ b/Assets/Scripts/Startup/Init.cs
@@ -132,9 +132,11 @@ namespace NBF
// UI.Inst.OpenUI();
LoadData();
CommonTopPanel.Show();
+ LoginPanel.Show();
// FishingPanel.Show();
- PreviewPanel.Show();
- Fishing.Inst.Go(1);
+ // PreviewPanel.Show();
+
+ // Fishing.Inst.Go(1);
// HomePanel.Show();
// ChatTestPanel.Show();
diff --git a/Assets/Scripts/UI/Binders/CommonBinder.cs b/Assets/Scripts/UI/Binders/CommonBinder.cs
index 0972390c5..07b121422 100644
--- a/Assets/Scripts/UI/Binders/CommonBinder.cs
+++ b/Assets/Scripts/UI/Binders/CommonBinder.cs
@@ -12,6 +12,7 @@ namespace NBF
UIObjectFactory.SetPackageItemExtension(SelectPages.URL, typeof(SelectPages));
UIObjectFactory.SetPackageItemExtension(ModelTexture.URL, typeof(ModelTexture));
UIObjectFactory.SetPackageItemExtension(BottomMenu.URL, typeof(BottomMenu));
+ UIObjectFactory.SetPackageItemExtension(CommonInput.URL, typeof(CommonInput));
UIObjectFactory.SetPackageItemExtension(ClassifyList.URL, typeof(ClassifyList));
UIObjectFactory.SetPackageItemExtension(CommonMenu.URL, typeof(CommonMenu));
UIObjectFactory.SetPackageItemExtension(MarqueeTag.URL, typeof(MarqueeTag));
diff --git a/Assets/Scripts/UI/Common/CommonInput.Designer.cs b/Assets/Scripts/UI/Common/CommonInput.Designer.cs
new file mode 100644
index 000000000..9b4d5a314
--- /dev/null
+++ b/Assets/Scripts/UI/Common/CommonInput.Designer.cs
@@ -0,0 +1,29 @@
+/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
+
+
+using FairyGUI;
+using FairyGUI.Utils;
+using NBC;
+
+namespace NBF
+{
+ public partial class CommonInput
+ {
+ public const string URL = "ui://6hgkvlau9zboma";
+
+ public Controller FocusState;
+ public GTextInput Input;
+ public GImage bottomBack;
+
+ public override void ConstructFromXML(XML xml)
+ {
+ base.ConstructFromXML(xml);
+
+ FocusState = GetController("FocusState");
+ Input = (GTextInput)GetChild("Input");
+ bottomBack = (GImage)GetChild("bottomBack");
+ OnInited();
+ UILanguage.TrySetComponentLanguage(this);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/Common/CommonInput.Designer.cs.meta b/Assets/Scripts/UI/Common/CommonInput.Designer.cs.meta
new file mode 100644
index 000000000..ba80ab955
--- /dev/null
+++ b/Assets/Scripts/UI/Common/CommonInput.Designer.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: fb776407f4f25e64a8e803ba135bddef
\ No newline at end of file
diff --git a/Assets/Scripts/UI/Common/CommonInput.cs b/Assets/Scripts/UI/Common/CommonInput.cs
new file mode 100644
index 000000000..5a310ba36
--- /dev/null
+++ b/Assets/Scripts/UI/Common/CommonInput.cs
@@ -0,0 +1,47 @@
+// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
+
+using UnityEngine;
+using FairyGUI;
+using NBC;
+
+namespace NBF
+{
+ public partial class CommonInput : GComponent
+ {
+ public EventListener onChanged => Input.onChanged;
+
+ public override string text
+ {
+ get => Input.text;
+ set => Input.text = value;
+ }
+
+ public string title
+ {
+ get => text;
+ set => text = value;
+ }
+
+ public string promptText
+ {
+ get => Input.promptText;
+ set => Input.promptText = value;
+ }
+
+ private void OnInited()
+ {
+ onFocusIn.Add(OnInputFocusIn);
+ onFocusOut.Add(OnInputFocusOut);
+ }
+
+ private void OnInputFocusIn()
+ {
+ FocusState.selectedIndex = 1;
+ }
+
+ private void OnInputFocusOut()
+ {
+ FocusState.selectedIndex = 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/Common/CommonInput.cs.meta b/Assets/Scripts/UI/Common/CommonInput.cs.meta
new file mode 100644
index 000000000..11e371554
--- /dev/null
+++ b/Assets/Scripts/UI/Common/CommonInput.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: c7adc7972d1d401489dc796fb27d1eaa
\ No newline at end of file
diff --git a/Assets/Scripts/UI/Login.meta b/Assets/Scripts/UI/Login.meta
new file mode 100644
index 000000000..38f4f0677
--- /dev/null
+++ b/Assets/Scripts/UI/Login.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 12482424a8714a5fb52ce23312a0a0f6
+timeCreated: 1755697902
\ No newline at end of file
diff --git a/Assets/Scripts/UI/Login/LoginHelper.cs b/Assets/Scripts/UI/Login/LoginHelper.cs
new file mode 100644
index 000000000..0763a30f7
--- /dev/null
+++ b/Assets/Scripts/UI/Login/LoginHelper.cs
@@ -0,0 +1,54 @@
+using Assets.Scripts.Entity;
+using Assets.Scripts.Hotfix;
+using NBC;
+using NBC.Network;
+
+namespace NBF
+{
+ public static class LoginHelper
+ {
+ private static Session _session;
+
+ public static async FTask Login(string account)
+ {
+ _session = Net.CreateSession("127.0.0.1:20001");
+
+ var acc = account;
+
+ // 发送登录的请求给服务器
+ var response = (A2C_LoginResponse)await Net.Call(new C2A_LoginRequest()
+ {
+ Username = acc,
+ Password = acc,
+ LoginType = 1
+ });
+
+ if (response.ErrorCode != 0)
+ {
+ Log.Error($"登录发生错误{response.ErrorCode}");
+ return;
+ }
+
+ if (!App.Main.GetComponent().Parse(response.ToKen, out var payload))
+ {
+ return;
+ }
+
+ // 根据ToKen返回的Address登录到Gate服务器
+ _session = Net.CreateSession(payload.Address);
+
+ // 发送登录请求到Gate服务器
+ var loginResponse = (G2C_LoginResponse)await Net.Call(new C2G_LoginRequest()
+ {
+ ToKen = response.ToKen
+ });
+ if (loginResponse.ErrorCode != 0)
+ {
+ Log.Error($"登录发生错误{loginResponse.ErrorCode}");
+ return;
+ }
+
+ Log.Debug($"登录到Gate服务器成功!ErrorCode:{loginResponse.ErrorCode}");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/Login/LoginHelper.cs.meta b/Assets/Scripts/UI/Login/LoginHelper.cs.meta
new file mode 100644
index 000000000..c2ec3022e
--- /dev/null
+++ b/Assets/Scripts/UI/Login/LoginHelper.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 031ed023449844cdb9d6c4eb5d7fee90
+timeCreated: 1755698636
\ No newline at end of file
diff --git a/Assets/Scripts/UI/Login/LoginPanel.Designer.cs b/Assets/Scripts/UI/Login/LoginPanel.Designer.cs
new file mode 100644
index 000000000..adde27e5f
--- /dev/null
+++ b/Assets/Scripts/UI/Login/LoginPanel.Designer.cs
@@ -0,0 +1,32 @@
+/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
+
+using FairyGUI;
+using FairyGUI.Utils;
+using NBC;
+using System.Collections.Generic;
+
+namespace NBF
+{
+ ///
+ public partial class LoginPanel
+ {
+ public GObject this[string aKey] => ContentPane.GetChild(aKey);
+ public override string UIPackName => "Main";
+ public override string UIResName => "LoginPanel";
+
+ [AutoFind(Name = "Back")]
+ public GLabel Back;
+ [AutoFind(Name = "InputAccount")]
+ public CommonInput InputAccount;
+ [AutoFind(Name = "BtnLogin")]
+ public GButton BtnLogin;
+ public override string[] GetDependPackages(){ return new string[] {"Common"}; }
+
+ public static void Show(object param = null){ App.UI.OpenUI(param); }
+
+ public static void Hide(){ App.UI.HideUI(); }
+
+ public static void Del(){ App.UI.DestroyUI(); }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/Login/LoginPanel.Designer.cs.meta b/Assets/Scripts/UI/Login/LoginPanel.Designer.cs.meta
new file mode 100644
index 000000000..c674924f4
--- /dev/null
+++ b/Assets/Scripts/UI/Login/LoginPanel.Designer.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 3b11ed3a4a10a3549a06d7845c9c4cfd
\ No newline at end of file
diff --git a/Assets/Scripts/UI/Login/LoginPanel.cs b/Assets/Scripts/UI/Login/LoginPanel.cs
new file mode 100644
index 000000000..5569c677c
--- /dev/null
+++ b/Assets/Scripts/UI/Login/LoginPanel.cs
@@ -0,0 +1,25 @@
+// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
+
+using FairyGUI;
+using UnityEngine;
+using NBC;
+using UIPanel = NBC.UIPanel;
+
+namespace NBF
+{
+ public partial class LoginPanel : UIPanel
+ {
+ protected override void OnInit()
+ {
+ this.AutoAddClick(OnClick);
+ }
+
+ private void OnClick(GComponent btn)
+ {
+ if (btn == BtnLogin)
+ {
+ LoginHelper.Login(InputAccount.text).Coroutine();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/Login/LoginPanel.cs.meta b/Assets/Scripts/UI/Login/LoginPanel.cs.meta
new file mode 100644
index 000000000..0775b510a
--- /dev/null
+++ b/Assets/Scripts/UI/Login/LoginPanel.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: b2d32e54ef5680541959b782ee8d0c7a
\ No newline at end of file
diff --git a/FGUIProject/assets/Common/Com/Buttons/BtnCommon.xml b/FGUIProject/assets/Common/Com/Buttons/BtnCommon.xml
index 1e7527056..63b95d17d 100644
--- a/FGUIProject/assets/Common/Com/Buttons/BtnCommon.xml
+++ b/FGUIProject/assets/Common/Com/Buttons/BtnCommon.xml
@@ -1,11 +1,15 @@
-
-
+
+
-
-
-
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/FGUIProject/assets/Common/Com/Inputs/CommonInput.xml b/FGUIProject/assets/Common/Com/Inputs/CommonInput.xml
new file mode 100644
index 000000000..ebf9138a0
--- /dev/null
+++ b/FGUIProject/assets/Common/Com/Inputs/CommonInput.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FGUIProject/assets/Common/package.xml b/FGUIProject/assets/Common/package.xml
index 23ecdc774..aa954a0db 100644
--- a/FGUIProject/assets/Common/package.xml
+++ b/FGUIProject/assets/Common/package.xml
@@ -4,7 +4,6 @@
-
@@ -221,6 +220,8 @@
+
+
\ No newline at end of file
diff --git a/FGUIProject/assets/Main/LoginPanel.xml b/FGUIProject/assets/Main/LoginPanel.xml
new file mode 100644
index 000000000..2eeea257a
--- /dev/null
+++ b/FGUIProject/assets/Main/LoginPanel.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FGUIProject/assets/Main/package.xml b/FGUIProject/assets/Main/package.xml
index 29b144b39..d61f5671a 100644
--- a/FGUIProject/assets/Main/package.xml
+++ b/FGUIProject/assets/Main/package.xml
@@ -48,6 +48,7 @@
+
\ No newline at end of file
diff --git a/FGUIProject/settings/whoot/6hgkvlau9zboma.json b/FGUIProject/settings/whoot/6hgkvlau9zboma.json
new file mode 100644
index 000000000..5e3c772a9
--- /dev/null
+++ b/FGUIProject/settings/whoot/6hgkvlau9zboma.json
@@ -0,0 +1 @@
+{"url":"ui://6hgkvlau9zboma","name":"CommonInput","scriptType":"component","isCustomName":false,"customName":"","annotation":"","member":{}}
\ No newline at end of file
diff --git a/FGUIProject/settings/whoot/hxr7rc7p9zbo1g.json b/FGUIProject/settings/whoot/hxr7rc7p9zbo1g.json
new file mode 100644
index 000000000..8ab6d7070
--- /dev/null
+++ b/FGUIProject/settings/whoot/hxr7rc7p9zbo1g.json
@@ -0,0 +1 @@
+{"url":"ui://hxr7rc7p9zbo1g","name":"LoginPanel","scriptType":"panel","isCustomName":false,"customName":"","annotation":"","member":{}}
\ No newline at end of file