[Add] GameLoop base
This commit is contained in:
@@ -4,6 +4,7 @@ using YachtDice.Economy;
|
||||
using YachtDice.Game;
|
||||
using YachtDice.Inventory;
|
||||
using YachtDice.Player;
|
||||
using YachtDice.Run;
|
||||
using YachtDice.Shop;
|
||||
|
||||
namespace YachtDice.UI.Presentation
|
||||
@@ -57,6 +58,13 @@ namespace YachtDice.UI.Presentation
|
||||
_gameLoopController.OnRollComplete += HandleRollComplete;
|
||||
_gameLoopController.OnScored += HandleScored;
|
||||
_gameLoopController.OnGameOver += HandleGameOver;
|
||||
_gameLoopController.OnBetStarted += HandleBetStarted;
|
||||
_gameLoopController.OnShopOpened += HandleShopOpened;
|
||||
_gameLoopController.OnShopClosed += HandleShopClosed;
|
||||
_gameLoopController.OnStoredRollsChanged += HandleStoredRollsChanged;
|
||||
_gameLoopController.OnQuotaChanged += HandleQuotaChanged;
|
||||
_gameLoopController.OnCycleCompleted += HandleCycleCompleted;
|
||||
_gameLoopController.OnPhaseChanged += HandlePhaseChanged;
|
||||
|
||||
_dicePanelPresenter.RollClicked += HandleRollClicked;
|
||||
_dicePanelPresenter.DiceToggled += HandleDiceToggled;
|
||||
@@ -70,6 +78,7 @@ namespace YachtDice.UI.Presentation
|
||||
|
||||
_saveService.Load();
|
||||
_gameInfoPresenter.SetCurrencyText(_currencyBank.Balance);
|
||||
_gameInfoPresenter.SetShopButtonInteractable(false);
|
||||
_gameLoopController.StartNewGame();
|
||||
}
|
||||
|
||||
@@ -79,6 +88,13 @@ namespace YachtDice.UI.Presentation
|
||||
_gameLoopController.OnRollComplete -= HandleRollComplete;
|
||||
_gameLoopController.OnScored -= HandleScored;
|
||||
_gameLoopController.OnGameOver -= HandleGameOver;
|
||||
_gameLoopController.OnBetStarted -= HandleBetStarted;
|
||||
_gameLoopController.OnShopOpened -= HandleShopOpened;
|
||||
_gameLoopController.OnShopClosed -= HandleShopClosed;
|
||||
_gameLoopController.OnStoredRollsChanged -= HandleStoredRollsChanged;
|
||||
_gameLoopController.OnQuotaChanged -= HandleQuotaChanged;
|
||||
_gameLoopController.OnCycleCompleted -= HandleCycleCompleted;
|
||||
_gameLoopController.OnPhaseChanged -= HandlePhaseChanged;
|
||||
|
||||
_dicePanelPresenter.RollClicked -= HandleRollClicked;
|
||||
_dicePanelPresenter.DiceToggled -= HandleDiceToggled;
|
||||
@@ -95,8 +111,9 @@ namespace YachtDice.UI.Presentation
|
||||
|
||||
private void HandleTurnStarted(int turn)
|
||||
{
|
||||
_gameInfoPresenter.SetTurnText(turn, _categoryCatalog.Count);
|
||||
UpdateRunInfoText();
|
||||
_dicePanelPresenter.ResetForNewTurn();
|
||||
_dicePanelPresenter.SetRollingEnabled(true);
|
||||
_scoreCardPresenter.ClearAllPreviews();
|
||||
}
|
||||
|
||||
@@ -110,6 +127,7 @@ namespace YachtDice.UI.Presentation
|
||||
{
|
||||
_scoreCardPresenter.SetCategoryScored(category, finalScore);
|
||||
_scoreCardPresenter.UpdateTotalDisplay(_scoreSummaryService.Calculate());
|
||||
UpdateRunInfoText();
|
||||
_saveService.Save();
|
||||
}
|
||||
|
||||
@@ -118,6 +136,8 @@ namespace YachtDice.UI.Presentation
|
||||
_dicePanelPresenter.HandleGameOver();
|
||||
_scoreCardPresenter.SetAllInteractable(false);
|
||||
_gameInfoPresenter.ShowGameOver(_scoreSummaryService.Calculate().DisplayTotal);
|
||||
_shopController.Close();
|
||||
_gameInfoPresenter.SetShopButtonInteractable(false);
|
||||
_saveService.Save();
|
||||
}
|
||||
|
||||
@@ -142,6 +162,8 @@ namespace YachtDice.UI.Presentation
|
||||
private void HandleNewGameClicked()
|
||||
{
|
||||
_gameInfoPresenter.HideGameOver();
|
||||
_shopController.Close();
|
||||
_gameInfoPresenter.SetShopButtonInteractable(false);
|
||||
_scoreCardPresenter.ResetAll();
|
||||
_dicePanelPresenter.ResetForNewGame();
|
||||
_gameLoopController.StartNewGame();
|
||||
@@ -149,7 +171,18 @@ namespace YachtDice.UI.Presentation
|
||||
|
||||
private void HandleShopClicked()
|
||||
{
|
||||
_shopController.ToggleVisibility();
|
||||
if (!_gameLoopController.CanOpenShopManually())
|
||||
return;
|
||||
|
||||
if (_shopController.IsOpen)
|
||||
{
|
||||
_shopController.Close();
|
||||
_gameLoopController.CompleteShop();
|
||||
}
|
||||
else
|
||||
{
|
||||
_shopController.Open();
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleInventoryClicked()
|
||||
@@ -160,11 +193,63 @@ namespace YachtDice.UI.Presentation
|
||||
private void HandleCurrencyChanged(int newBalance)
|
||||
{
|
||||
_gameInfoPresenter.SetCurrencyText(newBalance);
|
||||
UpdateRunInfoText();
|
||||
}
|
||||
|
||||
private void HandlePlayerChangedForSave()
|
||||
{
|
||||
_saveService.Save();
|
||||
}
|
||||
|
||||
private void HandleBetStarted(int betIndex)
|
||||
{
|
||||
UpdateRunInfoText();
|
||||
}
|
||||
|
||||
private void HandleShopOpened()
|
||||
{
|
||||
_shopController.Open();
|
||||
_gameInfoPresenter.SetShopButtonInteractable(true);
|
||||
_dicePanelPresenter.SetRollingEnabled(false);
|
||||
UpdateRunInfoText();
|
||||
}
|
||||
|
||||
private void HandleShopClosed()
|
||||
{
|
||||
_shopController.Close();
|
||||
_gameInfoPresenter.SetShopButtonInteractable(false);
|
||||
UpdateRunInfoText();
|
||||
}
|
||||
|
||||
private void HandleStoredRollsChanged(int value)
|
||||
{
|
||||
UpdateRunInfoText();
|
||||
}
|
||||
|
||||
private void HandleQuotaChanged(int value)
|
||||
{
|
||||
UpdateRunInfoText();
|
||||
}
|
||||
|
||||
private void HandleCycleCompleted(int bonus, int storedRolls)
|
||||
{
|
||||
_scoreCardPresenter.ResetAll();
|
||||
_scoreCardPresenter.UpdateTotalDisplay(_scoreSummaryService.Calculate());
|
||||
UpdateRunInfoText();
|
||||
}
|
||||
|
||||
private void HandlePhaseChanged(RunPhase phase)
|
||||
{
|
||||
if (phase != RunPhase.Shop)
|
||||
_gameInfoPresenter.SetShopButtonInteractable(false);
|
||||
|
||||
UpdateRunInfoText();
|
||||
}
|
||||
|
||||
private void UpdateRunInfoText()
|
||||
{
|
||||
var info = $"Bet {_gameLoopController.CurrentBet} | Stage {_gameLoopController.CurrentStage}/3 | Target {_gameLoopController.CurrentStageTarget} | Quota {_gameLoopController.CurrentBaseQuota} | Bank {_gameLoopController.StoredRolls}";
|
||||
_gameInfoPresenter.SetRunInfoText(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user