Add focused word scale-down and smooth camera shake + unfocus words scribble

This commit is contained in:
2026-01-27 20:13:18 +01:00
parent d1b7104676
commit b64a57d810
16 changed files with 764 additions and 32 deletions
@@ -30,7 +30,7 @@ namespace Unheimlich.Managers
private readonly float _raycastInterval;
private readonly float _recoveryDuration;
private readonly float _focusRetentionTime;
private readonly float _shakeIntensity;
private readonly float _fallbackShakeIntensity;
private static readonly Vector3 ViewportCenter = new Vector3(0.5f, 0.5f, 0f);
@@ -46,7 +46,7 @@ namespace Unheimlich.Managers
float raycastInterval,
float recoveryDuration,
float focusRetentionTime,
float shakeIntensity)
float fallbackShakeIntensity)
{
_manager = manager;
_mainCamera = mainCamera;
@@ -57,7 +57,7 @@ namespace Unheimlich.Managers
_raycastInterval = raycastInterval;
_recoveryDuration = recoveryDuration;
_focusRetentionTime = focusRetentionTime;
_shakeIntensity = shakeIntensity;
_fallbackShakeIntensity = fallbackShakeIntensity;
}
/// <summary>
@@ -87,7 +87,9 @@ namespace Unheimlich.Managers
if (_isFocusLocked)
{
if (_retentionTimer > 0f)
_retentionTimer -= Time.deltaTime;
_retentionTimer -= Time.deltaTime;
else
_isFocusLocked = false;
return;
}
@@ -115,8 +117,8 @@ namespace Unheimlich.Managers
{
if (_currentFocusedHandler != null)
{
_isFocusLocked = true;
_currentFocusedHandler.ResetFeedback(_recoveryDuration);
_currentFocusedHandler.ResetFeedback(_recoveryDuration);
ResetAllUnfocusEffects();
}
_currentFocusedHandler = hitHandler;
@@ -126,6 +128,8 @@ namespace Unheimlich.Managers
if (_playerLook != null)
_playerLook.LockAim(true);
ApplyUnfocusEffectToOthers(hitHandler);
DialogueAnimationSettings settings = _manager.CurrentAnimationSettings;
bool shouldRotate = settings == null || settings.EnableRotation;
if (shouldRotate && _manager.CurrentDialogueUI != null)
@@ -149,18 +153,24 @@ namespace Unheimlich.Managers
_currentFocusedHandler.ApplyFocusFeedback(progress);
if (_playerLook != null)
_playerLook.Shake(progress / _shakeIntensity);
DialogueAnimationSettings currentSettings = _manager.CurrentAnimationSettings;
bool shouldShake = currentSettings == null || currentSettings.EnableCameraShakeOnFocus;
if (shouldShake && _playerLook != null)
{
float shakeIntensity = currentSettings != null ? currentSettings.CameraShakeIntensity : _fallbackShakeIntensity;
float shakeSmoothness = currentSettings != null ? currentSettings.CameraShakeSmoothness : 10f;
_playerLook.Shake(progress / shakeIntensity, shakeSmoothness);
}
if (_focusTimer >= _focusTime)
{
_isFocusLocked = true;
_currentFocusedHandler.ResetFeedback(_recoveryDuration);
ChoiceFocusHandler selectedHandler = _currentFocusedHandler;
if (_currentFocusedHandler.DialogueData != null)
if (selectedHandler.DialogueData != null)
{
OnChoiceMade?.Invoke(_currentFocusedHandler.DialogueData);
DialogueNode nextNode = _currentFocusedHandler.GetNextNode();
OnChoiceMade?.Invoke(selectedHandler.DialogueData);
DialogueNode nextNode = selectedHandler.GetNextNode();
_manager.GoToNextNode(nextNode);
}
@@ -173,6 +183,9 @@ namespace Unheimlich.Managers
}
ResetAnimationTimers();
ResetAllUnfocusEffects();
selectedHandler.ResetFeedback(_recoveryDuration);
if (_playerLook != null)
_playerLook.LockAim(false);
@@ -180,9 +193,8 @@ namespace Unheimlich.Managers
}
else if (_currentFocusedHandler != null && _retentionTimer <= 0f)
{
_isFocusLocked = true;
_currentFocusedHandler.ResetFeedback(_recoveryDuration);
_currentFocusedHandler.ResetFeedback(_recoveryDuration);
ResetAllUnfocusEffects();
DialogueAnimationSettings settings = _manager.CurrentAnimationSettings;
bool shouldRotate = settings == null || settings.EnableRotation;
@@ -198,6 +210,41 @@ namespace Unheimlich.Managers
_playerLook.LockAim(false);
}
}
private void ApplyUnfocusEffectToOthers(ChoiceFocusHandler focusedHandler)
{
if (_manager.CurrentDialogueUI == null || _manager.CurrentDialogueUI.ChoiceContainer == null)
return;
DialogueAnimationSettings settings = _manager.CurrentAnimationSettings;
float shakeSlowdown = settings != null ? settings.UnfocusedShakeSpeedMultiplier : 0.3f;
foreach (Transform child in _manager.CurrentDialogueUI.ChoiceContainer.transform)
{
ChoiceFocusHandler handler = child.GetComponent<ChoiceFocusHandler>();
if (handler != null && handler != focusedHandler)
{
handler.SetShakeSpeedMultiplier(shakeSlowdown);
handler.ApplySketchFade();
}
}
}
private void ResetAllUnfocusEffects()
{
if (_manager.CurrentDialogueUI == null || _manager.CurrentDialogueUI.ChoiceContainer == null)
return;
foreach (Transform child in _manager.CurrentDialogueUI.ChoiceContainer.transform)
{
ChoiceFocusHandler handler = child.GetComponent<ChoiceFocusHandler>();
if (handler != null)
{
handler.SetShakeSpeedMultiplier(1f);
handler.ResetSketchFade();
}
}
}
private void ResetAnimationTimers()
{