diff --git a/Assets/Scenes/Scene.unity b/Assets/Scenes/Scene.unity index 1785143..4b2e22a 100644 --- a/Assets/Scenes/Scene.unity +++ b/Assets/Scenes/Scene.unity @@ -158,9 +158,9 @@ MonoBehaviour: shopCatalog: {fileID: 11400000, guid: 7efc21139c0b2234194047239dcf8a71, type: 2} scoringSystem: {fileID: 1016044386} currencyBank: {fileID: 389543052} - gameManager: {fileID: 2136136801} + gameLoopController: {fileID: 2136136801} diceManager: {fileID: 822363842} - gameController: {fileID: 1035691492} + gamePresentationRoot: {fileID: 1035691492} shopController: {fileID: 1102794499} inventoryController: {fileID: 2034939427} maxActiveModifierSlots: 5 @@ -802,7 +802,7 @@ GameObject: - component: {fileID: 1035691491} - component: {fileID: 1035691492} m_Layer: 0 - m_Name: GameController + m_Name: GamePresentationRoot m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -834,11 +834,10 @@ MonoBehaviour: m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 06752cfc00e8dc24f8004581af1a1933, type: 3} m_Name: - m_EditorClassIdentifier: YachtDice.Runtime::YachtDice.UI.GameController + m_EditorClassIdentifier: YachtDice.Runtime::YachtDice.UI.GamePresentationRoot scoreCardView: {fileID: 0} dicePanelView: {fileID: 0} gameInfoView: {fileID: 0} - maxRollsPerTurn: 3 --- !u!4 &1077005091 stripped Transform: m_CorrespondingSourceObject: {fileID: 6590077607741954368, guid: b59e9f48ded300a44bdf1f3f3a43e1ae, type: 3} @@ -1466,7 +1465,7 @@ GameObject: - component: {fileID: 2136136800} - component: {fileID: 2136136801} m_Layer: 0 - m_Name: GameManager + m_Name: GameLoopController m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -1498,7 +1497,7 @@ MonoBehaviour: m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 187be5e60b9cc014fbe755fbe18578be, type: 3} m_Name: - m_EditorClassIdentifier: YachtDice.Runtime::YachtDice.Game.GameManager + m_EditorClassIdentifier: YachtDice.Runtime::YachtDice.Game.GameLoopController maxRollsPerTurn: 3 --- !u!1001 &3765562131710099387 PrefabInstance: diff --git a/Assets/Scripts/DI/GameLifetimeScope.cs b/Assets/Scripts/DI/GameLifetimeScope.cs index 92351ab..791074a 100644 --- a/Assets/Scripts/DI/GameLifetimeScope.cs +++ b/Assets/Scripts/DI/GameLifetimeScope.cs @@ -29,9 +29,9 @@ namespace YachtDice.DI [Header("Scene References")] [SerializeField] private ScoringSystem scoringSystem; [SerializeField] private CurrencyBank currencyBank; - [SerializeField] private GameManager gameManager; + [SerializeField] private GameLoopController gameLoopController; [SerializeField] private DiceManager diceManager; - [SerializeField] private GameController gameController; + [SerializeField] private GamePresentationRoot gamePresentationRoot; [SerializeField] private ShopController shopController; [SerializeField] private InventoryController inventoryController; @@ -69,9 +69,9 @@ namespace YachtDice.DI // Scene MonoBehaviour components builder.RegisterComponent(scoringSystem); builder.RegisterComponent(currencyBank); - builder.RegisterComponent(gameManager); + builder.RegisterComponent(gameLoopController); builder.RegisterComponent(diceManager); - builder.RegisterComponent(gameController); + builder.RegisterComponent(gamePresentationRoot); builder.RegisterComponent(shopController); builder.RegisterComponent(inventoryController); } diff --git a/Assets/Scripts/Game/GameManager.cs b/Assets/Scripts/Game/GameLoopController.cs similarity index 75% rename from Assets/Scripts/Game/GameManager.cs rename to Assets/Scripts/Game/GameLoopController.cs index f5afacb..1118379 100644 --- a/Assets/Scripts/Game/GameManager.cs +++ b/Assets/Scripts/Game/GameLoopController.cs @@ -6,7 +6,7 @@ using YachtDice.Scoring; namespace YachtDice.Game { - public class GameManager : MonoBehaviour + public class GameLoopController : MonoBehaviour { [Header("Settings")] [SerializeField] private int maxRollsPerTurn = 3; @@ -47,7 +47,6 @@ namespace YachtDice.Game CurrentRoll = 0; _diceManager.UnlockAll(); OnTurnStarted?.Invoke(CurrentTurn); - Debug.Log($"=== Turn {CurrentTurn} ==="); } public void Roll() @@ -62,10 +61,6 @@ namespace YachtDice.Game private void HandleAllDiceSettled() { _diceManager.OnAllDiceSettled -= HandleAllDiceSettled; - - var values = _diceManager.GetCurrentValues(); - Debug.Log($"Roll {CurrentRoll}/{maxRollsPerTurn} | Dice: [{string.Join(", ", values)}]"); - OnRollComplete?.Invoke(CurrentRoll); } @@ -74,9 +69,6 @@ namespace YachtDice.Game if (_diceManager.IsAnyRolling) return; if (CurrentRoll == 0) return; _diceManager.ToggleLock(index); - - var isLocked = _diceManager.IsLocked(index); - Debug.Log($"Dice {index + 1} (value={_diceManager.GetValue(index)}): {(isLocked ? "LOCKED" : "UNLOCKED")}"); } public void ScoreInCategory(CategoryDefinition category) @@ -85,18 +77,13 @@ namespace YachtDice.Game if (_scoringSystem.IsCategoryUsed(category)) return; var dice = _diceManager.GetDice(); - ScoreResult result = _scoringSystem.ScoreCategory(dice, category); - - Debug.Log($"Scored {category.DisplayName}: base={result.baseScore}, " + - $"bonus=+{result.flatBonus}, mult=x{result.multiplier:F1}, " + - $"FINAL={result.FinalScore} | Total={_scoringSystem.TotalScore}"); + var result = _scoringSystem.ScoreCategory(dice, category); OnScored?.Invoke(category, result.FinalScore); if (_scoringSystem.IsComplete) { var total = _scoringSystem.TotalScore; - Debug.Log($"*** GAME OVER *** Total Score: {total}"); OnGameOver?.Invoke(total); } else diff --git a/Assets/Scripts/Game/GameLoopController.cs.meta b/Assets/Scripts/Game/GameLoopController.cs.meta new file mode 100644 index 0000000..cf8c000 --- /dev/null +++ b/Assets/Scripts/Game/GameLoopController.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 187be5e60b9cc014fbe755fbe18578be diff --git a/Assets/Scripts/Game/GameManager.cs.meta b/Assets/Scripts/Game/GameManager.cs.meta deleted file mode 100644 index 592ef49..0000000 --- a/Assets/Scripts/Game/GameManager.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 187be5e60b9cc014fbe755fbe18578be \ No newline at end of file diff --git a/Assets/Scripts/UI/GameController.cs.meta b/Assets/Scripts/UI/GameController.cs.meta deleted file mode 100644 index 0cb8b62..0000000 --- a/Assets/Scripts/UI/GameController.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 06752cfc00e8dc24f8004581af1a1933 \ No newline at end of file diff --git a/Assets/Scripts/UI/GameController.cs b/Assets/Scripts/UI/GamePresentationRoot.cs similarity index 91% rename from Assets/Scripts/UI/GameController.cs rename to Assets/Scripts/UI/GamePresentationRoot.cs index cf74b01..2fdb4c6 100644 --- a/Assets/Scripts/UI/GameController.cs +++ b/Assets/Scripts/UI/GamePresentationRoot.cs @@ -12,14 +12,14 @@ using YachtDice.UI.Presentation; namespace YachtDice.UI { - public class GameController : MonoBehaviour + public class GamePresentationRoot : MonoBehaviour { [Header("MVP Views")] [SerializeField] private ScoreCardView scoreCardView; [SerializeField] private DicePanelView dicePanelView; [SerializeField] private GameInfoView gameInfoView; - private GameManager _gameManager; + private GameLoopController _gameLoopController; private ScoringSystem _scoringSystem; private DiceManager _diceManager; private CurrencyBank _currencyBank; @@ -37,7 +37,7 @@ namespace YachtDice.UI [Inject] public void Construct( - GameManager gameManager, + GameLoopController gameLoopController, ScoringSystem scoringSystem, DiceManager diceManager, CurrencyBank currencyBank, @@ -48,7 +48,7 @@ namespace YachtDice.UI IGameSaveService saveService, IScoreSummaryService scoreSummaryService) { - this._gameManager = gameManager; + this._gameLoopController = gameLoopController; this._scoringSystem = scoringSystem; this._diceManager = diceManager; this._currencyBank = currencyBank; @@ -62,13 +62,12 @@ namespace YachtDice.UI private void Start() { - _dicePanelPresenter = new DicePanelPresenter(dicePanelView, _gameManager, _diceManager); + _dicePanelPresenter = new DicePanelPresenter(dicePanelView, _gameLoopController, _diceManager); _scoreCardPresenter = new ScoreCardPresenter(scoreCardView, _categoryCatalog, _scoringSystem, _diceManager); _gameInfoPresenter = new GameInfoPresenter(gameInfoView); _gameFlowPresenter = new GameFlowPresenter( - _gameManager, - _scoringSystem, + _gameLoopController, _diceManager, _currencyBank, _shopController, diff --git a/Assets/Scripts/UI/GamePresentationRoot.cs.meta b/Assets/Scripts/UI/GamePresentationRoot.cs.meta new file mode 100644 index 0000000..24d2479 --- /dev/null +++ b/Assets/Scripts/UI/GamePresentationRoot.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 06752cfc00e8dc24f8004581af1a1933 diff --git a/Assets/Scripts/UI/Presentation/DicePanelPresenter.cs b/Assets/Scripts/UI/Presentation/DicePanelPresenter.cs index c35232d..1446720 100644 --- a/Assets/Scripts/UI/Presentation/DicePanelPresenter.cs +++ b/Assets/Scripts/UI/Presentation/DicePanelPresenter.cs @@ -6,16 +6,16 @@ namespace YachtDice.UI.Presentation public sealed class DicePanelPresenter : IDisposable { private readonly DicePanelView _view; - private readonly GameManager _gameManager; + private readonly GameLoopController _gameLoopController; private readonly DiceManager _diceManager; public event Action RollClicked; public event Action DiceToggled; - public DicePanelPresenter(DicePanelView view, GameManager gameManager, DiceManager diceManager) + public DicePanelPresenter(DicePanelView view, GameLoopController gameLoopController, DiceManager diceManager) { _view = view; - _gameManager = gameManager; + _gameLoopController = gameLoopController; _diceManager = diceManager; } @@ -36,32 +36,32 @@ namespace YachtDice.UI.Presentation public void ResetForNewTurn() { _view.ResetForNewTurn(); - _view.SetRollButtonState(true, 0, _gameManager.MaxRollsPerTurn); + _view.SetRollButtonState(true, 0, _gameLoopController.MaxRollsPerTurn); } public void PrepareForRoll() { - _view.SetRollButtonState(false, _gameManager.CurrentRoll, _gameManager.MaxRollsPerTurn); + _view.SetRollButtonState(false, _gameLoopController.CurrentRoll, _gameLoopController.MaxRollsPerTurn); _view.SetDiceInteractable(false); } public void HandleRollComplete(int rollNumber) { - var canRollAgain = _gameManager.CanRoll; - _view.SetRollButtonState(canRollAgain, rollNumber, _gameManager.MaxRollsPerTurn); + var canRollAgain = _gameLoopController.CanRoll; + _view.SetRollButtonState(canRollAgain, rollNumber, _gameLoopController.MaxRollsPerTurn); _view.SetDiceInteractable(true); _view.SetAllDiceValues(_diceManager.GetCurrentValues()); } public void HandleGameOver() { - _view.SetRollButtonState(false, _gameManager.MaxRollsPerTurn, _gameManager.MaxRollsPerTurn); + _view.SetRollButtonState(false, _gameLoopController.MaxRollsPerTurn, _gameLoopController.MaxRollsPerTurn); _view.SetDiceInteractable(false); } public void ResetForNewGame() { - _view.ResetForNewGame(_gameManager.MaxRollsPerTurn); + _view.ResetForNewGame(_gameLoopController.MaxRollsPerTurn); } public void SetDiceLocked(int index, bool isLocked) diff --git a/Assets/Scripts/UI/Presentation/GameFlowPresenter.cs b/Assets/Scripts/UI/Presentation/GameFlowPresenter.cs index 456f623..2ea4fc3 100644 --- a/Assets/Scripts/UI/Presentation/GameFlowPresenter.cs +++ b/Assets/Scripts/UI/Presentation/GameFlowPresenter.cs @@ -4,15 +4,13 @@ using YachtDice.Economy; using YachtDice.Game; using YachtDice.Inventory; using YachtDice.Player; -using YachtDice.Scoring; using YachtDice.Shop; namespace YachtDice.UI.Presentation { public sealed class GameFlowPresenter : IDisposable { - private readonly GameManager _gameManager; - private readonly ScoringSystem _scoringSystem; + private readonly GameLoopController _gameLoopController; private readonly DiceManager _diceManager; private readonly CurrencyBank _currencyBank; private readonly ShopController _shopController; @@ -26,8 +24,7 @@ namespace YachtDice.UI.Presentation private readonly GameInfoPresenter _gameInfoPresenter; public GameFlowPresenter( - GameManager gameManager, - ScoringSystem scoringSystem, + GameLoopController gameLoopController, DiceManager diceManager, CurrencyBank currencyBank, ShopController shopController, @@ -40,8 +37,7 @@ namespace YachtDice.UI.Presentation ScoreCardPresenter scoreCardPresenter, GameInfoPresenter gameInfoPresenter) { - _gameManager = gameManager; - _scoringSystem = scoringSystem; + _gameLoopController = gameLoopController; _diceManager = diceManager; _currencyBank = currencyBank; _shopController = shopController; @@ -57,10 +53,10 @@ namespace YachtDice.UI.Presentation public void Initialize() { - _gameManager.OnTurnStarted += HandleTurnStarted; - _gameManager.OnRollComplete += HandleRollComplete; - _gameManager.OnScored += HandleScored; - _gameManager.OnGameOver += HandleGameOver; + _gameLoopController.OnTurnStarted += HandleTurnStarted; + _gameLoopController.OnRollComplete += HandleRollComplete; + _gameLoopController.OnScored += HandleScored; + _gameLoopController.OnGameOver += HandleGameOver; _dicePanelPresenter.RollClicked += HandleRollClicked; _dicePanelPresenter.DiceToggled += HandleDiceToggled; @@ -74,15 +70,15 @@ namespace YachtDice.UI.Presentation _saveService.Load(); _gameInfoPresenter.SetCurrencyText(_currencyBank.Balance); - _gameManager.StartNewGame(); + _gameLoopController.StartNewGame(); } public void Dispose() { - _gameManager.OnTurnStarted -= HandleTurnStarted; - _gameManager.OnRollComplete -= HandleRollComplete; - _gameManager.OnScored -= HandleScored; - _gameManager.OnGameOver -= HandleGameOver; + _gameLoopController.OnTurnStarted -= HandleTurnStarted; + _gameLoopController.OnRollComplete -= HandleRollComplete; + _gameLoopController.OnScored -= HandleScored; + _gameLoopController.OnGameOver -= HandleGameOver; _dicePanelPresenter.RollClicked -= HandleRollClicked; _dicePanelPresenter.DiceToggled -= HandleDiceToggled; @@ -127,35 +123,20 @@ namespace YachtDice.UI.Presentation private void HandleRollClicked() { - if (!_gameManager.CanRoll) - return; - _dicePanelPresenter.PrepareForRoll(); _scoreCardPresenter.SetAllInteractable(false); - _gameManager.Roll(); + _gameLoopController.Roll(); } private void HandleDiceToggled(int index) { - if (_gameManager.CurrentRoll == 0) - return; - - if (_diceManager.IsAnyRolling) - return; - - _gameManager.ToggleDiceLock(index); + _gameLoopController.ToggleDiceLock(index); _dicePanelPresenter.SetDiceLocked(index, _diceManager.IsLocked(index)); } private void HandleCategorySelected(CategoryDefinition category) { - if (!_gameManager.CanScore) - return; - - if (_scoringSystem.IsCategoryUsed(category)) - return; - - _gameManager.ScoreInCategory(category); + _gameLoopController.ScoreInCategory(category); } private void HandleNewGameClicked() @@ -163,7 +144,7 @@ namespace YachtDice.UI.Presentation _gameInfoPresenter.HideGameOver(); _scoreCardPresenter.ResetAll(); _dicePanelPresenter.ResetForNewGame(); - _gameManager.StartNewGame(); + _gameLoopController.StartNewGame(); } private void HandleShopClicked()