68c4abace3
Replace the entire static, enum-based modifier pipeline with a composition-based, data-driven architecture using ScriptableObject polymorphism. New modifiers can now be created by assembling SO building blocks (Conditions + Effects + Behaviors) — no core code edits needed. New architecture: - Core/: TriggerType, ModifierPhase, ModifierContext, ICondition, IEffect - Definition/: ModifierDefinitionSO, ModifierBehaviorSO, ConditionSO, EffectSO, ModifierCatalogSO - Conditions/: DieValueCondition, CategoryCondition, MinScoreCondition, DiceCountCondition - Effects/: AddFlat, AddPerDie, Multiply, MultiplyPerDie, PostMultiply, AddCurrency, ConsumeCharge - Runtime/: ModifierInstance, ModifierRegistry (non-static service) - Pipeline/: async ModifierPipeline with phase ordering, tracing, anti-recursion - Editor/: ModifierDefinitionValidator with menu items - Events/: GameEventBus (non-static typed dispatcher) - DI/: GameLifetimeScope (VContainer composition root) Deleted old system: ModifierData, ModifierEffect, ModifierEnums, ModifierPipeline (static), ModifierRuntime, ModifierTarget, ShopCatalog, ModifierAssetCreator. Updated: ScoringSystem (VContainer + async), InventoryModel (delegates to ModifierRegistry), ShopModel (uses ModifierDefinitionSO), GameController (VContainer injection), SaveData (uses Runtime.ModifierSaveEntry), all views/controllers, and all test files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
93 lines
3.2 KiB
C#
93 lines
3.2 KiB
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using YachtDice.Modifiers.Core;
|
|
using YachtDice.Modifiers.Definition;
|
|
|
|
namespace YachtDice.Shop
|
|
{
|
|
public class ShopItemView : MonoBehaviour
|
|
{
|
|
[SerializeField] private Image iconImage;
|
|
[SerializeField] private TMP_Text nameText;
|
|
[SerializeField] private TMP_Text descriptionText;
|
|
[SerializeField] private TMP_Text priceText;
|
|
[SerializeField] private TMP_Text rarityText;
|
|
[SerializeField] private Button buyButton;
|
|
[SerializeField] private TMP_Text buyButtonText;
|
|
[SerializeField] private Image background;
|
|
|
|
[Header("Rarity Colors")]
|
|
[SerializeField] private Color commonColor = Color.white;
|
|
[SerializeField] private Color uncommonColor = new(0.4f, 0.8f, 0.4f);
|
|
[SerializeField] private Color rareColor = new(0.4f, 0.6f, 1f);
|
|
[SerializeField] private Color epicColor = new(0.8f, 0.4f, 1f);
|
|
|
|
private ModifierDefinitionSO data;
|
|
|
|
public event Action<ModifierDefinitionSO> OnBuyClicked;
|
|
|
|
private void Awake()
|
|
{
|
|
if (buyButton != null)
|
|
buyButton.onClick.AddListener(() => OnBuyClicked?.Invoke(data));
|
|
}
|
|
|
|
public void Setup(ModifierDefinitionSO modifierDef, ShopItemState state)
|
|
{
|
|
data = modifierDef;
|
|
|
|
if (nameText != null) nameText.text = data.DisplayName;
|
|
if (descriptionText != null) descriptionText.text = data.Description;
|
|
if (priceText != null) priceText.text = data.ShopPrice.ToString();
|
|
if (iconImage != null && data.Icon != null) iconImage.sprite = data.Icon;
|
|
|
|
if (rarityText != null)
|
|
{
|
|
rarityText.text = data.Rarity.ToString();
|
|
rarityText.color = GetRarityColor(data.Rarity);
|
|
}
|
|
|
|
SetState(state);
|
|
}
|
|
|
|
public void SetState(ShopItemState state)
|
|
{
|
|
if (buyButton == null) return;
|
|
|
|
switch (state)
|
|
{
|
|
case ShopItemState.Available:
|
|
buyButton.interactable = true;
|
|
if (buyButtonText != null) buyButtonText.text = "Buy";
|
|
break;
|
|
case ShopItemState.RepurchaseAvailable:
|
|
buyButton.interactable = true;
|
|
if (buyButtonText != null) buyButtonText.text = "Buy";
|
|
break;
|
|
case ShopItemState.TooExpensive:
|
|
buyButton.interactable = false;
|
|
if (buyButtonText != null) buyButtonText.text = "Buy";
|
|
break;
|
|
case ShopItemState.Owned:
|
|
buyButton.interactable = false;
|
|
if (buyButtonText != null) buyButtonText.text = "Owned";
|
|
break;
|
|
}
|
|
}
|
|
|
|
private Color GetRarityColor(ModifierRarity rarity)
|
|
{
|
|
return rarity switch
|
|
{
|
|
ModifierRarity.Common => commonColor,
|
|
ModifierRarity.Uncommon => uncommonColor,
|
|
ModifierRarity.Rare => rareColor,
|
|
ModifierRarity.Epic => epicColor,
|
|
_ => commonColor
|
|
};
|
|
}
|
|
}
|
|
}
|