多轮审查评估
This commit is contained in:
@@ -76,10 +76,10 @@ namespace BaseGames.World.Shop
|
||||
return _availableItemsCache;
|
||||
}
|
||||
_availableItemsCache = _inventory.DefaultInventory
|
||||
.Take(_inventory.MaxDisplaySlots)
|
||||
.Where(item => item != null
|
||||
&& !_soldUniqueItems.Contains(item.ItemId)
|
||||
&& (item.MaxPurchaseCount < 0 || GetPurchaseCount(item.ItemId) < item.MaxPurchaseCount))
|
||||
.Take(_inventory.MaxDisplaySlots)
|
||||
.ToList();
|
||||
_isDirty = false;
|
||||
return _availableItemsCache;
|
||||
|
||||
@@ -3,6 +3,57 @@ using BaseGames.Equipment;
|
||||
|
||||
namespace BaseGames.World.Shop
|
||||
{
|
||||
// ─── 商品效果基类及子类 ──────────────────────────────────────────────────
|
||||
// 使用 [SerializeReference] 多态序列化:Inspector 中右键可选择具体效果类型,
|
||||
// 只显示该类型所需字段,消除原平铺字段方案中大量空字段的噪音。
|
||||
|
||||
[System.Serializable]
|
||||
public abstract class ShopItemEffect
|
||||
{
|
||||
public abstract ShopItemType Type { get; }
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class HealthRestorationEffect : ShopItemEffect
|
||||
{
|
||||
public override ShopItemType Type => ShopItemType.HealthRestoration;
|
||||
/// <summary>恢复的 HP 量。</summary>
|
||||
public int Amount;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class CharmItemEffect : ShopItemEffect
|
||||
{
|
||||
public override ShopItemType Type => ShopItemType.CharmItem;
|
||||
/// <summary>购买后解锁/获得的护符。</summary>
|
||||
public CharmSO CharmReference;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class KeyItemEffect : ShopItemEffect
|
||||
{
|
||||
public override ShopItemType Type => ShopItemType.KeyItem;
|
||||
/// <summary>授予玩家的关键道具 ID(对应 GameIds.Collectible)。</summary>
|
||||
public string KeyItemId;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ConsumableBuffEffect : ShopItemEffect
|
||||
{
|
||||
public override ShopItemType Type => ShopItemType.ConsumableBuff;
|
||||
// 可按需在此扩展 BuffId、Duration、Magnitude 等字段
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class MapFragmentEffect : ShopItemEffect
|
||||
{
|
||||
public override ShopItemType Type => ShopItemType.MapFragment;
|
||||
/// <summary>购买后揭示的房间 ID(对应 MapManager.SetMapped)。</summary>
|
||||
public string RoomId;
|
||||
}
|
||||
|
||||
// ─── 商品 SO ──────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// 商店单品 SO(架构 15_MapShopModule §2.1)。
|
||||
/// 资产路径: Assets/ScriptableObjects/Shop/Item_{ItemId}.asset
|
||||
@@ -20,15 +71,17 @@ namespace BaseGames.World.Shop
|
||||
[Header("价格")]
|
||||
public int BasePrice;
|
||||
public bool IsUnique; // 购买一次后永久从库存移除
|
||||
public int MaxPurchaseCount = -1; // -1 = 无限次
|
||||
|
||||
[Header("商品类型")]
|
||||
public ShopItemType ItemType;
|
||||
[Header("商品效果")]
|
||||
[SerializeReference]
|
||||
public ShopItemEffect Effect;
|
||||
|
||||
// 按 ItemType 填写以下字段(其余留空)
|
||||
public int HealthRestoreAmount; // HealthRestoration 类型
|
||||
public CharmSO CharmReference; // CharmItem 类型
|
||||
public string KeyItemId; // KeyItem 类型
|
||||
public int MaxPurchaseCount = -1; // -1 = 无限次
|
||||
/// <summary>
|
||||
/// 便捷属性:从 Effect 类型推导商品分类,供 ShopPanel/UI 按类型渲染图标或提示文字。
|
||||
/// Effect 为 null 时回退到 HealthRestoration(Inspector 未配置的保护值)。
|
||||
/// </summary>
|
||||
public ShopItemType ItemType => Effect?.Type ?? ShopItemType.HealthRestoration;
|
||||
}
|
||||
|
||||
public enum ShopItemType
|
||||
|
||||
Reference in New Issue
Block a user