diff --git a/.codelyignore b/.codelyignore new file mode 100644 index 000000000..9e79c7279 --- /dev/null +++ b/.codelyignore @@ -0,0 +1,72 @@ +# Codely ignore for Unity (git/Plastic style). Auto-generated by Codely/Continue. +# Library: only PackageCache is kept for indexing; rest is cache. + +# Library – ignore all except PackageCache +Library/* +!Library/PackageCache/ +!Library/PackageCache/** + +# Temp, Obj, Logs, UserSettings (conventional Unity ignores) +Temp/ +Obj/ +Logs/ +UserSettings/ +Build/ +Builds/ + +# Unity / IDE +.utmp/ +.vs/ +.consulo/ +.gradle/ +*.DotSettings.user +ExportedObj/ + +# MemoryCaptures / Recordings +MemoryCaptures/ +Recordings/ + +# Blender +*.blend1 +*.blend1.meta + +# JetBrains Rider (optional) +# Assets/Plugins/Editor/JetBrains* + +# Solution / project / IDE user files +*.csproj +*.unityproj +*.sln +*.suo +*.tmp +*.user +*.userprefs +*.pidb +*.booproj +*.svd +*.pdb +*.mdb +*.opendb +*.VC.db +*.pidb.meta +*.pdb.meta +*.mdb.meta +sysinfo.txt +mono_crash.* + +# Build artifacts +*.apk +*.aab +*.app +crashlytics-build.properties +InitTestScene*.unity* + +# Addressables +ServerData +Assets/StreamingAssets/aa* +Assets/AddressableAssetsData/link.xml* +Assets/Addressables_Temp* +Assets/AddressableAssetsData/*/*.bin* + +# Visual Scripting generated +Assets/Unity.VisualScripting.Generated/ diff --git a/Assets/New Terrain 12.asset b/Assets/New Terrain 12.asset index b57d809e6..b27451978 100644 Binary files a/Assets/New Terrain 12.asset and b/Assets/New Terrain 12.asset differ diff --git a/Assets/ResRaw/Fgui/Main/Main_fui.bytes b/Assets/ResRaw/Fgui/Main/Main_fui.bytes index 6bd0bbab8..e588d87d3 100644 Binary files a/Assets/ResRaw/Fgui/Main/Main_fui.bytes and b/Assets/ResRaw/Fgui/Main/Main_fui.bytes differ diff --git a/Assets/ResRaw/Maps/Map10/Map1.asset b/Assets/ResRaw/Maps/Map10/Map1.asset index 89933dfe1..d53da2f62 100644 Binary files a/Assets/ResRaw/Maps/Map10/Map1.asset and b/Assets/ResRaw/Maps/Map10/Map1.asset differ diff --git a/Assets/Scenes/BobberTest.unity b/Assets/Scenes/BobberTest.unity index 33c187fc4..64b1e4001 100644 --- a/Assets/Scenes/BobberTest.unity +++ b/Assets/Scenes/BobberTest.unity @@ -1116,7 +1116,7 @@ Transform: m_GameObject: {fileID: 909052969} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -53, y: -1.75, z: -55.52} + m_LocalPosition: {x: -53, y: -0.75, z: -55.52} m_LocalScale: {x: 100, y: 100, z: 100} m_ConstrainProportionsScale: 0 m_Children: [] @@ -2143,8 +2143,9 @@ MonoBehaviour: m_EditorClassIdentifier: Assembly-CSharp::Test.BobberTest rb: {fileID: 1518432885} line: {fileID: 8144283643417267672} - lineLength: 2 + lineLength: 3 floatLength: 1 + Tension: 0 --- !u!1 &1529912227 GameObject: m_ObjectHideFlags: 0 @@ -2659,6 +2660,7 @@ GameObject: - component: {fileID: 1876288043} - component: {fileID: 1876288042} - component: {fileID: 1876288041} + - component: {fileID: 1876288046} m_Layer: 0 m_Name: Capsule m_TagString: Untagged @@ -2787,6 +2789,18 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1876288046 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1876288040} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d5bfa3f53f894e7a87315e5cbc220e12, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::Test.CollisionTest --- !u!1 &1899034788 GameObject: m_ObjectHideFlags: 0 @@ -2884,25 +2898,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 3481fc2889d14a00a9de205cc39d9c33, type: 3} m_Name: m_EditorClassIdentifier: Assembly-CSharp::CentimeterBuoyancy - waterDensity: 1000 - buoyancyScale: 2 - dragScale: 1 - waterLevel: 0 - waterLayer: - m_Bits: 16 - showDebugInfo: 1 - debugColor: - r: 0 - g: 1 - b: 1 - a: 1 - rb: {fileID: 0} - objCollider: {fileID: 0} - volumeInCm: 0 - samplePoints: [] - localBounds: - m_Center: {x: 0, y: 0, z: 0} - m_Extent: {x: 0, y: 0, z: 0} --- !u!4 &1948332548 stripped Transform: m_CorrespondingSourceObject: {fileID: 8356280719142672529, guid: 84f17dfc7c7a7485296643a4e64d6200, type: 3} @@ -7339,7 +7334,7 @@ MonoBehaviour: uprightAxis: 1 extraDragInWater: 0.8 extraAngularDragInWater: 0.8 - Water: {fileID: 2531380344179187550} + Water: {fileID: 4652288250947343381} _Layer: 1 _ObjectWidth: 0.2 drawDebug: 0 diff --git a/Assets/Scripts/Common/Entity.meta b/Assets/Scripts/Common/Entity.meta new file mode 100644 index 000000000..1d0a3b48e --- /dev/null +++ b/Assets/Scripts/Common/Entity.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b25d7e65501b49c18f57eec3b4209ad0 +timeCreated: 1772695059 \ No newline at end of file diff --git a/Assets/Scripts/Common/Entity/SerializerComponent.cs b/Assets/Scripts/Common/Entity/SerializerComponent.cs new file mode 100644 index 000000000..0f731fb9d --- /dev/null +++ b/Assets/Scripts/Common/Entity/SerializerComponent.cs @@ -0,0 +1,30 @@ +// using Fantasy.Entitas; +// using Fantasy.Network; +// using Fantasy.Serialize; +// +// namespace NBF +// { +// public class SerializerComponent : Entity +// { +// public ISerialize Serialize; +// public readonly MemoryStreamBufferPool BufferPool = new MemoryStreamBufferPool(); +// +// +// public void Initialize() +// { +// Serialize = SerializerManager.ProtoBufHelper; +// } +// +// public byte[] Serialize(T @object) +// { +// using var memoryStreamBuffer = BufferPool.RentMemoryStream(MemoryStreamBufferSource.None); +// Serialize.Serialize(typeof(T), @object, memoryStreamBuffer); +// return memoryStreamBuffer.ToArray(); +// } +// +// public T Deserialize(byte[] bytes) +// { +// return Serialize.Deserialize(bytes); +// } +// } +// } \ No newline at end of file diff --git a/Assets/Scripts/Common/Entity/SerializerComponent.cs.meta b/Assets/Scripts/Common/Entity/SerializerComponent.cs.meta new file mode 100644 index 000000000..4cd0d630c --- /dev/null +++ b/Assets/Scripts/Common/Entity/SerializerComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0a4cb7f8b3fe47e0852a2081f714dec4 +timeCreated: 1772695064 \ No newline at end of file diff --git a/Assets/Scripts/Common/Net/MessageHandler/Chat2C_MessageHandler.cs b/Assets/Scripts/Common/Net/MessageHandler/Chat2C_MessageHandler.cs index 0efb403a1..b4647ea13 100644 --- a/Assets/Scripts/Common/Net/MessageHandler/Chat2C_MessageHandler.cs +++ b/Assets/Scripts/Common/Net/MessageHandler/Chat2C_MessageHandler.cs @@ -1,4 +1,5 @@ -using Fantasy; +using System.Text; +using Fantasy; using Fantasy.Async; using Fantasy.Network; using Fantasy.Network.Interface; @@ -7,17 +8,54 @@ using Log = NBC.Log; namespace NBF { - public class Chat2C_MessageHandler : Message + // public class Chat2C_MessageHandler : Message + // { + // protected override async FTask Run(Session session, S2C_Message message) + // { + // Log.Info($"收到一条消息推送,message={message.Msg}"); + // var chatTestPanel = UI.Inst.GetUI(); + // if (chatTestPanel != null) + // { + // chatTestPanel.Message(message.Msg.Content); + // } + // await FTask.CompletedTask; + // } + // } + + public sealed class Chat2C_MessageHandler : Message { - protected override async FTask Run(Session session, S2C_Message message) + protected override async FTask Run(Session session, Chat2C_Message message) { - Log.Info($"收到一条消息推送,message={message.Msg}"); - var chatTestPanel = UI.Inst.GetUI(); - if (chatTestPanel != null) - { - chatTestPanel.Message(message.Msg.Content); - } + ChatTreeParser.Parse(session.Scene,message.ChatInfoTree); + Log.Info("收到聊天信息:"); await FTask.CompletedTask; } } + + public static class ChatTreeParser + { + public static void Parse(Scene scene, ChatInfoTree tree) + { + // var entryComponent = scene.GetComponent(); + var chatTestPanel = UI.Inst.GetUI(); + if (chatTestPanel != null) + { + chatTestPanel.Message(tree); + } + + // var sb = new StringBuilder(); + // foreach (var chatInfoNode in tree.Node) + // { + // // 这里只是演示一下处理事件的效果,实际使用时,需要根据实际情况处理事件 + // // 明显我现在这样做的方式不是对的,应该是自己拼接一个聊天信息,然后调用这个接口来处理事件 + // entryComponent.Entry.ChatNodeEventButton.onClick.RemoveAllListeners(); + // entryComponent.Entry.ChatNodeEventButton.onClick.AddListener(() => + // { + // ChatNodeEventHelper.Handler(scene, chatInfoNode); + // }); + // sb.Append(chatInfoNode.Content); + // } + // entryComponent.Entry.MessageText.text = sb.ToString(); + } + } } \ No newline at end of file diff --git a/Assets/Scripts/Fishing/LureController.cs b/Assets/Scripts/Fishing/LureController.cs index 9b687818c..781f31158 100644 --- a/Assets/Scripts/Fishing/LureController.cs +++ b/Assets/Scripts/Fishing/LureController.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using System; +using UnityEngine; namespace NBF { @@ -10,11 +11,19 @@ namespace NBF public ConfigurableJoint Joint => joint; + private void Start() + { + RBody.detectCollisions = true; + RBody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; + RBody.interpolation = RigidbodyInterpolation.Interpolate; + } + public void SetJoint(Rigidbody rb) { joint.connectedBody = rb; } + public void EnableCollision(bool enable) { if (rBody == null) @@ -22,7 +31,7 @@ namespace NBF rBody = GetComponent(); } - rBody.detectCollisions = enable; + // rBody.detectCollisions = enable; } public void SetKinematic(bool value) @@ -37,5 +46,14 @@ namespace NBF limit = limit }; } + + private void OnCollisionEnter(Collision other) + { + Debug.Log($"OnCollisionEnter:{other.gameObject.name}"); + } + private void OnCollisionExit(Collision other) + { + Debug.Log($"OnCollisionExit:{other.gameObject.name}"); + } } } \ No newline at end of file diff --git a/Assets/Scripts/Fishing/Player/States/PlayerStateThrow.cs b/Assets/Scripts/Fishing/Player/States/PlayerStateThrow.cs index 7f22aa113..808bcc187 100644 --- a/Assets/Scripts/Fishing/Player/States/PlayerStateThrow.cs +++ b/Assets/Scripts/Fishing/Player/States/PlayerStateThrow.cs @@ -62,6 +62,21 @@ namespace NBF return base.onUpdate(); } + // IEnumerator ThrowCoroutine(float distance) + // { + // float startLength = 0.5f; + // Debug.Log($"REST LENGTH : {rope.restLength}"); + // do + // { + // float a = Vector3.Distance(rodTipTarget.position, attachedBody.transform.position); + // attachedBody.RBody.AddForce(playerForward.Value, ForceMode.VelocityChange); + // startLength = Mathf.Max(a, startLength); + // UnwindLine(attachedBody.RBody.linearVelocity.magnitude * Time.deltaTime); + // yield return null; + // } + // while ((bool)isBailOpen); + // } + #region 动画回调 /// diff --git a/Assets/Scripts/Generate/NetworkProtocol/NetworkProtocolHelper.cs b/Assets/Scripts/Generate/NetworkProtocol/NetworkProtocolHelper.cs index 3813db09b..b757cc3a2 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/NetworkProtocolHelper.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/NetworkProtocolHelper.cs @@ -472,6 +472,30 @@ namespace Fantasy session.Send(S2C_MailState_message); } [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static async FTask C2Chat_SendMessageRequest(this Session session, C2Chat_SendMessageRequest C2Chat_SendMessageRequest_request) + { + return (Chat2C_SendMessageResponse)await session.Call(C2Chat_SendMessageRequest_request); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static async FTask C2Chat_SendMessageRequest(this Session session, ChatInfoTree chatInfoTree) + { + using var C2Chat_SendMessageRequest_request = Fantasy.C2Chat_SendMessageRequest.Create(); + C2Chat_SendMessageRequest_request.ChatInfoTree = chatInfoTree; + return (Chat2C_SendMessageResponse)await session.Call(C2Chat_SendMessageRequest_request); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void Chat2C_Message(this Session session, Chat2C_Message Chat2C_Message_message) + { + session.Send(Chat2C_Message_message); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void Chat2C_Message(this Session session, ChatInfoTree chatInfoTree) + { + using var Chat2C_Message_message = Fantasy.Chat2C_Message.Create(); + Chat2C_Message_message.ChatInfoTree = chatInfoTree; + session.Send(Chat2C_Message_message); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static async FTask C2S_CreateChannelRequest(this Session session, C2S_CreateChannelRequest C2S_CreateChannelRequest_request) { return (S2C_CreateChannelResponse)await session.Call(C2S_CreateChannelRequest_request); diff --git a/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs b/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs index dcdeb4cf0..b99cea1ff 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs @@ -903,7 +903,7 @@ namespace Fantasy public uint ErrorCode { get; set; } } /// - /// 奖励推送 + /// 活动奖励推送 /// [Serializable] [ProtoContract] @@ -2839,7 +2839,398 @@ namespace Fantasy [ProtoMember(2)] public long MailId { get; set; } } + /// + /// 发送一个聊天消息给Chat服务器,中间是经过Gate中转的 + /// ////////// ******** 频道聊天 *******///////////// + [Serializable] + [ProtoContract] + public partial class C2Chat_SendMessageRequest : AMessage, ICustomRouteRequest + { + public static C2Chat_SendMessageRequest Create(bool autoReturn = true) + { + var c2Chat_SendMessageRequest = MessageObjectPool.Rent(); + c2Chat_SendMessageRequest.AutoReturn = autoReturn; + + if (!autoReturn) + { + c2Chat_SendMessageRequest.SetIsPool(false); + } + + return c2Chat_SendMessageRequest; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + if (ChatInfoTree != null) + { + ChatInfoTree.Dispose(); + ChatInfoTree = null; + } + MessageObjectPool.Return(this); + } + public uint OpCode() { return OuterOpcode.C2Chat_SendMessageRequest; } + [ProtoIgnore] + public Chat2C_SendMessageResponse ResponseType { get; set; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.SocialRoute; + [ProtoMember(1)] + public ChatInfoTree ChatInfoTree { get; set; } + } + [Serializable] + [ProtoContract] + public partial class Chat2C_SendMessageResponse : AMessage, ICustomRouteResponse + { + public static Chat2C_SendMessageResponse Create(bool autoReturn = true) + { + var chat2C_SendMessageResponse = MessageObjectPool.Rent(); + chat2C_SendMessageResponse.AutoReturn = autoReturn; + + if (!autoReturn) + { + chat2C_SendMessageResponse.SetIsPool(false); + } + + return chat2C_SendMessageResponse; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + ErrorCode = 0; + MessageObjectPool.Return(this); + } + public uint OpCode() { return OuterOpcode.Chat2C_SendMessageResponse; } + [ProtoMember(1)] + public uint ErrorCode { get; set; } + } + [Serializable] + [ProtoContract] + public partial class Chat2C_Message : AMessage, ICustomRouteMessage + { + public static Chat2C_Message Create(bool autoReturn = true) + { + var chat2C_Message = MessageObjectPool.Rent(); + chat2C_Message.AutoReturn = autoReturn; + + if (!autoReturn) + { + chat2C_Message.SetIsPool(false); + } + + return chat2C_Message; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + if (ChatInfoTree != null) + { + ChatInfoTree.Dispose(); + ChatInfoTree = null; + } + MessageObjectPool.Return(this); + } + public uint OpCode() { return OuterOpcode.Chat2C_Message; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.SocialRoute; + [ProtoMember(1)] + public ChatInfoTree ChatInfoTree { get; set; } + } + /// + /// 聊天消息树 + /// + [Serializable] + [ProtoContract] + public partial class ChatInfoTree : AMessage, IDisposable + { + public static ChatInfoTree Create(bool autoReturn = true) + { + var chatInfoTree = MessageObjectPool.Rent(); + chatInfoTree.AutoReturn = autoReturn; + + if (!autoReturn) + { + chatInfoTree.SetIsPool(false); + } + + return chatInfoTree; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + ChatChannelType = default; + ChatChannelId = default; + UnitId = default; + UserName = default; + Target.Clear(); + Node.Clear(); + MessageObjectPool.Return(this); + } + [ProtoMember(1)] + public int ChatChannelType { get; set; } + [ProtoMember(2)] + public long ChatChannelId { get; set; } + [ProtoMember(3)] + public long UnitId { get; set; } + [ProtoMember(4)] + public string UserName { get; set; } + [ProtoMember(5)] + public List Target { get; set; } = new List(); + [ProtoMember(6)] + public List Node { get; set; } = new List(); + } + /// + /// 聊天信息节点 + /// + [Serializable] + [ProtoContract] + public partial class ChatInfoNode : AMessage, IDisposable + { + public static ChatInfoNode Create(bool autoReturn = true) + { + var chatInfoNode = MessageObjectPool.Rent(); + chatInfoNode.AutoReturn = autoReturn; + + if (!autoReturn) + { + chatInfoNode.SetIsPool(false); + } + + return chatInfoNode; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + ChatNodeType = default; + ChatNodeEvent = default; + Content = default; + Color = default; + Data = null; + MessageObjectPool.Return(this); + } + [ProtoMember(1)] + public int ChatNodeType { get; set; } + [ProtoMember(2)] + public int ChatNodeEvent { get; set; } + [ProtoMember(3)] + public string Content { get; set; } + [ProtoMember(4)] + public string Color { get; set; } + [ProtoMember(5)] + public byte[] Data { get; set; } + } + /// + /// 聊天位置信息节点 + /// + [Serializable] + [ProtoContract] + public partial class ChatPositionNode : AMessage, IDisposable + { + public static ChatPositionNode Create(bool autoReturn = true) + { + var chatPositionNode = MessageObjectPool.Rent(); + chatPositionNode.AutoReturn = autoReturn; + + if (!autoReturn) + { + chatPositionNode.SetIsPool(false); + } + + return chatPositionNode; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + MapName = default; + PosX = default; + PosY = default; + PosZ = default; + MessageObjectPool.Return(this); + } + [ProtoMember(1)] + public string MapName { get; set; } + [ProtoMember(2)] + public float PosX { get; set; } + [ProtoMember(3)] + public float PosY { get; set; } + [ProtoMember(4)] + public float PosZ { get; set; } + } + /// + /// 聊天位置信息节点 + /// + [Serializable] + [ProtoContract] + public partial class ChatOpenUINode : AMessage, IDisposable + { + public static ChatOpenUINode Create(bool autoReturn = true) + { + var chatOpenUINode = MessageObjectPool.Rent(); + chatOpenUINode.AutoReturn = autoReturn; + + if (!autoReturn) + { + chatOpenUINode.SetIsPool(false); + } + + return chatOpenUINode; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + UIName = default; + MessageObjectPool.Return(this); + } + [ProtoMember(1)] + public string UIName { get; set; } + } + /// + /// 聊天连接信息节点 + /// + [Serializable] + [ProtoContract] + public partial class ChatLinkNode : AMessage, IDisposable + { + public static ChatLinkNode Create(bool autoReturn = true) + { + var chatLinkNode = MessageObjectPool.Rent(); + chatLinkNode.AutoReturn = autoReturn; + + if (!autoReturn) + { + chatLinkNode.SetIsPool(false); + } + + return chatLinkNode; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + Link = default; + MessageObjectPool.Return(this); + } + [ProtoMember(1)] + public string Link { get; set; } + } [Serializable] [ProtoContract] public partial class ChatUserInfo : AMessage, IDisposable @@ -4485,7 +4876,7 @@ namespace Fantasy MessageObjectPool.Return(this); } [ProtoMember(1)] - public int ConfigId { get; set; } + public long ConfigId { get; set; } [ProtoMember(2)] public int Count { get; set; } } @@ -4646,7 +5037,7 @@ namespace Fantasy [ProtoMember(4)] public uint Sort { get; set; } [ProtoMember(5)] - public string Tag { get; set; } + public uint Tag { get; set; } } /// /// fish信息 diff --git a/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs b/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs index 187ada4c4..fda636e7b 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs @@ -61,29 +61,32 @@ namespace Fantasy public const uint S2C_DeleteMailResponse = 2415929119; public const uint S2C_HaveMail = 2147493663; public const uint S2C_MailState = 2147493664; - public const uint C2S_CreateChannelRequest = 2281711392; - public const uint S2C_CreateChannelResponse = 2415929120; - public const uint C2S_JoinChannelRequest = 2281711393; - public const uint S2C_JoinChannelResponse = 2415929121; - public const uint C2S_SendMessageRequest = 2281711394; - public const uint S2C_SendMessageResponse = 2415929122; - public const uint S2C_Message = 2147493665; - public const uint C2S_CreateClubRequest = 2281711395; - public const uint S2C_CreateClubResponse = 2415929123; - public const uint C2S_GetClubInfoRequest = 2281711396; - public const uint S2C_GetClubInfoResponse = 2415929124; - public const uint C2S_GetMemberListRequest = 2281711397; - public const uint S2C_GetMemberListResponse = 2415929125; - public const uint C2S_GetClubListRequest = 2281711398; - public const uint S2C_GetClubListResponse = 2415929126; - public const uint C2S_JoinClubRequest = 2281711399; - public const uint S2C_JoinClubResponse = 2415929127; - public const uint C2S_LeaveClubRequest = 2281711400; - public const uint S2C_LeaveClubResponse = 2415929128; - public const uint C2S_DissolveClubRequest = 2281711401; - public const uint S2C_DissolveClubResponse = 2415929129; - public const uint C2S_DisposeJoinRequest = 2281711402; - public const uint S2C_DisposeJoinResponse = 2415929130; - public const uint S2C_ClubChange = 2147493666; + public const uint C2Chat_SendMessageRequest = 2281711392; + public const uint Chat2C_SendMessageResponse = 2415929120; + public const uint Chat2C_Message = 2147493665; + public const uint C2S_CreateChannelRequest = 2281711393; + public const uint S2C_CreateChannelResponse = 2415929121; + public const uint C2S_JoinChannelRequest = 2281711394; + public const uint S2C_JoinChannelResponse = 2415929122; + public const uint C2S_SendMessageRequest = 2281711395; + public const uint S2C_SendMessageResponse = 2415929123; + public const uint S2C_Message = 2147493666; + public const uint C2S_CreateClubRequest = 2281711396; + public const uint S2C_CreateClubResponse = 2415929124; + public const uint C2S_GetClubInfoRequest = 2281711397; + public const uint S2C_GetClubInfoResponse = 2415929125; + public const uint C2S_GetMemberListRequest = 2281711398; + public const uint S2C_GetMemberListResponse = 2415929126; + public const uint C2S_GetClubListRequest = 2281711399; + public const uint S2C_GetClubListResponse = 2415929127; + public const uint C2S_JoinClubRequest = 2281711400; + public const uint S2C_JoinClubResponse = 2415929128; + public const uint C2S_LeaveClubRequest = 2281711401; + public const uint S2C_LeaveClubResponse = 2415929129; + public const uint C2S_DissolveClubRequest = 2281711402; + public const uint S2C_DissolveClubResponse = 2415929130; + public const uint C2S_DisposeJoinRequest = 2281711403; + public const uint S2C_DisposeJoinResponse = 2415929131; + public const uint S2C_ClubChange = 2147493667; } } \ No newline at end of file diff --git a/Assets/Scripts/Test/BobberTest.cs b/Assets/Scripts/Test/BobberTest.cs index 179e13a1e..63a77df26 100644 --- a/Assets/Scripts/Test/BobberTest.cs +++ b/Assets/Scripts/Test/BobberTest.cs @@ -12,6 +12,7 @@ namespace Test public float lineLength = 1f; public float floatLength = 0.5f; + public float Tension = 0; public void Start() { line.InitTest(rb); @@ -20,5 +21,49 @@ namespace Test line.Bobber.SetJointDistance(lineLength - floatLength); line.SetObiRopeStretch(lineLength - floatLength); } + + private void Update() + { + if (Input.GetKeyDown(KeyCode.Alpha0)) + { + SetLineLength(lineLength); + } + else if (Input.GetKeyDown(KeyCode.Plus) || Input.GetKeyDown(KeyCode.Equals)) + { + lineLength += 0.1f; + SetLineLength(lineLength); + } + else if (Input.GetKeyDown(KeyCode.Minus)) + { + lineLength -= 0.1f; + SetLineLength(lineLength); + } + } + + public void SetLineLength(float lineLength, bool stretchRope = true) + { + Debug.Log($"lineLength={lineLength}"); + if (!line) return; + if (line.IsLure) + { + //没有浮漂类型 + line.Lure.SetJointDistance(lineLength); + if (stretchRope) + { + line.SetObiRopeStretch(Tension > 0f ? 0f : lineLength); + } + } + else + { + //有浮漂 + line.Lure.SetJointDistance(floatLength); + line.Bobber.SetJointDistance(lineLength - floatLength); + if (stretchRope) + { + line.SetObiRopeStretch(Tension > 0f ? 0f : lineLength - floatLength); + } + } + } + } } \ No newline at end of file diff --git a/Assets/Scripts/Test/CollisionTest.cs b/Assets/Scripts/Test/CollisionTest.cs new file mode 100644 index 000000000..1d2c17f01 --- /dev/null +++ b/Assets/Scripts/Test/CollisionTest.cs @@ -0,0 +1,16 @@ +using UnityEngine; + +namespace Test +{ + public class CollisionTest : MonoBehaviour + { + private void OnCollisionEnter(Collision other) + { + Debug.Log($"OnCollisionEnter:{other.gameObject.name}"); + } + private void OnCollisionExit(Collision other) + { + Debug.Log($"OnCollisionExit:{other.gameObject.name}"); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Test/CollisionTest.cs.meta b/Assets/Scripts/Test/CollisionTest.cs.meta new file mode 100644 index 000000000..ba80e1dbf --- /dev/null +++ b/Assets/Scripts/Test/CollisionTest.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d5bfa3f53f894e7a87315e5cbc220e12 +timeCreated: 1772767361 \ No newline at end of file diff --git a/Assets/Scripts/UI/Chat.meta b/Assets/Scripts/UI/Chat.meta new file mode 100644 index 000000000..4bb3940c0 --- /dev/null +++ b/Assets/Scripts/UI/Chat.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6169cecd85b9472e989a7ef14fc83964 +timeCreated: 1772694660 \ No newline at end of file diff --git a/Assets/Scripts/UI/Chat/ChatChannelType.cs b/Assets/Scripts/UI/Chat/ChatChannelType.cs new file mode 100644 index 000000000..669cd703e --- /dev/null +++ b/Assets/Scripts/UI/Chat/ChatChannelType.cs @@ -0,0 +1,52 @@ +using System; + +namespace NBF +{ + /// + /// 聊天频道类型 + /// + [Flags] + public enum ChatChannelType + { + None = 0, + World = 1 << 1, // 世界频道 + Private = 1 << 2, // 私聊频道 + System = 1 << 3, // 系统频道 + Broadcast = 1 << 4, // 广播频道 + Notice = 1 << 5, // 公告频道 + Team = 1 << 6, // 队伍频道 + Near = 1 << 7, // 附近频道 + CurrentMap = 1 << 8, // 当前地图频道 + + // 所有频道 + All = World | Private | System | Broadcast | Notice | Team | Near, + // 其他聊天栏显示的频道 + Display = World | Private | System | Broadcast | Notice | Team | Near | CurrentMap + } + + /// + /// 聊天节点类型 + /// + public enum ChatNodeType + { + None = 0, + Position = 1, // 位置节点 + OpenUI = 2, // 打开UI节点 + Link = 3, // 链接节点 + Item = 4, // 物品节点 + Text = 5, // 文本节点 + Image = 6, // 图片节点 + } + + /// + /// 聊天节点事件类型 + /// + public enum ChatNodeEvent + { + None = 0, + OpenUI = 1, // 打开UI节点 + ClickLink = 2, // 点击链接节点 + UseItem = 3, // 使用物品节点 + Position = 4, // 位置节点 + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/Chat/ChatChannelType.cs.meta b/Assets/Scripts/UI/Chat/ChatChannelType.cs.meta new file mode 100644 index 000000000..0b911f82d --- /dev/null +++ b/Assets/Scripts/UI/Chat/ChatChannelType.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4ec94d1a6ab744c4bdcff56d8da8e6ea +timeCreated: 1772694755 \ No newline at end of file diff --git a/Assets/Scripts/UI/Chat/ChatInfoTree.cs b/Assets/Scripts/UI/Chat/ChatInfoTree.cs new file mode 100644 index 000000000..44074d47d --- /dev/null +++ b/Assets/Scripts/UI/Chat/ChatInfoTree.cs @@ -0,0 +1,16 @@ +using System.Runtime.Serialization; +using LightProto; +using MongoDB.Bson.Serialization.Attributes; +using Newtonsoft.Json; + +namespace Fantasy +{ + public partial class ChatInfoTree + { + [BsonIgnore] + [JsonIgnore] + [ProtoIgnore] + [IgnoreDataMember] + public Scene Scene { get; set; } + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/Chat/ChatInfoTree.cs.meta b/Assets/Scripts/UI/Chat/ChatInfoTree.cs.meta new file mode 100644 index 000000000..930db7733 --- /dev/null +++ b/Assets/Scripts/UI/Chat/ChatInfoTree.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 73e6060aebcd46eca52cd4086e193fb3 +timeCreated: 1772694724 \ No newline at end of file diff --git a/Assets/Scripts/UI/Chat/ChatNodeEventHelper.cs b/Assets/Scripts/UI/Chat/ChatNodeEventHelper.cs new file mode 100644 index 000000000..56b72a55f --- /dev/null +++ b/Assets/Scripts/UI/Chat/ChatNodeEventHelper.cs @@ -0,0 +1,82 @@ +using System.Collections.Generic; +using Fantasy; +using Fantasy.Serialize; + +namespace NBF +{ + public static class ChatNodeEventHelper + { + public static void Handler(Scene scene, ChatInfoNode node) + { + switch ((ChatNodeEvent)node.ChatNodeEvent) + { + case ChatNodeEvent.ClickLink: + { + ClickLinkHandler(scene, node); + return; + } + case ChatNodeEvent.OpenUI: + { + OpenUIHandler(scene, node); + return; + } + case ChatNodeEvent.Position: + { + PositionHandler(scene, node); + return; + } + case ChatNodeEvent.UseItem: + { + UseItemHandler(scene, node); + return; + } + } + } + + private static void ClickLinkHandler(Scene scene, ChatInfoNode node) + { + if (node.Data == null || node.Data.Length == 0) + { + return; + } + + var chatLinkNode = SerializerManager.ProtoBufHelper.Deserialize(node.Data); + // var chatLinkNode = scene.GetComponent().Deserialize(node.Data); + // 拿到这个之后,就可以为所欲为了。 + // 根据自己的逻辑和UI设计,做出相应的处理。 + Log.Debug($"ClickLinkHandler Link:{chatLinkNode.Link}"); + } + + private static void OpenUIHandler(Scene scene, ChatInfoNode node) + { + if (node.Data == null || node.Data.Length == 0) + { + return; + } + + var chatOpenUINode = SerializerManager.ProtoBufHelper.Deserialize(node.Data); + // 拿到这个之后,就可以为所欲为了。 + // 根据自己的逻辑和UI设计,做出相应的处理。 + Log.Debug($"OpenUIHandler UIName:{chatOpenUINode.UIName}"); + } + + private static void PositionHandler(Scene scene, ChatInfoNode node) + { + if (node.Data == null || node.Data.Length == 0) + { + return; + } + + var chatPositionNode = SerializerManager.ProtoBufHelper.Deserialize(node.Data); + // 拿到这个之后,就可以为所欲为了。 + // 根据自己的逻辑和UI设计,做出相应的处理。 + Log.Debug( + $"PositionHandler MapName:{chatPositionNode.MapName} X:{chatPositionNode.PosX} Y:{chatPositionNode.PosY} Z:{chatPositionNode.PosZ}"); + } + + private static void UseItemHandler(Scene scene, ChatInfoNode node) + { + // TODO: Implement UseItemHandler + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/Chat/ChatNodeEventHelper.cs.meta b/Assets/Scripts/UI/Chat/ChatNodeEventHelper.cs.meta new file mode 100644 index 000000000..389f3bde9 --- /dev/null +++ b/Assets/Scripts/UI/Chat/ChatNodeEventHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7bcf5d11cea04d86a8a9c5c3fce31ed8 +timeCreated: 1772694878 \ No newline at end of file diff --git a/Assets/Scripts/UI/Chat/ChatNodeFactory.cs b/Assets/Scripts/UI/Chat/ChatNodeFactory.cs new file mode 100644 index 000000000..c66258e69 --- /dev/null +++ b/Assets/Scripts/UI/Chat/ChatNodeFactory.cs @@ -0,0 +1,130 @@ +using Fantasy; +using Fantasy.Network; +using Fantasy.Serialize; + +namespace NBF +{ + /// + /// 聊天信息节点 + /// + public static class ChatNodeFactory + { + /// + /// 添加文本节点 + /// + /// + /// + /// + public static ChatInfoTree AddendTextNode(this ChatInfoTree chatInfoTree, string content) + { + var chatInfoNode = new ChatInfoNode() + { + ChatNodeType = (int)ChatNodeType.Text, + Content = content + }; + chatInfoTree.Node.Add(chatInfoNode); + return chatInfoTree; + } + + /// + /// 添加链接节点 + /// + /// + /// + /// + /// + public static ChatInfoTree AddendLinkNode(this ChatInfoTree chatInfoTree, string content,string link) + { + var chatLinkNode = new ChatLinkNode() + { + Link = link + }; + // var serializerComponent = chatInfoTree.Scene.GetComponent(); + var chatInfoNode = new ChatInfoNode() + { + ChatNodeType = (int)ChatNodeType.Link, + ChatNodeEvent = (int)ChatNodeEvent.ClickLink, + Content = content, + Data = SerializerManager.ProtoBufHelper.Serialize(chatLinkNode) + }; + chatInfoTree.Node.Add(chatInfoNode); + return chatInfoTree; + } + + /// + /// 添加图片节点 + /// + /// + /// + /// + public static ChatInfoTree AddendImageNode(this ChatInfoTree chatInfoTree, string content) + { + var chatInfoNode = new ChatInfoNode() + { + ChatNodeType = (int)ChatNodeType.Image, + Content = content + }; + chatInfoTree.Node.Add(chatInfoNode); + return chatInfoTree; + } + + /// + /// 添加打开UI节点 + /// + /// + /// + /// + /// + public static ChatInfoTree AddendOpenUINode(this ChatInfoTree chatInfoTree, string content,string uiName) + { + var chatOpenUINode = new ChatOpenUINode() + { + UIName = uiName + }; + + var chatInfoNode = new ChatInfoNode() + { + ChatNodeType = (int)ChatNodeType.OpenUI, + ChatNodeEvent = (int)ChatNodeEvent.OpenUI, + Content = content, + Data = SerializerManager.ProtoBufHelper.Serialize(chatOpenUINode) + }; + chatInfoTree.Node.Add(chatInfoNode); + return chatInfoTree; + } + + /// + /// 添加位置节点 + /// + /// + /// + /// + /// + /// + /// + /// + public static ChatInfoTree AddendPositionNode(this ChatInfoTree chatInfoTree, string content, string mapName, + float mapX, float mapY, float mapZ) + { + var chatPositionNode = new ChatPositionNode() + { + MapName = mapName, + PosX = mapX, + PosY = mapY, + PosZ = mapZ, + }; + + // var serializerComponent = chatInfoTree.Scene.GetComponent(); + var chatInfoNode = new ChatInfoNode() + { + ChatNodeType = (int)ChatNodeType.Position, + ChatNodeEvent = (int)ChatNodeEvent.Position, + Content = content, + Data = SerializerManager.ProtoBufHelper.Serialize(chatPositionNode) + }; + + chatInfoTree.Node.Add(chatInfoNode); + return chatInfoTree; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/Chat/ChatNodeFactory.cs.meta b/Assets/Scripts/UI/Chat/ChatNodeFactory.cs.meta new file mode 100644 index 000000000..155f7bef1 --- /dev/null +++ b/Assets/Scripts/UI/Chat/ChatNodeFactory.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: bbf26a0aef9841f89db6182475f50e59 +timeCreated: 1772694930 \ No newline at end of file diff --git a/Assets/Scripts/UI/ChatTestPanel.Designer.cs b/Assets/Scripts/UI/Chat/ChatTestPanel.Designer.cs similarity index 81% rename from Assets/Scripts/UI/ChatTestPanel.Designer.cs rename to Assets/Scripts/UI/Chat/ChatTestPanel.Designer.cs index 275cd1e29..648118ee8 100644 --- a/Assets/Scripts/UI/ChatTestPanel.Designer.cs +++ b/Assets/Scripts/UI/Chat/ChatTestPanel.Designer.cs @@ -16,14 +16,6 @@ namespace NBF [AutoFind(Name = "back")] public GImage back; - [AutoFind(Name = "TextLoginInfo")] - public GTextField TextLoginInfo; - [AutoFind(Name = "InputAccount")] - public GLabel InputAccount; - [AutoFind(Name = "BtnLogout")] - public GButton BtnLogout; - [AutoFind(Name = "BtnLogin")] - public GButton BtnLogin; [AutoFind(Name = "InputMessage")] public GLabel InputMessage; [AutoFind(Name = "BtnSendMessage")] @@ -34,6 +26,8 @@ namespace NBF public GButton BtnSendWorld; [AutoFind(Name = "ChatList")] public GList ChatList; + [AutoFind(Name = "InputFriendId")] + public GLabel InputFriendId; public override string[] GetDependPackages(){ return new string[] {"Common","CommonNew"}; } public static void Show(object param = null){ UI.Inst.OpenUI(param); } diff --git a/Assets/Scripts/UI/ChatTestPanel.Designer.cs.meta b/Assets/Scripts/UI/Chat/ChatTestPanel.Designer.cs.meta similarity index 100% rename from Assets/Scripts/UI/ChatTestPanel.Designer.cs.meta rename to Assets/Scripts/UI/Chat/ChatTestPanel.Designer.cs.meta diff --git a/Assets/Scripts/UI/Chat/ChatTestPanel.cs b/Assets/Scripts/UI/Chat/ChatTestPanel.cs new file mode 100644 index 000000000..4e0840403 --- /dev/null +++ b/Assets/Scripts/UI/Chat/ChatTestPanel.cs @@ -0,0 +1,115 @@ +// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖 + +using System; +using System.Collections.Generic; +using System.Text; +using FairyGUI; +using Fantasy; +using Fantasy.Async; +using Fantasy.Network; +using NBC; +using UnityEngine; +using Log = NBC.Log; +using UIPanel = NBC.UIPanel; + +namespace NBF +{ + public partial class ChatTestPanel : UIPanel + { + private List _messages = new List(); + + protected override void OnInit() + { + this.AutoAddClick(OnClick); + } + + protected override void OnShow() + { + } + + private void RefreshList() + { + ChatList.RemoveChildrenToPool(); + foreach (var item in _messages) + { + if (ChatList.AddItemFromPool() is ChatItem chatItem) + { + chatItem.InitData(item); + } + } + } + + private void OnClick(GComponent btn) + { + if (btn == BtnSendWorld) + { + OnSendMessage(InputMessage.title).Coroutine(); + } + else if (btn == BtnSendFriend) + { + OnSendFriendMessage().Coroutine(); + } + } + + #region 发生消息测试 + + private async FTask OnSendMessage(string message) + { + var tree = ChatTreeFactory.Broadcast(Game.Main); + tree = tree.AddendPositionNode(message, "勇者大陆", 121, 131, 111); + + var response = (Chat2C_SendMessageResponse)await Net.Call(new C2Chat_SendMessageRequest() + { + ChatInfoTree = tree + }); + if (response.ErrorCode != 0) + { + Log.Error($"发送聊天消息失败 ErrorCode:{response.ErrorCode}"); + } + else + { + Log.Info("发送消息成功"); + } + } + + private async FTask OnSendFriendMessage() + { + var tree = ChatTreeFactory.Private(); + tree.Target.Add(Convert.ToInt64(InputFriendId.text)); + tree.AddendTextNode("你好,欢迎来到Fantasy Chat!") + .AddendLinkNode("点击这里http://www.fantasy.com.cn", "http://www.fantasy.com.cn"); + + var response = (Chat2C_SendMessageResponse)await Net.Call(new C2Chat_SendMessageRequest() + { + ChatInfoTree = tree + }); + if (response.ErrorCode != 0) + { + Log.Error($"发送私聊消息失败 ErrorCode:{response.ErrorCode}"); + } + } + + public void Message(ChatInfoTree tree) + { + // _messages.Add(message); + + var sb = new StringBuilder(); + foreach (var chatInfoNode in tree.Node) + { + // 这里只是演示一下处理事件的效果,实际使用时,需要根据实际情况处理事件 + // 明显我现在这样做的方式不是对的,应该是自己拼接一个聊天信息,然后调用这个接口来处理事件 + // entryComponent.Entry.ChatNodeEventButton.onClick.RemoveAllListeners(); + // entryComponent.Entry.ChatNodeEventButton.onClick.AddListener(() => + // { + // ChatNodeEventHelper.Handler(scene, chatInfoNode); + // }); + sb.Append(chatInfoNode.Content); + } + + _messages.Add(sb.ToString()); + RefreshList(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/ChatTestPanel.cs.meta b/Assets/Scripts/UI/Chat/ChatTestPanel.cs.meta similarity index 100% rename from Assets/Scripts/UI/ChatTestPanel.cs.meta rename to Assets/Scripts/UI/Chat/ChatTestPanel.cs.meta diff --git a/Assets/Scripts/UI/Chat/ChatTreeFactory.cs b/Assets/Scripts/UI/Chat/ChatTreeFactory.cs new file mode 100644 index 000000000..7781ef794 --- /dev/null +++ b/Assets/Scripts/UI/Chat/ChatTreeFactory.cs @@ -0,0 +1,121 @@ +using Fantasy; + +namespace NBF +{ + /// + /// 创建聊天树的总入口 + /// + public static class ChatTreeFactory + { + /// + /// 创建世界聊天树 + /// + /// + /// + public static ChatInfoTree World() + { + return new ChatInfoTree() + { + Scene = Game.Main, + ChatChannelType = (int)ChatChannelType.World, + }; + } + + /// + /// 创建私聊聊天树 + /// + /// + public static ChatInfoTree Private() + { + return new ChatInfoTree() + { + Scene = Game.Main, + ChatChannelType = (int)ChatChannelType.Private, + }; + } + + /// + /// 创建系统聊天树 + /// + /// + /// + public static ChatInfoTree System(Scene scene) + { + return new ChatInfoTree() + { + Scene = scene, + ChatChannelType = (int)ChatChannelType.System, + }; + } + + /// + /// 创建公广播聊天树 + /// + /// + /// + public static ChatInfoTree Broadcast(Scene scene) + { + return new ChatInfoTree() + { + Scene = scene, + ChatChannelType = (int)ChatChannelType.Broadcast, + }; + } + + /// + /// 创建公告聊天树 + /// + /// + /// + public static ChatInfoTree Notice(Scene scene) + { + return new ChatInfoTree() + { + Scene = scene, + ChatChannelType = (int)ChatChannelType.Notice, + }; + } + + /// + /// 创建队伍聊天树 + /// + /// + /// + public static ChatInfoTree Team(Scene scene) + { + return new ChatInfoTree() + { + Scene = scene, + ChatChannelType = (int)ChatChannelType.Team, + }; + } + + /// + /// 创建附近人聊天树 + /// + /// + /// + public static ChatInfoTree Near(Scene scene) + { + return new ChatInfoTree() + { + Scene = scene, + ChatChannelType = (int)ChatChannelType.Near, + }; + } + + /// + /// 创建当前地图聊天树 + /// + /// + /// + public static ChatInfoTree CurrentMap(Scene scene) + { + return new ChatInfoTree() + { + Scene = scene, + ChatChannelType = (int)ChatChannelType.CurrentMap, + }; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/Chat/ChatTreeFactory.cs.meta b/Assets/Scripts/UI/Chat/ChatTreeFactory.cs.meta new file mode 100644 index 000000000..f59ed14d8 --- /dev/null +++ b/Assets/Scripts/UI/Chat/ChatTreeFactory.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f028a29029d74cbf8c264a7d4a245ecf +timeCreated: 1772694684 \ No newline at end of file diff --git a/Assets/Scripts/UI/ChatTestPanel.cs b/Assets/Scripts/UI/ChatTestPanel.cs deleted file mode 100644 index 203114e54..000000000 --- a/Assets/Scripts/UI/ChatTestPanel.cs +++ /dev/null @@ -1,179 +0,0 @@ -// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖 - -using System.Collections.Generic; -using FairyGUI; -using Fantasy; -using Fantasy.Async; -using Fantasy.Network; -using NBC; -using UnityEngine; -using Log = NBC.Log; -using UIPanel = NBC.UIPanel; - -namespace NBF -{ - public partial class ChatTestPanel : UIPanel - { - private List _messages = new List(); - - protected override void OnInit() - { - this.AutoAddClick(OnClick); - } - - protected override void OnShow() - { - SetLoginState(false); - } - - private void RefreshList() - { - ChatList.RemoveChildrenToPool(); - foreach (var item in _messages) - { - if(ChatList.AddItemFromPool() is ChatItem chatItem) - { - chatItem.InitData(item); - } - } - } - - private void OnClick(GComponent btn) - { - if (btn == BtnLogin) - { - if (string.IsNullOrEmpty(InputAccount.text)) - { - Notices.Info("没有输入账号密码"); - return; - } - - OnLoginButtonClick(InputAccount.text).Coroutine(); - } - else if (btn == BtnSendWorld) - { - OnSendMessage(InputMessage.title).Coroutine(); - } - } - - private void SetLoginState(bool isLogin = false, string account = "") - { - if (isLogin) - { - BtnLogin.visible = false; - BtnLogout.visible = true; - TextLoginInfo.text = account; - } - else - { - BtnLogin.visible = true; - BtnLogout.visible = false; - } - } - - #region 登录测试 - - private Session _session; - - private async FTask OnLoginButtonClick(string account) - { - // NBC.Platform.Unity.Entry.Initialize(GetType().Assembly); - - // 根据用户名来选择目标的鉴权服务器 - // 根据鉴权服务器地址来创建一个新的网络会话 - _session = SessionHelper.CreateSession(Game.Main, "127.0.0.1:20001", OnConnectComplete, - OnConnectFail, - OnConnectDisconnect); - - var acc = account; - - // 发送登录的请求给服务器 - 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 (!Game.Main.GetComponent().Parse(response.ToKen, out var payload)) - { - return; - } - - // 根据ToKen返回的Address登录到Gate服务器 - _session = SessionHelper.CreateSession(Game.Main, 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; - } - - SetLoginState(true, InputAccount.text); - Log.Info( - $"登录到Gate服务器成功!ErrorCode:{loginResponse.ErrorCode}"); - // Log.Debug( - // $"登录到Gate服务器成功!LoginTime:{loginResponse.GameAccountInfo.LoginTime} CreateTime:{loginResponse.GameAccountInfo.CreateTime}"); - - // var getResponse = (G2C_GetAccountInfoResponse)await _session.Call(new C2G_GetAccountInfoRequest()); - // var gameAcc = getResponse.GameAccountInfo; - // Log.Info($"gameAcc LoginTime:{gameAcc.LoginTime} CreateTime:{gameAcc.CreateTime}"); - // getResponse.GameAccountInfo.LoginTime.ToString() - } - - private void OnConnectComplete() - { - Log.Info("连接成功"); - // 添加心跳组件给Session。 - // Start(2000)就是2000毫秒。 - _session.AddComponent().Start(5000); - } - - private void OnConnectFail() - { - Log.Info("连接失败"); - SetLoginState(false); - } - - private void OnConnectDisconnect() - { - Log.Info("连接断开"); - SetLoginState(false); - } - - #endregion - - #region 发生消息测试 - - private async FTask OnSendMessage(string message) - { - var messageResponse = (S2C_SendMessageResponse)await _session.Call(new C2S_SendMessageRequest() - { - Message = message - }); - if (messageResponse.ErrorCode != 0) - { - Notices.Info($"发送消息失败,code={messageResponse.ErrorCode}"); - } - } - - public void Message(string message) - { - _messages.Add(message); - RefreshList(); - } - - #endregion - } -} \ No newline at end of file diff --git a/Assets/Scripts/UI/Login/LoginPanel.cs b/Assets/Scripts/UI/Login/LoginPanel.cs index fcdd0d8eb..921a8af99 100644 --- a/Assets/Scripts/UI/Login/LoginPanel.cs +++ b/Assets/Scripts/UI/Login/LoginPanel.cs @@ -32,7 +32,9 @@ namespace NBF { await LoginHelper.Login(InputAccount.text); - await Fishing.Instance.Go(RoleModel.Instance.Info.MapId); + // await Fishing.Instance.Go(RoleModel.Instance.Info.MapId); + + ChatTestPanel.Show(); // FishingShopPanel.Show(); diff --git a/FGUIProject/assets/Main/Chat/ChatTestPanel.xml b/FGUIProject/assets/Main/Chat/ChatTestPanel.xml index 0e881c092..fc63bad4a 100644 --- a/FGUIProject/assets/Main/Chat/ChatTestPanel.xml +++ b/FGUIProject/assets/Main/Chat/ChatTestPanel.xml @@ -4,16 +4,6 @@ - - - - -