Implement pause functionality with UI and input bindings
This commit is contained in:
@@ -27,6 +27,7 @@ namespace Infrastructure.Unity
|
||||
[SerializeField] private TMP_Text scoreText;
|
||||
[SerializeField] private TMP_Text highScoreText;
|
||||
[SerializeField] private GameObject gameOverUi;
|
||||
[SerializeField] private GameObject pauseUi;
|
||||
[SerializeField] private GameObject startScreenUi;
|
||||
|
||||
[Header("Settings")]
|
||||
@@ -46,6 +47,7 @@ namespace Infrastructure.Unity
|
||||
private int _currentPlayerFloorIndex;
|
||||
private int _currentDisplayedScore;
|
||||
private float _inputBlockTimer;
|
||||
private bool _isPaused;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -105,6 +107,13 @@ namespace Infrastructure.Unity
|
||||
_inputBlockTimer -= Time.deltaTime;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_actions.Player.Pause.triggered && _isGameRunning)
|
||||
{
|
||||
TogglePause();
|
||||
}
|
||||
|
||||
if (_isPaused) return;
|
||||
|
||||
if (!_isGameRunning)
|
||||
{
|
||||
@@ -149,6 +158,26 @@ namespace Infrastructure.Unity
|
||||
}
|
||||
}
|
||||
|
||||
private void TogglePause()
|
||||
{
|
||||
_isPaused = !_isPaused;
|
||||
|
||||
if (_isPaused)
|
||||
{
|
||||
Time.timeScale = 0f;
|
||||
if (soundManager) soundManager.SetPaused(true);
|
||||
if (pauseUi) pauseUi.SetActive(true);
|
||||
if (rumbleManager) rumbleManager.SetPaused(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
if (soundManager) soundManager.SetPaused(false);
|
||||
if (pauseUi) pauseUi.SetActive(false);
|
||||
if (rumbleManager) rumbleManager.SetPaused(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnVisualOrb(string tileId)
|
||||
{
|
||||
if (_currentOrbInstance) Destroy(_currentOrbInstance);
|
||||
|
||||
Reference in New Issue
Block a user