(client) feat:实现血条显示,实现攻击交互,添加碰撞体;fix:修复部分朝向贴图加载失败的问题;chore:规范工作类和行为获取类命名

This commit is contained in:
m0_75251201
2025-08-13 22:53:57 +08:00
parent 9922f06990
commit 35924f3695
37 changed files with 1006 additions and 183 deletions

View File

@ -98,7 +98,7 @@ namespace Managers
// 初始化实体组件
entityComponent.Init(pawnDef);
// 确保派系键存在,并初始化对应的列表
var factionKey = pawnDef.attributes.label ?? "default"; // 使用 null 合并运算符简化代码
if (!factionEntities.ContainsKey(factionKey))

View File

@ -0,0 +1,45 @@
using System.Collections.Generic;
using System.Linq;
using Data;
using Item;
namespace Managers
{
public class ItemResourceManager:Utils.Singleton<ItemResourceManager>
{
//定义名,物品
public Dictionary<string,Item.ItemResource> items;
public void Init()
{
var itemDefs = Managers.DefineManager.Instance.QueryDefinesByType<ItemDef>();
foreach (var itemDef in itemDefs)
{
var item=new Item.ItemResource();
item.name = itemDef.label;
item.description = itemDef.description;
item.icon = Managers.PackagesImageManager.Instance.GetSprite(itemDef.texture);
}
}
public ItemResource GetItem(string defName)
{
return items.GetValueOrDefault(defName,null);
}
// <summary>
/// 按物品名称查找物品
/// </summary>
/// <param name="itemName">要查找的物品名称</param>
/// <returns>找到的物品对象,如果未找到则返回 null</returns>
public ItemResource FindItemByName(string itemName)
{
if (string.IsNullOrEmpty(itemName))
{
return null;
}
return items.Values.FirstOrDefault(item => item.name == itemName);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: eafd50f3a0594a6e845ecf87b04744ce
timeCreated: 1755062360

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))