(client) feat:添加临时动画组件,添加逃跑逻辑

This commit is contained in:
m0_75251201
2025-09-06 12:25:55 +08:00
parent f43aeffebf
commit 15cdd2b244
73 changed files with 3420 additions and 6055 deletions

View File

@ -227,8 +227,8 @@ namespace Data
public class DrawNodeDef : Define
{
public List<string> textures = new();
public List<DrawNodeDef> nodes = new();
public string[] textures;
public DrawNodeDef[] nodes;
public string nodeName;
public Vector2 position = new(0, 0);
public float FPS = 1f;
@ -262,35 +262,6 @@ 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);
}
}
}

View File

@ -3,15 +3,9 @@ using System.Xml.Linq;
namespace Data
{
public class HediffCompDef:Define
public class HediffCompDef : Define
{
public Type compClass;
public override bool Init(XElement xmlDef)
{
base.Init(xmlDef);
var name = xmlDef.Attribute("class")?.Value??"";
compClass=Type.GetType(name);
return true;
}
public string compClass;
public string properties;
}
}

View File

@ -8,6 +8,8 @@ namespace Data
public int wCount;
public int hCount;
public int pixelsPerUnit = 16;
public bool flipX = false;
public bool flipY = false;
public override bool Init(XElement xmlDef)
{

View File

@ -6,14 +6,13 @@ namespace Data
{
public class TileDef : Define
{
public ImageDef texture;
public string name = "";
public string name = null;
public Tile.ColliderType collider = Tile.ColliderType.None;
public override bool Init(XElement xmlDef)
{
base.Init(xmlDef);
name = defName;
name ??= defName;
return false;
}
}

View File

@ -10,7 +10,7 @@ namespace Data
public WeaponType type = WeaponType.Melee;
public AttributesDef attributes;
public BulletDef bullet;
public DrawNodeDef attackAnimation;
public string[] attackAnimation;
public float attackDetectionTime = 0;
public WeaponDef() // 构造函数,用于设置武器的默认属性
{