Files
YachtDice/Assets/Scripts/UI/GameController.cs
T
2026-03-04 06:48:21 +07:00

105 lines
3.6 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 GameController : MonoBehaviour
{
[Header("MVP Views")]
[SerializeField] private ScoreCardView scoreCardView;
[SerializeField] private DicePanelView dicePanelView;
[SerializeField] private GameInfoView gameInfoView;
private GameManager _gameManager;
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(
GameManager gameManager,
ScoringSystem scoringSystem,
DiceManager diceManager,
CurrencyBank currencyBank,
ShopController shopController,
InventoryController inventoryController,
CategoryCatalog categoryCatalog,
PlayerModel playerModel,
IGameSaveService saveService,
IScoreSummaryService scoreSummaryService)
{
this._gameManager = gameManager;
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, _gameManager, _diceManager);
_scoreCardPresenter = new ScoreCardPresenter(scoreCardView, _categoryCatalog, _scoringSystem, _diceManager);
_gameInfoPresenter = new GameInfoPresenter(gameInfoView);
_gameFlowPresenter = new GameFlowPresenter(
_gameManager,
_scoringSystem,
_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();
}
}
}