Files
YachtDice/Assets/Scripts/UI/GamePresentationRoot.cs
2026-03-18 09:13:48 +07:00

104 lines
3.7 KiB
C#

using System;
using UnityEngine;
using VContainer;
using YachtDice.Categories;
using YachtDice.Economy;
using YachtDice.Game;
using YachtDice.Inventory;
using YachtDice.Player;
using YachtDice.Scoring;
using YachtDice.Shop;
using YachtDice.UI.Presentation;
namespace YachtDice.UI
{
public class GamePresentationRoot : MonoBehaviour
{
[Header("MVP Views")]
[SerializeField] private ScoreCardView scoreCardView;
[SerializeField] private DicePanelView dicePanelView;
[SerializeField] private GameInfoView gameInfoView;
private GameLoopController _gameLoopController;
private ScoringSystem _scoringSystem;
private DiceManager _diceManager;
private CurrencyBank _currencyBank;
private ShopController _shopController;
private InventoryController _inventoryController;
private CategoryCatalog _categoryCatalog;
private PlayerModel _playerModel;
private IGameSaveService _saveService;
private IScoreSummaryService _scoreSummaryService;
private DicePanelPresenter _dicePanelPresenter;
private ScoreCardPresenter _scoreCardPresenter;
private GameInfoPresenter _gameInfoPresenter;
private GameFlowPresenter _gameFlowPresenter;
[Inject]
public void Construct(
GameLoopController gameLoopController,
ScoringSystem scoringSystem,
DiceManager diceManager,
CurrencyBank currencyBank,
ShopController shopController,
InventoryController inventoryController,
CategoryCatalog categoryCatalog,
PlayerModel playerModel,
IGameSaveService saveService,
IScoreSummaryService scoreSummaryService)
{
this._gameLoopController = gameLoopController;
this._scoringSystem = scoringSystem;
this._diceManager = diceManager;
this._currencyBank = currencyBank;
this._shopController = shopController;
this._inventoryController = inventoryController;
this._categoryCatalog = categoryCatalog;
this._playerModel = playerModel;
this._saveService = saveService;
this._scoreSummaryService = scoreSummaryService;
}
private void Start()
{
_dicePanelPresenter = new DicePanelPresenter(dicePanelView, _gameLoopController, _diceManager);
_scoreCardPresenter = new ScoreCardPresenter(scoreCardView, _gameLoopController, _categoryCatalog, _scoringSystem, _diceManager);
_gameInfoPresenter = new GameInfoPresenter(gameInfoView);
_gameFlowPresenter = new GameFlowPresenter(
_gameLoopController,
_diceManager,
_currencyBank,
_shopController,
_inventoryController,
_categoryCatalog,
_playerModel,
_saveService,
_scoreSummaryService,
_dicePanelPresenter,
_scoreCardPresenter,
_gameInfoPresenter);
_dicePanelPresenter.Initialize();
_scoreCardPresenter.Initialize();
_gameInfoPresenter.Initialize();
_gameFlowPresenter.Initialize();
}
private void OnDestroy()
{
DisposeIfNeeded(_gameFlowPresenter);
DisposeIfNeeded(_gameInfoPresenter);
DisposeIfNeeded(_scoreCardPresenter);
DisposeIfNeeded(_dicePanelPresenter);
}
private static void DisposeIfNeeded(IDisposable disposable)
{
if (disposable != null)
disposable.Dispose();
}
}
}