(client)feat:实现按武器释放技能
This commit is contained in:
@ -20,11 +20,12 @@ namespace Data
|
||||
value = xmlDef.Attribute("value")?.Value;
|
||||
|
||||
var nodes = xmlDef.Elements("Node");
|
||||
if (!nodes.Any())
|
||||
var xElements = nodes as XElement[] ?? nodes.ToArray();
|
||||
if (!xElements.Any())
|
||||
return true; // 没有子节点也是有效的
|
||||
|
||||
List<BehaviorTreeDef> children = new();
|
||||
foreach (var node in nodes)
|
||||
foreach (var node in xElements)
|
||||
{
|
||||
var childNode = new BehaviorTreeDef();
|
||||
if (!childNode.Init(node))
|
||||
|
@ -262,7 +262,35 @@ namespace Data
|
||||
|
||||
return Vector2.zero;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算动画执行一个周期的总时间(包括子对象)。
|
||||
/// 如果自身没有纹理,自身动画时间为0。
|
||||
/// 总周期取自身动画时间和所有子动画周期中的最大值。
|
||||
/// </summary>
|
||||
/// <returns>动画执行一个周期的总时间(秒)。</returns>
|
||||
public float GetAnimationCycleDuration()
|
||||
{
|
||||
if (FPS < 0.01)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
float ownDuration = 0f;
|
||||
// 计算当前节点自身的动画周期时间
|
||||
// 由于 Init 方法已经处理了 FPS 的校验,FPS 保证大于 0
|
||||
if (textures.Count > 0)
|
||||
{
|
||||
ownDuration = textures.Count / FPS;
|
||||
}
|
||||
// 递归计算所有子节点的动画周期,并取其中最长的
|
||||
float maxChildDuration = 0f;
|
||||
foreach (var childNode in nodes)
|
||||
{
|
||||
float childDuration = childNode.GetAnimationCycleDuration();
|
||||
maxChildDuration = Math.Max(maxChildDuration, childDuration);
|
||||
}
|
||||
// 整个 DrawNodeDef 的动画周期是自身动画周期和所有子动画周期中的最大值
|
||||
return Math.Max(ownDuration, maxChildDuration);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -7,15 +7,15 @@ namespace Data
|
||||
{
|
||||
public class EntityDef : Define
|
||||
{
|
||||
public AttributesDef attributes;
|
||||
public AttributesDef attributes = new();
|
||||
public DrawingOrderDef drawingOrder;
|
||||
|
||||
public BehaviorTreeDef behaviorTree;
|
||||
public AffiliationDef affiliation;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -2,6 +2,6 @@ namespace Data
|
||||
{
|
||||
public class MonsterDef:EntityDef
|
||||
{
|
||||
|
||||
public WeaponDef weapon;
|
||||
}
|
||||
}
|
@ -9,6 +9,9 @@ namespace Data
|
||||
{
|
||||
public WeaponType type = WeaponType.Melee;
|
||||
public AttributesDef attributes;
|
||||
public BulletDef bullet;
|
||||
public DrawNodeDef attackAnimation;
|
||||
public float attackDetectionTime = 0;
|
||||
public WeaponDef() // 构造函数,用于设置武器的默认属性
|
||||
{
|
||||
maxStack = 1; // 武器默认最大堆叠为1
|
||||
|
Reference in New Issue
Block a user