[Add] Game Loop Playable
This commit is contained in:
@@ -65,6 +65,7 @@ namespace YachtDice.UI.Presentation
|
||||
_gameLoopController.OnQuotaChanged += HandleQuotaChanged;
|
||||
_gameLoopController.OnCycleCompleted += HandleCycleCompleted;
|
||||
_gameLoopController.OnPhaseChanged += HandlePhaseChanged;
|
||||
_gameLoopController.OnShopAvailabilityChanged += HandleShopAvailabilityChanged;
|
||||
|
||||
_dicePanelPresenter.RollClicked += HandleRollClicked;
|
||||
_dicePanelPresenter.DiceToggled += HandleDiceToggled;
|
||||
@@ -72,13 +73,14 @@ namespace YachtDice.UI.Presentation
|
||||
_gameInfoPresenter.NewGameClicked += HandleNewGameClicked;
|
||||
_gameInfoPresenter.ShopClicked += HandleShopClicked;
|
||||
_gameInfoPresenter.InventoryClicked += HandleInventoryClicked;
|
||||
_shopController.OnCloseRequested += HandleShopCloseRequested;
|
||||
|
||||
_currencyBank.OnBalanceChanged += HandleCurrencyChanged;
|
||||
_playerModel.OnChanged += HandlePlayerChangedForSave;
|
||||
|
||||
_saveService.Load();
|
||||
_gameInfoPresenter.SetCurrencyText(_currencyBank.Balance);
|
||||
_gameInfoPresenter.SetShopButtonInteractable(false);
|
||||
_gameInfoPresenter.SetShopButtonInteractable(_gameLoopController.CanOpenShopManually());
|
||||
_gameLoopController.StartNewGame();
|
||||
}
|
||||
|
||||
@@ -95,6 +97,7 @@ namespace YachtDice.UI.Presentation
|
||||
_gameLoopController.OnQuotaChanged -= HandleQuotaChanged;
|
||||
_gameLoopController.OnCycleCompleted -= HandleCycleCompleted;
|
||||
_gameLoopController.OnPhaseChanged -= HandlePhaseChanged;
|
||||
_gameLoopController.OnShopAvailabilityChanged -= HandleShopAvailabilityChanged;
|
||||
|
||||
_dicePanelPresenter.RollClicked -= HandleRollClicked;
|
||||
_dicePanelPresenter.DiceToggled -= HandleDiceToggled;
|
||||
@@ -102,6 +105,7 @@ namespace YachtDice.UI.Presentation
|
||||
_gameInfoPresenter.NewGameClicked -= HandleNewGameClicked;
|
||||
_gameInfoPresenter.ShopClicked -= HandleShopClicked;
|
||||
_gameInfoPresenter.InventoryClicked -= HandleInventoryClicked;
|
||||
_shopController.OnCloseRequested -= HandleShopCloseRequested;
|
||||
|
||||
_currencyBank.OnBalanceChanged -= HandleCurrencyChanged;
|
||||
|
||||
@@ -115,12 +119,14 @@ namespace YachtDice.UI.Presentation
|
||||
_dicePanelPresenter.ResetForNewTurn();
|
||||
_dicePanelPresenter.SetRollingEnabled(true);
|
||||
_scoreCardPresenter.ClearAllPreviews();
|
||||
_gameInfoPresenter.SetShopButtonInteractable(_gameLoopController.CanOpenShopManually());
|
||||
}
|
||||
|
||||
private void HandleRollComplete(int rollNumber)
|
||||
{
|
||||
_dicePanelPresenter.HandleRollComplete(rollNumber);
|
||||
_scoreCardPresenter.UpdatePreviewScores();
|
||||
_gameInfoPresenter.SetShopButtonInteractable(_gameLoopController.CanOpenShopManually());
|
||||
}
|
||||
|
||||
private void HandleScored(CategoryDefinition category, int finalScore)
|
||||
@@ -143,9 +149,11 @@ namespace YachtDice.UI.Presentation
|
||||
|
||||
private void HandleRollClicked()
|
||||
{
|
||||
if (!_gameLoopController.Roll())
|
||||
return;
|
||||
|
||||
_dicePanelPresenter.PrepareForRoll();
|
||||
_scoreCardPresenter.SetAllInteractable(false);
|
||||
_gameLoopController.Roll();
|
||||
}
|
||||
|
||||
private void HandleDiceToggled(int index)
|
||||
@@ -175,14 +183,9 @@ namespace YachtDice.UI.Presentation
|
||||
return;
|
||||
|
||||
if (_shopController.IsOpen)
|
||||
{
|
||||
_shopController.Close();
|
||||
_gameLoopController.CompleteShop();
|
||||
}
|
||||
else
|
||||
{
|
||||
_shopController.Open();
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleInventoryClicked()
|
||||
@@ -208,16 +211,14 @@ namespace YachtDice.UI.Presentation
|
||||
|
||||
private void HandleShopOpened()
|
||||
{
|
||||
_shopController.Open();
|
||||
_gameInfoPresenter.SetShopButtonInteractable(true);
|
||||
_dicePanelPresenter.SetRollingEnabled(false);
|
||||
_gameInfoPresenter.SetShopButtonInteractable(_gameLoopController.CanOpenShopManually());
|
||||
UpdateRunInfoText();
|
||||
}
|
||||
|
||||
private void HandleShopClosed()
|
||||
{
|
||||
_shopController.Close();
|
||||
_gameInfoPresenter.SetShopButtonInteractable(false);
|
||||
_gameInfoPresenter.SetShopButtonInteractable(_gameLoopController.CanOpenShopManually());
|
||||
UpdateRunInfoText();
|
||||
}
|
||||
|
||||
@@ -240,16 +241,36 @@ namespace YachtDice.UI.Presentation
|
||||
|
||||
private void HandlePhaseChanged(RunPhase phase)
|
||||
{
|
||||
if (phase != RunPhase.Shop)
|
||||
_gameInfoPresenter.SetShopButtonInteractable(false);
|
||||
|
||||
_gameInfoPresenter.SetShopButtonInteractable(_gameLoopController.CanOpenShopManually());
|
||||
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);
|
||||
var phase = _gameLoopController.CurrentPhase.ToString();
|
||||
_gameInfoPresenter.SetRunHud(
|
||||
phase,
|
||||
_gameLoopController.CurrentBet,
|
||||
_gameLoopController.CurrentStage,
|
||||
3,
|
||||
_gameLoopController.CurrentStageTarget,
|
||||
_gameLoopController.CurrentBaseQuota,
|
||||
_gameLoopController.StoredRolls);
|
||||
}
|
||||
|
||||
private void HandleShopCloseRequested()
|
||||
{
|
||||
_shopController.Close();
|
||||
_gameLoopController.CompleteShop();
|
||||
}
|
||||
|
||||
private void HandleShopAvailabilityChanged(bool isAvailable)
|
||||
{
|
||||
if (!isAvailable && _shopController.IsOpen)
|
||||
_shopController.Close();
|
||||
|
||||
_gameInfoPresenter.SetShopButtonInteractable(isAvailable);
|
||||
UpdateRunInfoText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user