多轮审查评估

This commit is contained in:
2026-05-13 09:19:54 +08:00
parent 458f344e83
commit 1b37297585
57 changed files with 3019 additions and 218 deletions

View File

@@ -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;

View File

@@ -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 时回退到 HealthRestorationInspector 未配置的保护值)。
/// </summary>
public ShopItemType ItemType => Effect?.Type ?? ShopItemType.HealthRestoration;
}
public enum ShopItemType