(client)feat:实现子弹定义以及生成,实现初始化动画,实现血条 (#43)

Co-authored-by: zzdxxz <2079238449@qq.com>
Co-committed-by: zzdxxz <2079238449@qq.com>
This commit is contained in:
2025-08-19 20:22:10 +08:00
committed by TheRedApricot
parent 670f778eee
commit d91210a6ff
119 changed files with 4797 additions and 2929 deletions

View File

@ -90,16 +90,16 @@ namespace Managers
}
// 判断是否为 Unity 资源路径
bool isUnityResource = drawOrder.texturePath.StartsWith("res:", StringComparison.OrdinalIgnoreCase);
string rootPath = packRootSite[drawOrder.packID];
var isUnityResource = drawOrder.texturePath.StartsWith("res:", StringComparison.OrdinalIgnoreCase);
var rootPath = packRootSite[drawOrder.packID];
if (isUnityResource)
{
// 移除 "res:" 前缀并适配 Unity 资源路径规则
string resourceFolder = drawOrder.texturePath.Substring(4).TrimStart('/').Replace('\\', '/');
var resourceFolder = drawOrder.texturePath.Substring(4).TrimStart('/').Replace('\\', '/');
// 加载文件夹下的所有纹理资源
Texture2D[] textures = Resources.LoadAll<Texture2D>(resourceFolder);
var textures = Resources.LoadAll<Texture2D>(resourceFolder);
if (textures == null || textures.Length == 0)
{
Debug.LogWarning($"No textures found in Unity resource folder: {resourceFolder}");
@ -124,7 +124,6 @@ namespace Managers
new Vector2(0.5f, 0.5f), // 中心点
drawOrder.pixelsPerUnit
);
var name = image.name;
// 插入纹理
@ -269,7 +268,11 @@ namespace Managers
sprites.Clear();
Init();
}
public Sprite GetSprite(ImageDef ima)
{
return GetSprite(ima.packID,ima.name);
}
public Sprite GetSprite(string packID, string name)
{
if (string.IsNullOrEmpty(packID))
@ -343,14 +346,14 @@ namespace Managers
if (!bodyTexture.TryGetValue(packageName, out var packageDict))
{
Debug.LogWarning($"Package '{packageName}' not found.");
return Array.Empty<Sprite>();
return new[] { defaultSprite };
}
// 检查文件路径是否存在
if (!packageDict.TryGetValue(filePath, out var pathDict))
{
Debug.LogWarning($"File path '{filePath}' not found in package '{packageName}'.");
return Array.Empty<Sprite>();
return new[] { defaultSprite };
}
// 收集所有匹配的Sprite
@ -374,7 +377,7 @@ namespace Managers
// 尝试解析编号
if (int.TryParse(suffix, out var number))
{
sprites.Add((number, Value: value));
sprites.Add((number, value));
}
}
}