Files
Fishing2NetTest/Assets/Scripts/Chat/ChatNodeEventHelper.cs
2026-03-06 09:44:00 +08:00

79 lines
2.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections.Generic;
using Fantasy.Serialize;
namespace Fantasy
{
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<ChatLinkNode>(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<ChatOpenUINode>(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<ChatPositionNode>(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
}
}
}