(client) feat:主要实现实体的行为树和工作类 (#40)

Co-authored-by: zzdxxz <2079238449@qq.com>
Co-committed-by: zzdxxz <2079238449@qq.com>
This commit is contained in:
2025-07-21 13:58:58 +08:00
committed by TheRedApricot
parent 389376ec47
commit 28ddcda9a0
87 changed files with 9052 additions and 2504 deletions

View File

@ -1,9 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
namespace Data
{
public class PawnDef : Define
{
public AttributesDef attributes;
public string aiController;
public string texturePath = null;
public DrawingOrderDef
@ -11,6 +15,10 @@ namespace Data
drawingOrder_up,
drawingOrder_left,
drawingOrder_right;
public BehaviorTreeDef behaviorTree;
public DrawingOrderDef GetDrawingOrder(Orientation orientation)
{
// 定义一个临时变量用于存储结果
@ -48,4 +56,33 @@ namespace Data
{
}
public class BehaviorTreeDef : Define
{
public BehaviorTreeDef[] childTree;
public string className;
public override bool Init(XElement xmlDef)
{
base.Init(xmlDef);
var nodes = xmlDef.Elements("Node");
var xElements = nodes as XElement[] ?? nodes.ToArray();
if (!xElements.Any())
return false;
className = xmlDef.Attribute("className")?.Value;
List<BehaviorTreeDef> children = new();
foreach (var node in xElements)
{
var childNode = new BehaviorTreeDef();
childNode.Init(node);
children.Add(childNode);
}
childTree = children.ToArray();
return true;
}
}
}