Rework shop to support multiple item types and add unified PlayerModel
Generalize the shop from selling only ModifierDefinition to any IShopItem (modifiers + dice). Add purchase condition checks, hover tooltips, and fixed prices. Introduce PlayerModel as a facade over CurrencyBank, InventoryModel, and DiceCollection for centralized state and save/load. New files: - IShopItem interface for purchasable items - ShopCatalog SO (unified catalog for all item types) - ShopTooltipView (description on hover) - PlayerModel (aggregates player state) - DiceCollection (owned dice tracking) - DiceCatalog SO (dice definition registry) - DiceCollectionTests Modified: - ModifierDefinition/DieDefinitionSO implement IShopItem - ShopModel/ShopView/ShopItemView/ShopController use IShopItem - SaveData v3 with OwnedDiceIds - GameController uses PlayerModel for save/load - GameLifetimeScope registers new services Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YachtDice.Shop
|
||||
{
|
||||
public class ShopTooltipView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text titleText;
|
||||
[SerializeField] private TMP_Text descriptionText;
|
||||
[SerializeField] private TMP_Text priceText;
|
||||
[SerializeField] private RectTransform panelRect;
|
||||
[SerializeField] private Vector2 offset = new(10f, -10f);
|
||||
|
||||
public void Show(IShopItem item, RectTransform anchor)
|
||||
{
|
||||
if (titleText != null) titleText.text = item.DisplayName;
|
||||
if (descriptionText != null) descriptionText.text = item.Description;
|
||||
if (priceText != null) priceText.text = $"Price: {item.ShopPrice}";
|
||||
|
||||
PositionNear(anchor);
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void PositionNear(RectTransform anchor)
|
||||
{
|
||||
if (panelRect == null || anchor == null) return;
|
||||
|
||||
Vector3 worldPos = anchor.position;
|
||||
panelRect.position = worldPos + (Vector3)offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user