mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 04:07:13 +08:00
(client) feat:健康给予,路径优化,结算界面,商店界面 (#60)
Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com> Reviewed-on: http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite/pulls/60
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Xml.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
@@ -18,35 +17,34 @@ namespace Data
|
||||
Walking,
|
||||
MeleeAttack,
|
||||
RangedAttack,
|
||||
Death,
|
||||
Death
|
||||
}
|
||||
|
||||
public class DrawingOrderDef : Define
|
||||
{
|
||||
public DrawNodeDef idle_down;
|
||||
public DrawNodeDef idle_up;
|
||||
public DrawNodeDef idle_left;
|
||||
public DrawNodeDef idle_right;
|
||||
|
||||
public DrawNodeDef walk_down;
|
||||
public DrawNodeDef walk_up;
|
||||
public DrawNodeDef walk_left;
|
||||
public DrawNodeDef walk_right;
|
||||
|
||||
public DrawNodeDef meleeAttack_down;
|
||||
public DrawNodeDef meleeAttack_up;
|
||||
public DrawNodeDef meleeAttack_left;
|
||||
public DrawNodeDef meleeAttack_right;
|
||||
|
||||
public DrawNodeDef rangedAttack_down;
|
||||
public DrawNodeDef rangedAttack_up;
|
||||
public DrawNodeDef rangedAttack_left;
|
||||
public DrawNodeDef rangedAttack_right;
|
||||
|
||||
public DrawNodeDef death_down;
|
||||
public DrawNodeDef death_up;
|
||||
public DrawNodeDef death_left;
|
||||
public DrawNodeDef death_right;
|
||||
public DrawNodeDef death_up;
|
||||
public DrawNodeDef idle_down;
|
||||
public DrawNodeDef idle_left;
|
||||
public DrawNodeDef idle_right;
|
||||
public DrawNodeDef idle_up;
|
||||
|
||||
public DrawNodeDef meleeAttack_down;
|
||||
public DrawNodeDef meleeAttack_left;
|
||||
public DrawNodeDef meleeAttack_right;
|
||||
public DrawNodeDef meleeAttack_up;
|
||||
|
||||
public DrawNodeDef rangedAttack_down;
|
||||
public DrawNodeDef rangedAttack_left;
|
||||
public DrawNodeDef rangedAttack_right;
|
||||
public DrawNodeDef rangedAttack_up;
|
||||
|
||||
public DrawNodeDef walk_down;
|
||||
public DrawNodeDef walk_left;
|
||||
public DrawNodeDef walk_right;
|
||||
public DrawNodeDef walk_up;
|
||||
|
||||
public DrawNodeDef GetDrawNodeDef(EntityState state, Orientation orientation,
|
||||
out Orientation? fallbackOrientation)
|
||||
@@ -56,10 +54,7 @@ namespace Data
|
||||
// 根据状态和方向获取对应的DrawNodeDef
|
||||
var result = GetDrawNodeDefInternal(state, orientation);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if (result != null) return result;
|
||||
|
||||
// 如果找不到,按照规则查找替补
|
||||
switch (orientation)
|
||||
@@ -241,24 +236,24 @@ namespace Data
|
||||
|
||||
public class DrawNodeDef : Define
|
||||
{
|
||||
public string[] textures;
|
||||
public DrawNodeDef[] nodes;
|
||||
public string nodeName;
|
||||
public Vector2 position = new(0, 0);
|
||||
public float FPS = 5f;
|
||||
public string nodeName;
|
||||
public DrawNodeDef[] nodes;
|
||||
public string position;
|
||||
public string[] textures;
|
||||
|
||||
public override bool Init(XElement xmlDef)
|
||||
{
|
||||
base.Init(xmlDef);
|
||||
|
||||
nodeName = xmlDef.Attribute("name")?.Value ?? "noName";
|
||||
position = Utils.StringUtils.StringToVector2(xmlDef.Attribute("position")?.Value ?? "0,0");
|
||||
position = xmlDef.Attribute("position")?.Value ?? "0,0";
|
||||
FPS = float.TryParse(xmlDef.Attribute("FPS")?.Value, out var result) ? result : 5.0f;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取播放一遍动画所需的最小时间(取当前节点动画与所有子集动画的最大值)。
|
||||
/// 获取播放一遍动画所需的最小时间(取当前节点动画与所有子集动画的最大值)。
|
||||
/// </summary>
|
||||
/// <returns>播放一遍动画所需的最小时间(秒),如果无动画则为0。</returns>
|
||||
public float GetMinAnimationDuration()
|
||||
@@ -266,29 +261,18 @@ namespace Data
|
||||
var maxDuration = 0f;
|
||||
// 计算当前节点自身的动画时间
|
||||
if (textures != null && textures.Length > 0)
|
||||
{
|
||||
// 只有当FPS大于0时,才计算有效的动画时间。
|
||||
// 如果FPS <= 0,表示该部分动画无法播放,其时长贡献为0,不参与最大值计算。
|
||||
if (FPS > 0)
|
||||
{
|
||||
maxDuration = Math.Max(maxDuration, textures.Length / FPS);
|
||||
}
|
||||
}
|
||||
|
||||
// 递归计算子节点的动画时间,并更新最大值
|
||||
if (nodes != null && nodes.Length > 0)
|
||||
{
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
if (node != null)
|
||||
{
|
||||
maxDuration = Math.Max(maxDuration, node.GetMinAnimationDuration());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return maxDuration;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user