头像路径

This commit is contained in:
xianyi
2025-08-29 11:33:52 +08:00
parent b3a5232867
commit 19413911d9
2 changed files with 76 additions and 7 deletions

View File

@@ -76,13 +76,12 @@ namespace TcgEngine.UI
hp_txt.text = prev_hp.ToString();
hp_max_txt.text = "/" + player.hp_max.ToString();
AvatarData adata = AvatarData.Get(player.avatar);
if (avatar != null && adata != null && !killed)
avatar.SetAvatar(adata);
delayed_damage_timer -= Time.deltaTime;
if (!IsDamagedDelayed())
prev_hp = player.hp;
// 默认头像
string avatarId = !string.IsNullOrEmpty(player.avatar) ? player.avatar : "horse";
string avatarPath = "Avatar/" + avatarId + ".png";
// 设置头像路径
SetAvatarByPath(avatarPath);
}
@@ -93,6 +92,17 @@ namespace TcgEngine.UI
SlowUpdate();
}
}
/// <summary>
/// 通过路径设置头像
/// </summary>
private void SetAvatarByPath(string avatarPath)
{
if (avatar != null && !killed)
{
avatar.SetAvatarPath(avatarPath);
}
}
void SlowUpdate()
{