Refactor identifiers and add subtitle UI

This commit is contained in:
2026-05-17 11:56:08 +01:00
parent 3174079e37
commit 9f9ef72390
25 changed files with 276 additions and 6871 deletions

View File

@@ -16,6 +16,7 @@ using PrimeTween;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using VContainer;
@@ -29,8 +30,8 @@ namespace BriarQueen.Game.Puzzles.ChapterOne.AshwickHallow
public class AshwickGateKeypadPuzzle : BasePuzzle, IPuzzleStateful, IUIWindow, IUIBackHandler, IUIOverlayHost
{
private const string CorrectCode = "312";
private const int RequiredDigits = 3;
private const string CORRECT_CODE = "312";
private const int REQUIRED_DIGITS = 3;
[Header("Scene References")]
[SerializeField] private AshwickOutskirts _outskirts;
@@ -50,7 +51,7 @@ namespace BriarQueen.Game.Puzzles.ChapterOne.AshwickHallow
[SerializeField] private TweenSettings _panelFadeTweenSettings = new()
{
duration = 1.5f,
duration = 0.8f,
ease = Ease.OutQuad,
useUnscaledTime = true
};
@@ -71,7 +72,7 @@ namespace BriarQueen.Game.Puzzles.ChapterOne.AshwickHallow
private TutorialService _tutorialService;
private UIManager _uiManager;
public override string PuzzleID => PuzzleIdentifiers.AllPuzzles[PuzzleKey.AshwickMarketGate];
public override string PuzzleID => PuzzleIdentifiers.Get(PuzzleKey.AshwickOutskirtsGate);
public bool IsCompleted => _isCompleted || SaveManager.GetLevelFlag(LevelFlag.AshwickGateOpen);
public WindowType WindowType => WindowType.AshwickGateKeypadWindow;
public UIPauseBehavior PauseBehavior => UIPauseBehavior.OpenPauseOverlay;
@@ -161,11 +162,12 @@ namespace BriarQueen.Game.Puzzles.ChapterOne.AshwickHallow
var restored = MemoryPackSerializer.Deserialize<AshwickGateKeypadPuzzleState>(state);
_currentDigits = restored?.Digits ?? string.Empty;
if (_currentDigits.Length > RequiredDigits)
_currentDigits = _currentDigits[..RequiredDigits];
if (_currentDigits.Length > REQUIRED_DIGITS)
_currentDigits = _currentDigits[..REQUIRED_DIGITS];
}
SyncDisplay();
ResetFeedbackState();
return UniTask.CompletedTask;
}
@@ -178,7 +180,7 @@ namespace BriarQueen.Game.Puzzles.ChapterOne.AshwickHallow
_currentDigits = string.Empty;
SyncDisplay();
SaveManager.SetPuzzleCompleted(PuzzleKey.AshwickMarketGate, true, requestSave: false);
SaveManager.SetPuzzleCompleted(PuzzleKey.AshwickOutskirtsGate, true, requestSave: false);
_skipSaveOnHide = true;
_uiManager?.CloseWindow(WindowType);
AudioManager.Play(AudioNameIdentifiers.Get(SFXKey.AshwickGateOpening));
@@ -195,6 +197,7 @@ namespace BriarQueen.Game.Puzzles.ChapterOne.AshwickHallow
SetPanelState(0f, false, true);
SyncDisplay();
ResetFeedbackState();
EnsureExclusiveRaycaster();
try
@@ -229,6 +232,7 @@ namespace BriarQueen.Game.Puzzles.ChapterOne.AshwickHallow
_isOpen = false;
ResetPanelTween();
ResetFeedbackState();
if (_panelGroup != null)
{
@@ -349,13 +353,16 @@ namespace BriarQueen.Game.Puzzles.ChapterOne.AshwickHallow
private void OnDigitPressed(int digit)
{
if (_isEvaluating || IsCompleted || !_isOpen || _currentDigits.Length >= RequiredDigits)
if (_isEvaluating || IsCompleted || !_isOpen || _currentDigits.Length >= REQUIRED_DIGITS)
return;
if (_currentDigits.Length == 0)
ResetFeedbackState();
_currentDigits += digit.ToString();
SyncDisplay();
if (_currentDigits.Length == RequiredDigits)
if (_currentDigits.Length == REQUIRED_DIGITS)
EvaluateCode().Forget();
}
@@ -366,7 +373,7 @@ namespace BriarQueen.Game.Puzzles.ChapterOne.AshwickHallow
if (_panelGroup != null)
_panelGroup.interactable = false;
if (_currentDigits == CorrectCode)
if (_currentDigits == CORRECT_CODE)
{
if (_statusGlow != null)
{
@@ -438,6 +445,21 @@ namespace BriarQueen.Game.Puzzles.ChapterOne.AshwickHallow
_displayField.text = _currentDigits;
}
private void ResetFeedbackState()
{
_statusGlow?.TurnOff().Forget();
ResetCloseButtonSelection();
}
private void ResetCloseButtonSelection()
{
if (_closeButton == null || EventSystem.current == null)
return;
if (EventSystem.current.currentSelectedGameObject == _closeButton.gameObject)
EventSystem.current.SetSelectedGameObject(null);
}
private void SetPanelState(float alpha, bool interactable, bool blocksRaycasts)
{
if (_panelGroup == null)