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;
}
}
}