Refactor identifiers and add subtitle UI
This commit is contained in:
@@ -97,8 +97,8 @@ namespace BriarQueen.Game.Cinematics
|
||||
|
||||
private Sequence _skipTextSequence;
|
||||
|
||||
protected EventCoordinator EventCoordinator;
|
||||
protected InputManager InputManager;
|
||||
protected EventCoordinator _eventCoordinator;
|
||||
protected InputManager _inputManager;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
@@ -116,7 +116,7 @@ namespace BriarQueen.Game.Cinematics
|
||||
{
|
||||
if (!_isPlaying) return;
|
||||
if (!_allowKeyboardEscapeSkipFallback) return;
|
||||
if (InputManager != null) return;
|
||||
if (_inputManager != null) return;
|
||||
|
||||
var kb = Keyboard.current;
|
||||
if (kb != null && kb.escapeKey.wasPressedThisFrame)
|
||||
@@ -247,14 +247,14 @@ namespace BriarQueen.Game.Cinematics
|
||||
|
||||
protected virtual void BindSkipAction()
|
||||
{
|
||||
if (InputManager == null)
|
||||
if (_inputManager == null)
|
||||
return;
|
||||
|
||||
InputManager.BindPauseForSkip(OnSkipPerformed);
|
||||
_inputManager.BindPauseForSkip(OnSkipPerformed);
|
||||
|
||||
if (_skipText != null)
|
||||
{
|
||||
var inputType = InputManager.DeviceInputType;
|
||||
var inputType = _inputManager.DeviceInputType;
|
||||
switch (inputType)
|
||||
{
|
||||
case DeviceInputType.KeyboardAndMouse:
|
||||
@@ -278,10 +278,10 @@ namespace BriarQueen.Game.Cinematics
|
||||
|
||||
protected virtual void UnbindSkipAction()
|
||||
{
|
||||
if (InputManager == null)
|
||||
if (_inputManager == null)
|
||||
return;
|
||||
|
||||
InputManager.ResetPauseBind(OnSkipPerformed);
|
||||
_inputManager.ResetPauseBind(OnSkipPerformed);
|
||||
}
|
||||
|
||||
private void OnSkipPerformed(InputAction.CallbackContext _)
|
||||
@@ -535,7 +535,7 @@ namespace BriarQueen.Game.Cinematics
|
||||
{
|
||||
StopSkipTextTween();
|
||||
|
||||
if (EventCoordinator != null)
|
||||
if (_eventCoordinator != null)
|
||||
{
|
||||
if (_cinematicCanvasGroup != null)
|
||||
{
|
||||
@@ -544,7 +544,7 @@ namespace BriarQueen.Game.Cinematics
|
||||
_cinematicCanvasGroup.alpha = 1f;
|
||||
}
|
||||
|
||||
EventCoordinator.PublishImmediate(new FadeEvent(false, 1f));
|
||||
_eventCoordinator.PublishImmediate(new FadeEvent(false, 1f));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -679,8 +679,8 @@ namespace BriarQueen.Game.Cinematics
|
||||
[Inject]
|
||||
public void Construct(EventCoordinator eventCoordinator, InputManager inputManager)
|
||||
{
|
||||
EventCoordinator = eventCoordinator;
|
||||
InputManager = inputManager;
|
||||
_eventCoordinator = eventCoordinator;
|
||||
_inputManager = inputManager;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,12 +39,12 @@ namespace BriarQueen.Game.Items.HoverZones
|
||||
[SerializeField]
|
||||
private SFXKey _soundEffectOnClick;
|
||||
|
||||
protected EventCoordinator EventCoordinator;
|
||||
protected LevelManager LevelManager;
|
||||
protected SaveManager SaveManager;
|
||||
protected AudioManager AudioManager;
|
||||
protected EventCoordinator _eventCoordinator;
|
||||
protected LevelManager _levelManager;
|
||||
protected SaveManager _saveManager;
|
||||
protected AudioManager _audioManager;
|
||||
|
||||
protected TutorialService TutorialService;
|
||||
protected TutorialService _tutorialService;
|
||||
|
||||
public CanvasGroup CanvasGroup;
|
||||
|
||||
@@ -76,13 +76,13 @@ namespace BriarQueen.Game.Items.HoverZones
|
||||
var message = !string.IsNullOrEmpty(_lockedInteractText) ? _lockedInteractText
|
||||
: InteractEventIDs.Get(EnvironmentInteractKey.Locked);
|
||||
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(message));
|
||||
_eventCoordinator.Publish(new DisplayInteractEvent(message));
|
||||
return;
|
||||
}
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
_eventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -90,17 +90,17 @@ namespace BriarQueen.Game.Items.HoverZones
|
||||
|
||||
if (_soundEffectOnClick != SFXKey.None)
|
||||
{
|
||||
AudioManager.Play(AudioNameIdentifiers.Get(_soundEffectOnClick));
|
||||
_audioManager.Play(AudioNameIdentifiers.Get(_soundEffectOnClick));
|
||||
}
|
||||
|
||||
var loaded = await LevelManager.LoadLevel(levelId);
|
||||
var loaded = await _levelManager.LoadLevel(levelId);
|
||||
|
||||
if (!loaded)
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(EnvironmentInteractKey.CantGoThere)));
|
||||
_eventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(EnvironmentInteractKey.CantGoThere)));
|
||||
}
|
||||
|
||||
TutorialService.DisplayTutorial(TutorialPopupID.ReturnToPreviousLevel);
|
||||
_tutorialService.DisplayTutorial(TutorialPopupID.ReturnToPreviousLevel);
|
||||
}
|
||||
|
||||
public virtual UniTask EnterHover()
|
||||
@@ -127,11 +127,11 @@ namespace BriarQueen.Game.Items.HoverZones
|
||||
public void Construct(LevelManager levelManager, EventCoordinator eventCoordinator,
|
||||
SaveManager saveManager, AudioManager audioManager, TutorialService tutorialService)
|
||||
{
|
||||
LevelManager = levelManager;
|
||||
EventCoordinator = eventCoordinator;
|
||||
SaveManager = saveManager;
|
||||
AudioManager = audioManager;
|
||||
TutorialService = tutorialService;
|
||||
_levelManager = levelManager;
|
||||
_eventCoordinator = eventCoordinator;
|
||||
_saveManager = saveManager;
|
||||
_audioManager = audioManager;
|
||||
_tutorialService = tutorialService;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user