2025-08-25 18:24:12 +08:00
|
|
|
using Data;
|
2025-08-19 20:22:10 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace Item
|
|
|
|
{
|
|
|
|
public class ItemResource
|
|
|
|
{
|
2025-08-25 18:24:12 +08:00
|
|
|
public string DefName { get; protected set; } // 新增:物品的定义名称,唯一标识符
|
|
|
|
public string Name { get; protected set; } // 物品的显示名称 (来自 label)
|
|
|
|
public string Description { get; protected set; }
|
|
|
|
public Sprite Icon { get; protected set; }
|
|
|
|
public ItemRarity Rarity { get; protected set; }
|
|
|
|
public int MaxStack { get; protected set; }
|
|
|
|
public bool IsEquippable { get; protected set; }
|
|
|
|
|
|
|
|
// 构造函数,现在接受 defName
|
|
|
|
public ItemResource(string defName, string name, string description, Sprite icon, ItemRarity rarity, int maxStack, bool isEquippable)
|
|
|
|
{
|
|
|
|
DefName = defName; // 赋值 defName
|
|
|
|
Name = name;
|
|
|
|
Description = description;
|
|
|
|
Icon = icon;
|
|
|
|
Rarity = rarity;
|
|
|
|
MaxStack = maxStack;
|
|
|
|
IsEquippable = isEquippable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class WeaponResource : ItemResource
|
|
|
|
{
|
|
|
|
public AttributesDef Attributes { get; private set; }
|
|
|
|
|
|
|
|
// 构造函数,调用基类构造函数并传递 defName
|
|
|
|
public WeaponResource(string defName, string name, string description, Sprite icon, ItemRarity rarity, int maxStack, bool isEquippable, AttributesDef attributes)
|
|
|
|
: base(defName, name, description, icon, rarity, maxStack, isEquippable)
|
|
|
|
{
|
|
|
|
Attributes = attributes;
|
|
|
|
}
|
2025-08-19 20:22:10 +08:00
|
|
|
}
|
2025-08-25 18:24:12 +08:00
|
|
|
|
2025-08-19 20:22:10 +08:00
|
|
|
}
|