Passion & UI
This commit is contained in:
@@ -40,6 +40,28 @@ namespace Cielonos.MainGame.Characters
|
||||
|
||||
public partial class BackpackSubmodule
|
||||
{
|
||||
public bool HaveItem(string itemClass)
|
||||
{
|
||||
Type type = Type.GetType($"Cielonos.MainGame.Inventory.Collections.{itemClass}");
|
||||
if (type == null)
|
||||
{
|
||||
Debug.LogError($"[Backpack] 无法找到道具类类型:'{itemClass}'。确保它在命名空间 Cielonos.MainGame.Inventory.Collections 中。");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof(MainWeaponBase).IsAssignableFrom(type))
|
||||
return mainWeapons.Exists(item => item.GetType() == type);
|
||||
if (typeof(SupportEquipmentBase).IsAssignableFrom(type))
|
||||
return supportEquipments.Exists(item => item.GetType() == type);
|
||||
if (typeof(PassiveEquipmentBase).IsAssignableFrom(type))
|
||||
return passiveEquipments.Exists(item => item.GetType() == type);
|
||||
if (typeof(ConsumableBase).IsAssignableFrom(type))
|
||||
return consumables.Exists(item => item.GetType() == type);
|
||||
|
||||
Debug.LogError($"[Backpack] 类型 '{itemClass}' 不属于任何已知的道具基类。");
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过 Resources 加载 Prefab,实例化到对应的 Container 下,然后加入背包。
|
||||
/// 若为消耗品且背包中已存在同类型实例,则直接堆叠,不再重复生成。
|
||||
|
||||
Reference in New Issue
Block a user