Files
YachtDice/Assets/Scripts/UI/GameInfoView.cs
T
horooko ba626acb9b [Add] Universal modifier system, shop, inventory & persistence
Replace hardcoded BonusForOnes/MultiplierForSixes with data-driven
modifier system supporting 2 scopes (SelectedCategory, AnyCategoryClosed),
4 effect types, durability modes (Permanent, LimitedUses), and
configurable targets via ScriptableObject (ModifierData).

- Modifier domain: ModifierEnums, ModifierTarget, ModifierData,
  ModifierRuntime, ModifierEffect (dict-based strategy), ModifierPipeline
  (4-pass: cat-additive → cat-multiplicative → final-additive → final-multiplicative)
- ScoringSystem: replaced old modifier list with ModifierPipeline integration,
  added OnCategoryConfirmed event
- Shop MVC: ShopCatalog (SO), ShopModel, ShopView, ShopItemView, ShopController
- Inventory MVC: InventoryModel (activate/deactivate/sell/durability),
  InventoryView, InventorySlotView, InventoryController
- CurrencyBank: editor-adjustable balance with events
- Persistence: SaveData + SaveSystem (Newtonsoft JSON + PlayerPrefs)
- Editor: ModifierAssetCreator menu item to generate 6 example modifiers + catalog
- Tests: 6 test classes covering effects, pipeline, scoring, shop, inventory, save
- GameController: wired shop/inventory/save lifecycle
- GameInfoView: added currency display, shop/inventory toggle buttons

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 06:40:33 +07:00

70 lines
1.8 KiB
C#

using System;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public sealed class GameInfoView : MonoBehaviour
{
[Header("Turn Info")]
[SerializeField] private TMP_Text turnText;
[Header("Currency")]
[SerializeField] private TMP_Text currencyText;
[Header("Navigation")]
[SerializeField] private Button shopButton;
[SerializeField] private Button inventoryButton;
[Header("Game Over Overlay")]
[SerializeField] private GameObject gameOverPanel;
[SerializeField] private TMP_Text finalScoreText;
[SerializeField] private Button newGameButton;
public event Action OnNewGameClicked;
public event Action OnShopClicked;
public event Action OnInventoryClicked;
private void Awake()
{
newGameButton.onClick.AddListener(() => OnNewGameClicked?.Invoke());
gameOverPanel.SetActive(false);
if (shopButton != null)
shopButton.onClick.AddListener(() => OnShopClicked?.Invoke());
if (inventoryButton != null)
inventoryButton.onClick.AddListener(() => OnInventoryClicked?.Invoke());
}
public void SetTurnText(int turn, int maxTurns)
{
turnText.text = $"Ход {turn} / {maxTurns}";
}
public void SetCurrencyText(int amount)
{
if (currencyText != null)
currencyText.text = amount.ToString();
}
public void ShowGameOver(int finalScore)
{
gameOverPanel.SetActive(true);
finalScoreText.text = $"Итого: {finalScore}";
}
public void HideGameOver()
{
gameOverPanel.SetActive(false);
}
private void OnDestroy()
{
newGameButton.onClick.RemoveAllListeners();
if (shopButton != null)
shopButton.onClick.RemoveAllListeners();
if (inventoryButton != null)
inventoryButton.onClick.RemoveAllListeners();
}
}