First commit for private source control. Older commits available on Github.
This commit is contained in:
26
Assets/Scripts/Game/BriarQueen.Game.asmdef
Normal file
26
Assets/Scripts/Game/BriarQueen.Game.asmdef
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "BriarQueen.Game",
|
||||
"rootNamespace": "BriarQueen",
|
||||
"references": [
|
||||
"GUID:ac1be664c635c449eb9f3f52cf5c97f5",
|
||||
"GUID:776d03a35f1b52c4a9aed9f56d7b4229",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23",
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||
"GUID:80ecb87cae9c44d19824e70ea7229748",
|
||||
"GUID:75469ad4d38634e559750d17036d5f7c",
|
||||
"GUID:84651a3751eca9349aac36a66bba901b",
|
||||
"GUID:bdf0eff65032c4178bf18aa9c96b1c70",
|
||||
"GUID:9e24947de15b9834991c9d8411ea37cf",
|
||||
"GUID:d525ad6bd40672747bde77962f1c401e"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Assets/Scripts/Game/BriarQueen.Game.asmdef.meta
Normal file
7
Assets/Scripts/Game/BriarQueen.Game.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08d167124de9a43559a6f77e28228b15
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
3
Assets/Scripts/Game/Cinematics.meta
Normal file
3
Assets/Scripts/Game/Cinematics.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8a17e4ab74f4af68e30f42f41ddbc27
|
||||
timeCreated: 1769970270
|
||||
685
Assets/Scripts/Game/Cinematics/BaseCinematic.cs
Normal file
685
Assets/Scripts/Game/Cinematics/BaseCinematic.cs
Normal file
@@ -0,0 +1,685 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using BriarQueen.Framework.Coordinators.Events;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Input;
|
||||
using BriarQueen.Game.Cinematics.Data;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using PrimeTween;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UI;
|
||||
using VContainer;
|
||||
|
||||
namespace BriarQueen.Game.Cinematics
|
||||
{
|
||||
public abstract class BaseCinematic : MonoBehaviour
|
||||
{
|
||||
[Header("Cinematic Settings")]
|
||||
[SerializeField]
|
||||
protected List<CinematicPanel> _cinematicPanels = new();
|
||||
|
||||
[Header("Crossfade Settings")]
|
||||
[Tooltip("Max crossfade duration. Actual fade is clamped so EACH panel still lasts exactly DisplayTime.")]
|
||||
[SerializeField]
|
||||
[Min(0f)]
|
||||
protected float _maxCrossfadeDuration = 0.75f;
|
||||
|
||||
[Header("Subtitles")]
|
||||
[SerializeField]
|
||||
protected bool _logSubtitleTimingWarnings = true;
|
||||
|
||||
[Tooltip("If true, clears subtitle text when a panel ends (recommended for VO sync).")]
|
||||
[SerializeField]
|
||||
protected bool _clearSubtitlesBetweenPanels = true;
|
||||
|
||||
[Header("UI Elements")]
|
||||
[SerializeField]
|
||||
protected CanvasGroup _cinematicCanvasGroup;
|
||||
|
||||
[SerializeField]
|
||||
protected TextMeshProUGUI _cinematicText;
|
||||
|
||||
[SerializeField]
|
||||
protected TextMeshProUGUI _skipText;
|
||||
|
||||
[Header("Cinematic Images (Two Layers For Crossfade)")]
|
||||
[SerializeField]
|
||||
protected Image _imageA;
|
||||
|
||||
[SerializeField]
|
||||
protected Image _imageB;
|
||||
|
||||
[Header("Input")]
|
||||
[SerializeField]
|
||||
protected string _skipActionName = "Cancel";
|
||||
|
||||
[Header("Tween Settings")]
|
||||
[SerializeField]
|
||||
protected float _canvasFadeInDuration = 0.25f;
|
||||
|
||||
[SerializeField]
|
||||
protected float _canvasFadeOutDuration = 0.25f;
|
||||
|
||||
[SerializeField]
|
||||
protected float _finalImageFadeOutDuration = 0.25f;
|
||||
|
||||
[Header("Skip Text Tween (Yoyo Alpha)")]
|
||||
[SerializeField]
|
||||
protected bool _animateSkipText = true;
|
||||
|
||||
[SerializeField]
|
||||
[Min(0.05f)]
|
||||
protected float _skipTextHalfCycleSeconds = 0.75f;
|
||||
|
||||
[SerializeField]
|
||||
[Range(0f, 1f)]
|
||||
protected float _skipTextMinAlpha = 0.25f;
|
||||
|
||||
[SerializeField]
|
||||
[Range(0f, 1f)]
|
||||
protected float _skipTextMaxAlpha = 1f;
|
||||
|
||||
[SerializeField]
|
||||
protected Ease _skipTextEase = Ease.InOutSine;
|
||||
|
||||
[Header("Test/Debug (No Injection Needed)")]
|
||||
[Tooltip("If true, Escape will skip even when InputManager isn't injected (handy for editor tests).")]
|
||||
[SerializeField]
|
||||
private bool _allowKeyboardEscapeSkipFallback = true;
|
||||
|
||||
private CancellationTokenSource _cinematicCts;
|
||||
private bool _endingStarted;
|
||||
private bool _isPlaying;
|
||||
private bool _skipRequested;
|
||||
|
||||
private Sequence _skipTextSequence;
|
||||
|
||||
protected EventCoordinator EventCoordinator;
|
||||
protected InputManager InputManager;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
if (_cinematicCanvasGroup != null)
|
||||
_cinematicCanvasGroup.alpha = 0f;
|
||||
|
||||
SetImageAlpha(_imageA, 0f);
|
||||
SetImageAlpha(_imageB, 0f);
|
||||
|
||||
ClearSubtitleText();
|
||||
StopSkipTextTween();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!_isPlaying) return;
|
||||
if (!_allowKeyboardEscapeSkipFallback) return;
|
||||
if (InputManager != null) return;
|
||||
|
||||
var kb = Keyboard.current;
|
||||
if (kb != null && kb.escapeKey.wasPressedThisFrame)
|
||||
RequestSkip();
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
BindSkipAction();
|
||||
}
|
||||
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
UnbindSkipAction();
|
||||
CancelAndDisposeCts();
|
||||
StopSkipTextTween();
|
||||
_isPlaying = false;
|
||||
}
|
||||
|
||||
protected virtual void OnDestroy()
|
||||
{
|
||||
UnbindSkipAction();
|
||||
CancelAndDisposeCts();
|
||||
StopSkipTextTween();
|
||||
}
|
||||
|
||||
protected async UniTask PlayCinematic(CancellationToken destroyToken)
|
||||
{
|
||||
if (_cinematicCanvasGroup == null || _imageA == null || _imageB == null)
|
||||
{
|
||||
Debug.LogWarning("[BaseCinematic] Missing CanvasGroup or Images.");
|
||||
return;
|
||||
}
|
||||
|
||||
_isPlaying = true;
|
||||
|
||||
if (_cinematicPanels == null || _cinematicPanels.Count == 0)
|
||||
{
|
||||
await EndCinematicFlow();
|
||||
return;
|
||||
}
|
||||
|
||||
CancelAndDisposeCts();
|
||||
_cinematicCts = CancellationTokenSource.CreateLinkedTokenSource(destroyToken);
|
||||
var playbackToken = _cinematicCts.Token;
|
||||
|
||||
_skipRequested = false;
|
||||
_endingStarted = false;
|
||||
|
||||
_cinematicCanvasGroup.blocksRaycasts = false;
|
||||
_cinematicCanvasGroup.interactable = false;
|
||||
_cinematicCanvasGroup.alpha = 0f;
|
||||
|
||||
ClearSubtitleText();
|
||||
SetImageAlpha(_imageA, 0f);
|
||||
SetImageAlpha(_imageB, 0f);
|
||||
|
||||
StartSkipTextTweenIfNeeded();
|
||||
|
||||
await FadeCanvasGroup(_cinematicCanvasGroup, 0f, 1f, _canvasFadeInDuration, destroyToken);
|
||||
|
||||
_cinematicCanvasGroup.blocksRaycasts = true;
|
||||
_cinematicCanvasGroup.interactable = true;
|
||||
|
||||
try
|
||||
{
|
||||
for (var i = 0; i < _cinematicPanels.Count; i++)
|
||||
{
|
||||
if (_skipRequested)
|
||||
break;
|
||||
|
||||
var panel = GetPanel(i);
|
||||
if (panel == null || panel.CinematicImage == null)
|
||||
continue;
|
||||
|
||||
var currentTime = Mathf.Max(0f, panel.DisplayTime);
|
||||
var nextTime = i + 1 < _cinematicPanels.Count
|
||||
? Mathf.Max(0f, GetPanel(i + 1)?.DisplayTime ?? 0f)
|
||||
: 0f;
|
||||
|
||||
var isFirst = i == 0;
|
||||
var isLast = i == _cinematicPanels.Count - 1;
|
||||
|
||||
await RunPanelWithSubtitles(i, currentTime, nextTime, isFirst, isLast, playbackToken);
|
||||
|
||||
if (_clearSubtitlesBetweenPanels && !isLast)
|
||||
ClearSubtitleText();
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
|
||||
var safeExitToken = this.GetCancellationTokenOnDestroy();
|
||||
|
||||
await FadeOutAtEnd(safeExitToken);
|
||||
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(2f), DelayType.UnscaledDeltaTime,
|
||||
cancellationToken: safeExitToken);
|
||||
|
||||
await EndCinematicFlow();
|
||||
}
|
||||
|
||||
protected virtual UniTask OnCinematicEnd()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
protected void RequestSkip()
|
||||
{
|
||||
Debug.Log("Skip Requested");
|
||||
|
||||
if (_skipRequested || _endingStarted)
|
||||
return;
|
||||
|
||||
_skipRequested = true;
|
||||
|
||||
if (_cinematicCts != null && !_cinematicCts.IsCancellationRequested)
|
||||
try
|
||||
{
|
||||
_cinematicCts.Cancel();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void BindSkipAction()
|
||||
{
|
||||
if (InputManager == null)
|
||||
return;
|
||||
|
||||
InputManager.BindPauseForSkip(OnSkipPerformed);
|
||||
|
||||
if (_skipText != null)
|
||||
{
|
||||
var inputType = InputManager.DeviceInputType;
|
||||
switch (inputType)
|
||||
{
|
||||
case DeviceInputType.KeyboardAndMouse:
|
||||
_skipText.text = "Press Escape to Skip.";
|
||||
break;
|
||||
case DeviceInputType.XboxController:
|
||||
_skipText.text = "Press B to Skip.";
|
||||
break;
|
||||
case DeviceInputType.PlaystationController:
|
||||
_skipText.text = "Press Circle to Skip.";
|
||||
break;
|
||||
case DeviceInputType.SwitchProController:
|
||||
_skipText.text = "Press B to Skip.";
|
||||
break;
|
||||
default:
|
||||
_skipText.text = "Press Cancel to Skip.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void UnbindSkipAction()
|
||||
{
|
||||
if (InputManager == null)
|
||||
return;
|
||||
|
||||
InputManager.ResetPauseBind(OnSkipPerformed);
|
||||
}
|
||||
|
||||
private void OnSkipPerformed(InputAction.CallbackContext _)
|
||||
{
|
||||
RequestSkip();
|
||||
}
|
||||
|
||||
private void CancelAndDisposeCts()
|
||||
{
|
||||
if (_cinematicCts == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
_cinematicCts.Cancel();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
_cinematicCts.Dispose();
|
||||
_cinematicCts = null;
|
||||
}
|
||||
|
||||
private async UniTask EndCinematicFlow()
|
||||
{
|
||||
if (_endingStarted)
|
||||
return;
|
||||
|
||||
_endingStarted = true;
|
||||
_isPlaying = false;
|
||||
|
||||
StopSkipTextTween();
|
||||
ClearSubtitleText();
|
||||
|
||||
await OnCinematicEnd();
|
||||
}
|
||||
|
||||
private void StartSkipTextTweenIfNeeded()
|
||||
{
|
||||
if (!_animateSkipText || _skipText == null)
|
||||
return;
|
||||
|
||||
StopSkipTextTween();
|
||||
|
||||
var c = _skipText.color;
|
||||
c.a = Mathf.Clamp01(_skipTextMaxAlpha);
|
||||
_skipText.color = c;
|
||||
|
||||
_skipTextSequence = Sequence.Create(
|
||||
useUnscaledTime: true,
|
||||
cycleMode: Sequence.SequenceCycleMode.Yoyo,
|
||||
cycles: -1
|
||||
)
|
||||
.Group(Tween.Alpha(_skipText, new TweenSettings<float>
|
||||
{
|
||||
startValue = _skipTextMaxAlpha,
|
||||
endValue = _skipTextMinAlpha,
|
||||
settings = new TweenSettings
|
||||
{
|
||||
duration = _skipTextHalfCycleSeconds,
|
||||
ease = _skipTextEase,
|
||||
useUnscaledTime = true
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void StopSkipTextTween()
|
||||
{
|
||||
if (_skipTextSequence.isAlive)
|
||||
_skipTextSequence.Stop();
|
||||
|
||||
_skipTextSequence = default;
|
||||
}
|
||||
|
||||
private CinematicPanel GetPanel(int index)
|
||||
{
|
||||
if (_cinematicPanels == null) return null;
|
||||
if (index < 0 || index >= _cinematicPanels.Count) return null;
|
||||
return _cinematicPanels[index];
|
||||
}
|
||||
|
||||
private async UniTask RunPanelWithSubtitles(int panelIndex, float currentTime, float nextTime, bool isFirst,
|
||||
bool isLast, CancellationToken token)
|
||||
{
|
||||
using var panelCts = CancellationTokenSource.CreateLinkedTokenSource(token);
|
||||
var panelToken = panelCts.Token;
|
||||
|
||||
await UniTask.WhenAll(
|
||||
ShowPanelExact(panelIndex, currentTime, nextTime, isFirst, isLast, panelToken),
|
||||
RunSubtitlesForPanel(panelIndex, currentTime, panelToken)
|
||||
);
|
||||
}
|
||||
|
||||
private async UniTask RunSubtitlesForPanel(int panelIndex, float panelTime, CancellationToken token)
|
||||
{
|
||||
if (_cinematicText == null)
|
||||
return;
|
||||
|
||||
var panel = GetPanel(panelIndex);
|
||||
if (panel == null)
|
||||
return;
|
||||
|
||||
var subs = panel.Subtitles;
|
||||
if (subs == null || subs.Count == 0)
|
||||
{
|
||||
ClearSubtitleText();
|
||||
if (panelTime > 0f)
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(panelTime), DelayType.UnscaledDeltaTime,
|
||||
cancellationToken: token);
|
||||
return;
|
||||
}
|
||||
|
||||
var sum = 0f;
|
||||
for (var i = 0; i < subs.Count; i++)
|
||||
{
|
||||
if (subs[i].Equals(default))
|
||||
continue;
|
||||
|
||||
sum += Mathf.Max(0f, subs[i].DisplayTime);
|
||||
}
|
||||
|
||||
if (_logSubtitleTimingWarnings && sum > panelTime + 0.001f)
|
||||
Debug.LogWarning(
|
||||
$"[BaseCinematic] Panel '{panel.name}' subtitle times sum to {sum:0.###}s but panel DisplayTime is {panelTime:0.###}s. Subtitles will be cut short.");
|
||||
|
||||
var remaining = panelTime;
|
||||
|
||||
for (var i = 0; i < subs.Count; i++)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
var sub = subs[i];
|
||||
if (sub.Equals(default))
|
||||
continue;
|
||||
|
||||
var subTime = Mathf.Max(0f, sub.DisplayTime);
|
||||
if (subTime <= 0f)
|
||||
continue;
|
||||
|
||||
var actual = Mathf.Min(subTime, remaining);
|
||||
if (actual <= 0f)
|
||||
break;
|
||||
|
||||
_cinematicText.text = sub.Subtitle ?? string.Empty;
|
||||
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(actual), DelayType.UnscaledDeltaTime,
|
||||
cancellationToken: token);
|
||||
|
||||
remaining -= actual;
|
||||
if (remaining <= 0f)
|
||||
break;
|
||||
}
|
||||
|
||||
if (remaining > 0f)
|
||||
{
|
||||
_cinematicText.text = string.Empty;
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(remaining), DelayType.UnscaledDeltaTime,
|
||||
cancellationToken: token);
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearSubtitleText()
|
||||
{
|
||||
if (_cinematicText != null)
|
||||
_cinematicText.text = string.Empty;
|
||||
}
|
||||
|
||||
private async UniTask ShowPanelExact(int panelIndex, float currentTime, float nextTime, bool isFirst,
|
||||
bool isLast, CancellationToken token)
|
||||
{
|
||||
var panel = GetPanel(panelIndex);
|
||||
if (panel == null || panel.CinematicImage == null)
|
||||
return;
|
||||
|
||||
var boundaryFade = 0f;
|
||||
if (!isLast)
|
||||
boundaryFade = Mathf.Min(_maxCrossfadeDuration, currentTime, nextTime);
|
||||
|
||||
var introFade = 0f;
|
||||
|
||||
if (isFirst)
|
||||
{
|
||||
introFade = isLast
|
||||
? Mathf.Min(_maxCrossfadeDuration, currentTime)
|
||||
: Mathf.Min(_maxCrossfadeDuration, currentTime, nextTime);
|
||||
|
||||
_imageA.sprite = panel.CinematicImage;
|
||||
|
||||
SetImageAlpha(_imageA, 0f);
|
||||
SetImageAlpha(_imageB, 0f);
|
||||
|
||||
if (introFade > 0f)
|
||||
await FadeImage(_imageA, 0f, 1f, introFade, token);
|
||||
else
|
||||
SetImageAlpha(_imageA, 1f);
|
||||
|
||||
var hold = Mathf.Max(0f, currentTime - introFade - boundaryFade);
|
||||
if (hold > 0f)
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(hold), DelayType.UnscaledDeltaTime,
|
||||
cancellationToken: token);
|
||||
|
||||
if (!isLast && boundaryFade > 0f)
|
||||
await CrossfadeToNext(panelIndex + 1, boundaryFade, token);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var holdTime = Mathf.Max(0f, currentTime - boundaryFade);
|
||||
if (holdTime > 0f)
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(holdTime), DelayType.UnscaledDeltaTime,
|
||||
cancellationToken: token);
|
||||
|
||||
if (!isLast && boundaryFade > 0f)
|
||||
await CrossfadeToNext(panelIndex + 1, boundaryFade, token);
|
||||
}
|
||||
|
||||
private async UniTask CrossfadeToNext(int nextPanelIndex, float duration, CancellationToken token)
|
||||
{
|
||||
var nextPanel = GetPanel(nextPanelIndex);
|
||||
if (nextPanel == null || nextPanel.CinematicImage == null)
|
||||
return;
|
||||
|
||||
var current = GetMoreVisible(_imageA, _imageB);
|
||||
var next = current == _imageA ? _imageB : _imageA;
|
||||
|
||||
next.sprite = nextPanel.CinematicImage;
|
||||
|
||||
var currentAlpha = GetImageAlpha(current);
|
||||
|
||||
SetImageAlpha(next, 0f);
|
||||
|
||||
var seq = Sequence.Create(useUnscaledTime: true)
|
||||
.Group(Tween.Alpha(current, new TweenSettings<float>
|
||||
{
|
||||
startValue = currentAlpha,
|
||||
endValue = 0f,
|
||||
settings = new TweenSettings { duration = duration, ease = Ease.Linear, useUnscaledTime = true }
|
||||
}))
|
||||
.Group(Tween.Alpha(next, new TweenSettings<float>
|
||||
{
|
||||
startValue = 0f,
|
||||
endValue = 1f,
|
||||
settings = new TweenSettings { duration = duration, ease = Ease.Linear, useUnscaledTime = true }
|
||||
}));
|
||||
|
||||
await seq.ToUniTask(cancellationToken: token);
|
||||
}
|
||||
|
||||
private async UniTask FadeOutAtEnd(CancellationToken token)
|
||||
{
|
||||
StopSkipTextTween();
|
||||
|
||||
if (EventCoordinator != null)
|
||||
{
|
||||
if (_cinematicCanvasGroup != null)
|
||||
{
|
||||
_cinematicCanvasGroup.blocksRaycasts = false;
|
||||
_cinematicCanvasGroup.interactable = false;
|
||||
_cinematicCanvasGroup.alpha = 1f;
|
||||
}
|
||||
|
||||
EventCoordinator.PublishImmediate(new FadeEvent(false, 1f));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var img = GetMoreVisible(_imageA, _imageB);
|
||||
var imgFrom = GetImageAlpha(img);
|
||||
|
||||
if ((_cinematicCanvasGroup == null || _cinematicCanvasGroup.alpha <= 0.001f) && imgFrom <= 0.001f)
|
||||
return;
|
||||
|
||||
var canvasFrom = _cinematicCanvasGroup != null ? _cinematicCanvasGroup.alpha : 0f;
|
||||
|
||||
var imgDur = Mathf.Max(0f, _finalImageFadeOutDuration);
|
||||
var canvasDur = Mathf.Max(0f, _canvasFadeOutDuration);
|
||||
|
||||
var seq = Sequence.Create(useUnscaledTime: true);
|
||||
|
||||
if (img != null && imgDur > 0f && imgFrom > 0.001f)
|
||||
seq.Group(Tween.Alpha(img, new TweenSettings<float>
|
||||
{
|
||||
startValue = imgFrom,
|
||||
endValue = 0f,
|
||||
settings = new TweenSettings { duration = imgDur, ease = Ease.OutQuad, useUnscaledTime = true }
|
||||
}));
|
||||
else if (img != null) SetImageAlpha(img, 0f);
|
||||
|
||||
if (_cinematicCanvasGroup != null && canvasDur > 0f && canvasFrom > 0.001f)
|
||||
{
|
||||
_cinematicCanvasGroup.blocksRaycasts = false;
|
||||
_cinematicCanvasGroup.interactable = false;
|
||||
|
||||
seq.Group(Tween.Alpha(_cinematicCanvasGroup, new TweenSettings<float>
|
||||
{
|
||||
startValue = canvasFrom,
|
||||
endValue = 0f,
|
||||
settings = new TweenSettings { duration = canvasDur, ease = Ease.OutQuad, useUnscaledTime = true }
|
||||
}));
|
||||
}
|
||||
else if (_cinematicCanvasGroup != null)
|
||||
{
|
||||
_cinematicCanvasGroup.alpha = 0f;
|
||||
_cinematicCanvasGroup.blocksRaycasts = false;
|
||||
_cinematicCanvasGroup.interactable = false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (seq.isAlive)
|
||||
await seq.ToUniTask(cancellationToken: token);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
if (img != null) SetImageAlpha(img, 0f);
|
||||
if (_cinematicCanvasGroup != null) _cinematicCanvasGroup.alpha = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
private static async UniTask FadeCanvasGroup(CanvasGroup group, float from, float to, float duration,
|
||||
CancellationToken token)
|
||||
{
|
||||
if (group == null)
|
||||
return;
|
||||
|
||||
if (duration <= 0f)
|
||||
{
|
||||
group.alpha = to;
|
||||
return;
|
||||
}
|
||||
|
||||
group.alpha = from;
|
||||
|
||||
var seq = Sequence.Create(useUnscaledTime: true)
|
||||
.Group(Tween.Alpha(group, new TweenSettings<float>
|
||||
{
|
||||
startValue = from,
|
||||
endValue = to,
|
||||
settings = new TweenSettings { duration = duration, ease = Ease.OutQuad, useUnscaledTime = true }
|
||||
}));
|
||||
|
||||
await seq.ToUniTask(cancellationToken: token);
|
||||
}
|
||||
|
||||
private static async UniTask FadeImage(Image image, float from, float to, float duration,
|
||||
CancellationToken token)
|
||||
{
|
||||
if (image == null)
|
||||
return;
|
||||
|
||||
if (duration <= 0f)
|
||||
{
|
||||
SetImageAlpha(image, to);
|
||||
return;
|
||||
}
|
||||
|
||||
SetImageAlpha(image, from);
|
||||
|
||||
var seq = Sequence.Create(useUnscaledTime: true)
|
||||
.Group(Tween.Alpha(image, new TweenSettings<float>
|
||||
{
|
||||
startValue = from,
|
||||
endValue = to,
|
||||
settings = new TweenSettings { duration = duration, ease = Ease.OutQuad, useUnscaledTime = true }
|
||||
}));
|
||||
|
||||
await seq.ToUniTask(cancellationToken: token);
|
||||
}
|
||||
|
||||
private static float GetImageAlpha(Image image)
|
||||
{
|
||||
if (image == null)
|
||||
return 0f;
|
||||
return image.color.a;
|
||||
}
|
||||
|
||||
private static void SetImageAlpha(Image image, float alpha)
|
||||
{
|
||||
if (image == null)
|
||||
return;
|
||||
|
||||
var c = image.color;
|
||||
c.a = Mathf.Clamp01(alpha);
|
||||
image.color = c;
|
||||
}
|
||||
|
||||
private static Image GetMoreVisible(Image a, Image b)
|
||||
{
|
||||
var aa = GetImageAlpha(a);
|
||||
var bb = GetImageAlpha(b);
|
||||
return aa >= bb ? a : b;
|
||||
}
|
||||
|
||||
[Inject]
|
||||
public void Construct(EventCoordinator eventCoordinator, InputManager inputManager)
|
||||
{
|
||||
EventCoordinator = eventCoordinator;
|
||||
InputManager = inputManager;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Game/Cinematics/BaseCinematic.cs.meta
Normal file
3
Assets/Scripts/Game/Cinematics/BaseCinematic.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28c2bf5f2cf04ab7ac3c1613e6164f9b
|
||||
timeCreated: 1770666923
|
||||
3
Assets/Scripts/Game/Cinematics/Data.meta
Normal file
3
Assets/Scripts/Game/Cinematics/Data.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ec5cb96d11346c6b66b58e2c33d6539
|
||||
timeCreated: 1773830225
|
||||
18
Assets/Scripts/Game/Cinematics/Data/CinematicPanel.cs
Normal file
18
Assets/Scripts/Game/Cinematics/Data/CinematicPanel.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using BriarQueen.Framework.Managers.Audio.Data;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Game.Cinematics.Data
|
||||
{
|
||||
[CreateAssetMenu(menuName = "Briar Queen/Cinematics/New Cinematic Panel", fileName = "New Cinematic Panel")]
|
||||
public class CinematicPanel : ScriptableObject
|
||||
{
|
||||
public Sprite CinematicImage;
|
||||
public float DisplayTime = 3f;
|
||||
public AudioFileSo AudioFile;
|
||||
|
||||
[ReorderableList]
|
||||
public List<CinematicSubtitle> Subtitles;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ce2fc8cc1f54667a902fed5e8df23c4
|
||||
timeCreated: 1769970619
|
||||
11
Assets/Scripts/Game/Cinematics/Data/CinematicSubtitle.cs
Normal file
11
Assets/Scripts/Game/Cinematics/Data/CinematicSubtitle.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace BriarQueen.Game.Cinematics.Data
|
||||
{
|
||||
[Serializable]
|
||||
public struct CinematicSubtitle
|
||||
{
|
||||
public string Subtitle;
|
||||
public float DisplayTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f5c998a34174e81a18833d43fd32548
|
||||
timeCreated: 1769978310
|
||||
115
Assets/Scripts/Game/Cinematics/OpeningCinematic.cs
Normal file
115
Assets/Scripts/Game/Cinematics/OpeningCinematic.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Assets;
|
||||
using BriarQueen.Framework.Coordinators.Events;
|
||||
using BriarQueen.Framework.Managers.Input;
|
||||
using BriarQueen.Framework.Managers.IO;
|
||||
using BriarQueen.Framework.Managers.Levels;
|
||||
using BriarQueen.Framework.Registries;
|
||||
using BriarQueen.Framework.Services.Game;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using UnityEngine.ResourceManagement.ResourceProviders;
|
||||
using VContainer;
|
||||
|
||||
namespace BriarQueen.Game.Cinematics
|
||||
{
|
||||
public class OpeningCinematic : BaseCinematic
|
||||
{
|
||||
private AddressableManager _addressableManager;
|
||||
private AssetRegistry _assetRegistry;
|
||||
private GameService _gameService;
|
||||
private LevelManager _levelManager;
|
||||
private SaveManager _saveManager;
|
||||
|
||||
private SceneInstance _loadedScene;
|
||||
private AsyncOperationHandle<SceneInstance> _loadedSceneHandle;
|
||||
|
||||
protected async UniTaskVoid Start()
|
||||
{
|
||||
var destroyToken = this.GetCancellationTokenOnDestroy();
|
||||
|
||||
try
|
||||
{
|
||||
if (_assetRegistry == null ||
|
||||
!_assetRegistry.TryGetReference(
|
||||
AssetKeyIdentifiers.Get(SceneKey.GameScene),
|
||||
out var loadedSceneRef))
|
||||
{
|
||||
Debug.LogWarning("[OpeningCinematic] Missing GameScene reference in AssetRegistry.");
|
||||
return;
|
||||
}
|
||||
|
||||
_loadedSceneHandle = await _addressableManager.LoadSceneAsync(
|
||||
loadedSceneRef,
|
||||
autoLoad: false,
|
||||
cancellationToken: destroyToken);
|
||||
|
||||
if (_loadedSceneHandle.IsValid())
|
||||
_loadedScene = _loadedSceneHandle.Result;
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[OpeningCinematic] Failed to preload GameScene.");
|
||||
return;
|
||||
}
|
||||
|
||||
await PlayCinematic(destroyToken);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected override async UniTask OnCinematicEnd()
|
||||
{
|
||||
if (!_loadedSceneHandle.IsValid())
|
||||
{
|
||||
Debug.LogWarning("[OpeningCinematic] Game scene handle invalid; cannot transition.");
|
||||
await _gameService.LoadMainMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
gameObject.SetActive(false);
|
||||
|
||||
await _loadedScene.ActivateAsync().ToUniTask();
|
||||
await _gameService.SwapGameSceneHandle(_loadedSceneHandle);
|
||||
|
||||
if (_saveManager.CurrentSave != null)
|
||||
_saveManager.CurrentSave.OpeningCinematicPlayed = true;
|
||||
|
||||
var levelLoaded = await _levelManager.LoadLevel(
|
||||
AssetKeyIdentifiers.Get(LevelKey.ChapterOneVillageEdge));
|
||||
|
||||
if (!levelLoaded)
|
||||
{
|
||||
Debug.LogError(
|
||||
"[OpeningCinematic] Failed to load ChapterOneVillageEdge after cinematic. Returning to main menu.");
|
||||
await _gameService.LoadMainMenu();
|
||||
}
|
||||
}
|
||||
|
||||
[Inject]
|
||||
public void Construct(
|
||||
AddressableManager addressableManager,
|
||||
AssetRegistry assetRegistry,
|
||||
EventCoordinator eventCoordinator,
|
||||
LevelManager levelManager,
|
||||
GameService gameService,
|
||||
InputManager inputManager,
|
||||
SaveManager saveManager)
|
||||
{
|
||||
base.Construct(eventCoordinator, inputManager);
|
||||
|
||||
_addressableManager = addressableManager;
|
||||
_assetRegistry = assetRegistry;
|
||||
_levelManager = levelManager;
|
||||
_gameService = gameService;
|
||||
_saveManager = saveManager;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Game/Cinematics/OpeningCinematic.cs.meta
Normal file
3
Assets/Scripts/Game/Cinematics/OpeningCinematic.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60a9bb3284c148b89edd6f46df6284dc
|
||||
timeCreated: 1769970270
|
||||
3
Assets/Scripts/Game/Cinematics/Scopes.meta
Normal file
3
Assets/Scripts/Game/Cinematics/Scopes.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f22ccda226c4e07bcdb00ff5983d62b
|
||||
timeCreated: 1773833525
|
||||
20
Assets/Scripts/Game/Cinematics/Scopes/CinematicScope.cs
Normal file
20
Assets/Scripts/Game/Cinematics/Scopes/CinematicScope.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace BriarQueen.Game.Cinematics.Scopes
|
||||
{
|
||||
public class CinematicScope : LifetimeScope
|
||||
{
|
||||
[SerializeField]
|
||||
private List<BaseCinematic> _cinematics;
|
||||
|
||||
protected override void Configure(IContainerBuilder builder)
|
||||
{
|
||||
if (_cinematics.Count > 0)
|
||||
foreach (var component in _cinematics)
|
||||
builder.RegisterComponent(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb0a6d9650bf4c759ebcef1ed4f1eba1
|
||||
timeCreated: 1770666441
|
||||
205
Assets/Scripts/Game/Cinematics/SplashScreens.cs
Normal file
205
Assets/Scripts/Game/Cinematics/SplashScreens.cs
Normal file
@@ -0,0 +1,205 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using BriarQueen.Framework.Services.Game;
|
||||
using BriarQueen.Game.Cinematics.Data;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using VContainer;
|
||||
|
||||
namespace BriarQueen.Game.Cinematics
|
||||
{
|
||||
public class SplashScreens : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
[ReorderableList]
|
||||
private List<CinematicPanel> _splashScreens = new();
|
||||
|
||||
[SerializeField]
|
||||
private Image _activeSplashScreen;
|
||||
|
||||
[Header("Playback")]
|
||||
[Tooltip("Small fade for polish. Set to 0 for hard cuts.")]
|
||||
[SerializeField]
|
||||
private float _fadeDuration = 0.15f;
|
||||
|
||||
[SerializeField]
|
||||
private bool _skipInvalidPanels = true;
|
||||
|
||||
private CancellationTokenSource _cts;
|
||||
private GameService _gameService;
|
||||
private bool _isPlaying;
|
||||
|
||||
[Inject]
|
||||
public void Construct(GameService gameService)
|
||||
{
|
||||
_gameService = gameService;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
if (_isPlaying)
|
||||
return;
|
||||
|
||||
Debug.Log("[SplashScreens] Playing splash screens.");
|
||||
|
||||
_isPlaying = true;
|
||||
_cts?.Dispose();
|
||||
_cts = new CancellationTokenSource();
|
||||
|
||||
RunSequence(_cts.Token).Forget();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (!_isPlaying)
|
||||
return;
|
||||
|
||||
_isPlaying = false;
|
||||
|
||||
try
|
||||
{
|
||||
_cts?.Cancel();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
_cts?.Dispose();
|
||||
_cts = null;
|
||||
}
|
||||
}
|
||||
|
||||
private async UniTaskVoid RunSequence(CancellationToken token)
|
||||
{
|
||||
try
|
||||
{
|
||||
Debug.Log("[SplashScreens] Splash screen sequence started.");
|
||||
|
||||
if (_activeSplashScreen == null)
|
||||
{
|
||||
Debug.LogWarning("[SplashScreens] Active splash Image is not assigned.");
|
||||
await EndSplashScreens();
|
||||
return;
|
||||
}
|
||||
|
||||
var cg = _activeSplashScreen.GetComponent<CanvasGroup>();
|
||||
if (cg == null)
|
||||
cg = _activeSplashScreen.gameObject.AddComponent<CanvasGroup>();
|
||||
|
||||
cg.alpha = 0f;
|
||||
_activeSplashScreen.enabled = true;
|
||||
|
||||
if (_splashScreens == null || _splashScreens.Count == 0)
|
||||
{
|
||||
Debug.LogWarning("[SplashScreens] No splash panels configured.");
|
||||
await EndSplashScreens();
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < _splashScreens.Count; i++)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
var panel = _splashScreens[i];
|
||||
if (panel == null || panel.CinematicImage == null)
|
||||
{
|
||||
if (_skipInvalidPanels)
|
||||
continue;
|
||||
|
||||
Debug.LogWarning($"[SplashScreens] Splash panel at index {i} is null or missing image.");
|
||||
continue;
|
||||
}
|
||||
|
||||
_activeSplashScreen.sprite = panel.CinematicImage;
|
||||
|
||||
if (_fadeDuration > 0f)
|
||||
await FadeTo(cg, 1f, _fadeDuration, token);
|
||||
else
|
||||
cg.alpha = 1f;
|
||||
|
||||
var hold = Mathf.Max(0f, panel.DisplayTime);
|
||||
if (hold > 0f)
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(hold), cancellationToken: token);
|
||||
|
||||
if (_fadeDuration > 0f)
|
||||
await FadeTo(cg, 0f, _fadeDuration, token);
|
||||
else
|
||||
cg.alpha = 0f;
|
||||
}
|
||||
|
||||
await EndSplashScreens();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"[SplashScreens] Sequence failed: {ex}");
|
||||
|
||||
try
|
||||
{
|
||||
await EndSplashScreens();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isPlaying = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async UniTask FadeTo(CanvasGroup cg, float target, float duration, CancellationToken token)
|
||||
{
|
||||
var start = cg.alpha;
|
||||
|
||||
if (Mathf.Approximately(start, target))
|
||||
{
|
||||
cg.alpha = target;
|
||||
return;
|
||||
}
|
||||
|
||||
var t = 0f;
|
||||
while (t < duration)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
t += Time.deltaTime;
|
||||
var p = Mathf.Clamp01(t / duration);
|
||||
cg.alpha = Mathf.Lerp(start, target, p);
|
||||
|
||||
await UniTask.NextFrame(token);
|
||||
}
|
||||
|
||||
cg.alpha = target;
|
||||
}
|
||||
|
||||
private async UniTask EndSplashScreens()
|
||||
{
|
||||
if (_gameService != null)
|
||||
{
|
||||
await _gameService.LoadUIAndMainMenuScene();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[SplashScreens] GameService is null; cannot load UI/MainMenu scene.");
|
||||
}
|
||||
|
||||
const string bootstrapSceneName = "00_Bootstrap";
|
||||
var scene = SceneManager.GetSceneByName(bootstrapSceneName);
|
||||
if (scene.IsValid() && scene.isLoaded)
|
||||
await SceneManager.UnloadSceneAsync(bootstrapSceneName);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Game/Cinematics/SplashScreens.cs.meta
Normal file
3
Assets/Scripts/Game/Cinematics/SplashScreens.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21a1c3d08d6f49a8b1c36082ed1f0a16
|
||||
timeCreated: 1770136340
|
||||
3
Assets/Scripts/Game/Items.meta
Normal file
3
Assets/Scripts/Game/Items.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fd2d197341941499b0497c7af098252
|
||||
timeCreated: 1769699857
|
||||
3
Assets/Scripts/Game/Items/Environment.meta
Normal file
3
Assets/Scripts/Game/Items/Environment.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 026072510e794241bdaa169bba452696
|
||||
timeCreated: 1773589962
|
||||
3
Assets/Scripts/Game/Items/Environment/ChapterOne.meta
Normal file
3
Assets/Scripts/Game/Items/Environment/ChapterOne.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be01b5741bc94861a9b41d8c8ce3b5ee
|
||||
timeCreated: 1773590011
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae64d437e6594bf58b5512ee5ffca402
|
||||
timeCreated: 1773590011
|
||||
@@ -0,0 +1,45 @@
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Data.IO.Saves;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Framework.Managers.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace BriarQueen.Game.Items.Environment.ChapterOne.Pumphouse
|
||||
{
|
||||
public class PumpHouseWaterValve : BaseItem
|
||||
{
|
||||
public override string InteractableName => "Water Valve";
|
||||
public override UICursorService.CursorStyle ApplicableCursorStyle => UICursorService.CursorStyle.Interact;
|
||||
|
||||
public override UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
if (!CheckEmptyHands())
|
||||
return UniTask.CompletedTask;
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
if (SaveManager.GetLevelFlag(LevelFlag.PumpWaterRestored))
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(LevelInteractKey.WaterValve)));
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
if (!SaveManager.GetLevelFlag(LevelFlag.FountainVinesCut))
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(LevelInteractKey.ClearVinesOutside)));
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
// TODO : Play Water SFX
|
||||
SaveManager.SetLevelFlag(LevelFlag.PumpWaterRestored, true);
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ffe97b80fed45bbb7152752c4f10685
|
||||
timeCreated: 1770991451
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3825afbb1ee941b1af18781d8f1311fa
|
||||
timeCreated: 1773590034
|
||||
@@ -0,0 +1,44 @@
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Data.IO.Saves;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Framework.Managers.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace BriarQueen.Game.Items.Environment.ChapterOne.Village
|
||||
{
|
||||
public class ChainLock : BaseItem
|
||||
{
|
||||
public override string InteractableName => "Locked Chain";
|
||||
public override UICursorService.CursorStyle ApplicableCursorStyle => UICursorService.CursorStyle.Inspect;
|
||||
|
||||
public override async UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
if (!CheckEmptyHands())
|
||||
return;
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(LevelInteractKey.PumphouseChain)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.UniqueID != ItemIDs.Pickups[ItemKey.PumphouseKey])
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
return;
|
||||
}
|
||||
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(LevelInteractKey.UnlockedPumphouse)));
|
||||
await Remove();
|
||||
}
|
||||
|
||||
protected override UniTask OnRemoved()
|
||||
{
|
||||
SaveManager.SetLevelFlag(LevelFlag.PumpHouseOpened, true);
|
||||
PlayerManager.RemoveItem(ItemIDs.Pickups[ItemKey.PumphouseKey]);
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf2e55b12a3040deb4e54465336fc989
|
||||
timeCreated: 1770985414
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45144a83888f401e8d282181328521fb
|
||||
timeCreated: 1773953887
|
||||
@@ -0,0 +1,56 @@
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Framework.Managers.UI;
|
||||
using BriarQueen.Game.Levels.ChapterOne.VillageStreet;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Game.Items.Environment.ChapterOne.VillageStreet
|
||||
{
|
||||
public class StreetVines : BaseItem
|
||||
{
|
||||
[SerializeField]
|
||||
private Street _owner;
|
||||
|
||||
public override UICursorService.CursorStyle ApplicableCursorStyle => UICursorService.CursorStyle.Inspect;
|
||||
|
||||
public override async UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
if (_owner == null)
|
||||
{
|
||||
Debug.LogWarning("StreetVines is missing its Street owner.", this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CanUseKnife())
|
||||
{
|
||||
PublishFailureMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(
|
||||
InteractEventIDs.Get(EnvironmentInteractKey.UsingKnife)));
|
||||
|
||||
await _owner.CutVines();
|
||||
}
|
||||
|
||||
private bool CanUseKnife()
|
||||
{
|
||||
if (SettingsService.Game.AutoUseTools)
|
||||
return PlayerManager.HasAccessToTool(ToolID.Knife);
|
||||
|
||||
return PlayerManager.GetEquippedTool() == ToolID.Knife;
|
||||
}
|
||||
|
||||
private void PublishFailureMessage()
|
||||
{
|
||||
var message = SettingsService.Game.AutoUseTools
|
||||
? InteractEventIDs.Get(LevelInteractKey.CutVines)
|
||||
: InteractEventIDs.Get(ItemInteractKey.WrongTool);
|
||||
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32a79fbd751c4216b83680bbc425cfa7
|
||||
timeCreated: 1773954077
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5cf35e464ec407c81e5d29b6bf5c713
|
||||
timeCreated: 1773590078
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c3efb5408364c23bc9f0256bb727fb5
|
||||
timeCreated: 1773609093
|
||||
@@ -0,0 +1,20 @@
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Framework.Managers.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace BriarQueen.Game.Items.Environment.ChapterOne.Workshop.Downstairs
|
||||
{
|
||||
public class WorkshopBrokenLantern : BaseItem
|
||||
{
|
||||
public override UICursorService.CursorStyle ApplicableCursorStyle => UICursorService.CursorStyle.Inspect;
|
||||
|
||||
public override UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(EnvironmentInteractKey.BrokenLantern)));
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1004a82a9b7f487180b0fcf4978a4446
|
||||
timeCreated: 1773609258
|
||||
@@ -0,0 +1,45 @@
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Framework.Managers.UI;
|
||||
using BriarQueen.Game.Levels.ChapterOne.Workshop;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Game.Items.Environment.ChapterOne.Workshop.Downstairs
|
||||
{
|
||||
public class WorkshopDownstairsLight : BaseItem
|
||||
{
|
||||
[SerializeField]
|
||||
private WorkshopDownstairs _workshopDownstairs;
|
||||
|
||||
public override UICursorService.CursorStyle ApplicableCursorStyle => UICursorService.CursorStyle.Interact;
|
||||
|
||||
public override string InteractableName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_workshopDownstairs.LightOn)
|
||||
return "Turn off Light";
|
||||
|
||||
return "Turn on Light";
|
||||
}
|
||||
}
|
||||
|
||||
public override UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
if(!CheckEmptyHands())
|
||||
return UniTask.CompletedTask;
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
_workshopDownstairs.ToggleLightSwitch();
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c5889af77b0491bb18818491222520b
|
||||
timeCreated: 1773609093
|
||||
@@ -0,0 +1,20 @@
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Framework.Managers.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace BriarQueen.Game.Items.Environment.ChapterOne.Workshop.Downstairs
|
||||
{
|
||||
public class WorkshopWriting : BaseItem
|
||||
{
|
||||
public override UICursorService.CursorStyle ApplicableCursorStyle => UICursorService.CursorStyle.Inspect;
|
||||
|
||||
public override UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(EnvironmentInteractKey.WorkshopWriting)));
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8ae950ec2f6412f9a05f9eb22a81004
|
||||
timeCreated: 1773681035
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Data.IO.Saves;
|
||||
using BriarQueen.Framework.Events.Gameplay;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Framework.Managers.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Game.Items.Environment.ChapterOne.Workshop
|
||||
{
|
||||
public class GrindingStone : BaseItem
|
||||
{
|
||||
[SerializeField]
|
||||
private Levels.ChapterOne.Workshop.Workshop _workshop;
|
||||
|
||||
public override string InteractableName => "Grinding Stone";
|
||||
|
||||
public override UICursorService.CursorStyle ApplicableCursorStyle => UICursorService.CursorStyle.Interact;
|
||||
|
||||
public override async UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
if (!CheckEmptyHands())
|
||||
return;
|
||||
|
||||
if (!SaveManager.GetLevelFlag(LevelFlag.WorkshopGrindstoneRepaired))
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
EventCoordinator.Publish(
|
||||
new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.SomethingMissing)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.UniqueID != ItemIDs.Get(ItemKey.GrindstoneAxlePin))
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
return;
|
||||
}
|
||||
|
||||
await _workshop.SetWoodenPin();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(EnvironmentInteractKey.UseGrindstone)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.UniqueID != ItemIDs.Get(ItemKey.RustedKnife))
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO - Animations, SFX, etc
|
||||
|
||||
EventCoordinator.Publish(new FadeEvent(false, 0.6f));
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(1.2f));
|
||||
AudioManager.Play(AudioNameIdentifiers.Get(SFXKey.SharpenKnife));
|
||||
EventCoordinator.Publish(new FadeEvent(true, 0.6f));
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(0.8f));
|
||||
|
||||
PlayerManager.UnlockTool(ToolID.Knife);
|
||||
TutorialService.DisplayTutorial(TutorialPopupID.Tools);
|
||||
PlayerManager.RemoveItem(ItemIDs.Get(ItemKey.RustedKnife));
|
||||
|
||||
EventCoordinator.Publish(new SelectedItemChangedEvent(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7af3243d1b3240a5bb86ba7cd0b2e9b8
|
||||
timeCreated: 1771003747
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09d6091451f64822a55575f3ab2b6b68
|
||||
timeCreated: 1773590204
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b57d4daa04964b28b6c24a1e41fb4d6a
|
||||
timeCreated: 1773590204
|
||||
@@ -0,0 +1,40 @@
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Game.Levels.ChapterOne.Workshop.Upstairs;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Game.Items.Environment.ChapterOne.Workshop.Upstairs.Bag
|
||||
{
|
||||
public class WorkshopBagBook : BaseItem
|
||||
{
|
||||
[Header("Internal")]
|
||||
[SerializeField]
|
||||
private WorkshopBag _bag;
|
||||
|
||||
public override string InteractableName => "Damaged Book";
|
||||
|
||||
public override async UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
if(!CheckEmptyHands())
|
||||
return;
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
return;
|
||||
}
|
||||
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(EnvironmentInteractKey.WorkshopBookDisintegrating)));
|
||||
await Remove();
|
||||
}
|
||||
|
||||
protected override UniTask OnRemoved()
|
||||
{
|
||||
_bag.RemoveBook();
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a482fd71d48d4edaaceec7a7038a72a2
|
||||
timeCreated: 1773496524
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Data.IO.Saves;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Game.Levels.ChapterOne.Workshop.Upstairs;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Game.Items.Environment.ChapterOne.Workshop.Upstairs.Bag
|
||||
{
|
||||
public class WorkshopBagHole : BaseItem
|
||||
{
|
||||
[Header("Workshop Bag")]
|
||||
[SerializeField]
|
||||
private WorkshopBag _workshopBag;
|
||||
|
||||
public override string InteractableName => "Dig";
|
||||
|
||||
public override async UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
if(!CheckEmptyHands())
|
||||
return;
|
||||
|
||||
if (SaveManager.GetLevelFlag(LevelFlag.WorkshopBagHoleDug))
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(
|
||||
InteractEventIDs.Get(EnvironmentInteractKey.WorkshopBagNoItems)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
return;
|
||||
}
|
||||
|
||||
EventCoordinator.Publish(new FadeEvent(false, 1f));
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(1));
|
||||
|
||||
await _workshopBag.DigHole();
|
||||
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(1));
|
||||
EventCoordinator.Publish(new FadeEvent(true, 1f));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8e8a954a6d04904b15e4e1b50db8615
|
||||
timeCreated: 1773494920
|
||||
3
Assets/Scripts/Game/Items/Environment/General.meta
Normal file
3
Assets/Scripts/Game/Items/Environment/General.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44d1ad2d59094966b83912a68097b451
|
||||
timeCreated: 1773590165
|
||||
3
Assets/Scripts/Game/Items/Environment/General/Book.meta
Normal file
3
Assets/Scripts/Game/Items/Environment/General/Book.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb142f5c855c46e8a7e406646e5a7b02
|
||||
timeCreated: 1773507259
|
||||
@@ -0,0 +1,55 @@
|
||||
using BriarQueen.Framework.Coordinators.Events;
|
||||
using BriarQueen.Framework.Events.Input;
|
||||
using BriarQueen.Framework.Managers.Interaction;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using VContainer;
|
||||
|
||||
namespace BriarQueen.Game.Items.Environment.General.Book
|
||||
{
|
||||
public class BookInterface : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private CanvasGroup _canvasGroup;
|
||||
|
||||
[SerializeField]
|
||||
private GraphicRaycaster _graphicRaycaster;
|
||||
|
||||
private BookTrigger _bookTrigger;
|
||||
private EventCoordinator _eventCoordinator;
|
||||
private InteractManager _interactManager;
|
||||
|
||||
internal CanvasGroup CanvasGroup => _canvasGroup;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_interactManager.SetExclusiveRaycaster(_graphicRaycaster);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
_eventCoordinator.Unsubscribe<OnRightClickEvent>(OnRightClickPressed);
|
||||
_interactManager.ClearExclusiveRaycaster();
|
||||
}
|
||||
|
||||
[Inject]
|
||||
public void Construct(EventCoordinator eventCoordinator, InteractManager interactManager)
|
||||
{
|
||||
_eventCoordinator = eventCoordinator;
|
||||
_interactManager = interactManager;
|
||||
}
|
||||
|
||||
public void Initialise(BookTrigger trigger)
|
||||
{
|
||||
_bookTrigger = trigger;
|
||||
|
||||
_eventCoordinator.Subscribe<OnRightClickEvent>(OnRightClickPressed);
|
||||
}
|
||||
|
||||
private void OnRightClickPressed(OnRightClickEvent e)
|
||||
{
|
||||
_bookTrigger.CloseBookInterface().Forget();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a73c3f5588834da2a26a77de99f59e3c
|
||||
timeCreated: 1773508324
|
||||
@@ -0,0 +1,147 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Events.Save;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Framework.Managers.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using PrimeTween;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Game.Items.Environment.General.Book
|
||||
{
|
||||
public class BookTrigger : BaseItem
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField]
|
||||
private AssetItemKey _bookAssetID;
|
||||
|
||||
[SerializeField]
|
||||
private BookEntryID _bookEntryID;
|
||||
|
||||
[Header("Book Interface")]
|
||||
[SerializeField]
|
||||
private BookInterface _bookInterface;
|
||||
|
||||
private CancellationTokenSource _displayCts;
|
||||
|
||||
private Sequence _displaySequence;
|
||||
|
||||
public override string InteractableName => "Worn Book";
|
||||
public override UICursorService.CursorStyle ApplicableCursorStyle => UICursorService.CursorStyle.Inspect;
|
||||
|
||||
public override async UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CheckEmptyHands())
|
||||
return;
|
||||
|
||||
await InstantiateBookInterface();
|
||||
}
|
||||
|
||||
private async UniTask InstantiateBookInterface()
|
||||
{
|
||||
Debug.Log($"Instantiating {_bookAssetID}");
|
||||
|
||||
if (!AssetRegistry.TryGetReference(AssetKeyIdentifiers.Get(_bookAssetID), out var assetReference) ||
|
||||
assetReference == null)
|
||||
return;
|
||||
|
||||
var bookObj = await AddressableManager.InstantiateAsync(assetReference);
|
||||
if (bookObj == null) return;
|
||||
|
||||
_bookInterface = bookObj.GetComponent<BookInterface>();
|
||||
if (_bookInterface == null) return;
|
||||
|
||||
_bookInterface.CanvasGroup.alpha = 0f;
|
||||
_bookInterface.CanvasGroup.blocksRaycasts = false;
|
||||
_bookInterface.CanvasGroup.interactable = false;
|
||||
|
||||
_bookInterface.Initialise(this);
|
||||
Debug.Log($"Instantiated {_bookAssetID}");
|
||||
|
||||
CancelTweenIfRunning();
|
||||
_displayCts = new CancellationTokenSource();
|
||||
|
||||
_displaySequence = Sequence.Create(useUnscaledTime: true)
|
||||
.Group(Tween.Alpha(_bookInterface.CanvasGroup, new TweenSettings<float>
|
||||
{
|
||||
endValue = 1f,
|
||||
settings = new TweenSettings { duration = 0.8f }
|
||||
}));
|
||||
|
||||
try
|
||||
{
|
||||
await _displaySequence.ToUniTask(cancellationToken: _displayCts.Token);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
|
||||
_bookInterface.CanvasGroup.blocksRaycasts = true;
|
||||
_bookInterface.CanvasGroup.interactable = true;
|
||||
|
||||
ShowTutorialIfNeeded();
|
||||
UnlockCodexEntry();
|
||||
}
|
||||
|
||||
private void ShowTutorialIfNeeded()
|
||||
{
|
||||
TutorialService.DisplayTutorial(TutorialPopupID.ExitItems);
|
||||
}
|
||||
|
||||
private void UnlockCodexEntry()
|
||||
{
|
||||
PlayerManager.UnlockCodexEntry(CodexEntryIDs.Get(_bookEntryID));
|
||||
}
|
||||
|
||||
public async UniTask CloseBookInterface()
|
||||
{
|
||||
if (_bookInterface == null) return;
|
||||
|
||||
CancelTweenIfRunning();
|
||||
_displayCts = new CancellationTokenSource();
|
||||
|
||||
_displaySequence = Sequence.Create(useUnscaledTime: true)
|
||||
.Group(Tween.Alpha(_bookInterface.CanvasGroup, new TweenSettings<float>
|
||||
{
|
||||
startValue = _bookInterface.CanvasGroup.alpha,
|
||||
endValue = 0f,
|
||||
settings = new TweenSettings { duration = 0.6f }
|
||||
}));
|
||||
|
||||
try
|
||||
{
|
||||
await _displaySequence.ToUniTask(cancellationToken: _displayCts.Token);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
|
||||
await DestructionService.Destroy(_bookInterface.gameObject);
|
||||
_bookInterface = null;
|
||||
}
|
||||
|
||||
private void CancelTweenIfRunning()
|
||||
{
|
||||
if (_displaySequence.isAlive) _displaySequence.Complete();
|
||||
DisposeCts();
|
||||
}
|
||||
|
||||
private void DisposeCts()
|
||||
{
|
||||
if (_displayCts == null) return;
|
||||
|
||||
_displayCts.Cancel();
|
||||
_displayCts.Dispose();
|
||||
_displayCts = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca523ca014894287805fea5daba9276c
|
||||
timeCreated: 1773507259
|
||||
@@ -0,0 +1,33 @@
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Framework.Managers.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Game.Items.Environment.General
|
||||
{
|
||||
public class EnvironmentTrigger : BaseItem
|
||||
{
|
||||
[Header("Interaction")]
|
||||
[SerializeField]
|
||||
private EnvironmentInteractKey _interactKey;
|
||||
|
||||
[SerializeField]
|
||||
private bool _removeTrigger;
|
||||
|
||||
public override UICursorService.CursorStyle ApplicableCursorStyle => UICursorService.CursorStyle.Inspect;
|
||||
|
||||
public override async UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
if (!CheckEmptyHands())
|
||||
return;
|
||||
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(_interactKey)));
|
||||
|
||||
if (_removeTrigger)
|
||||
await Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f499bd83d87940e5892d63e525087505
|
||||
timeCreated: 1773862043
|
||||
@@ -0,0 +1,65 @@
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Data.IO.Saves;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Framework.Managers.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Game.Items.Environment.General
|
||||
{
|
||||
public class TwistingVines : BaseItem
|
||||
{
|
||||
[Header("Flags")]
|
||||
[SerializeField]
|
||||
private LevelFlag _levelFlag;
|
||||
|
||||
public override string InteractableName => "Twisting Vines";
|
||||
public override UICursorService.CursorStyle ApplicableCursorStyle => UICursorService.CursorStyle.Inspect;
|
||||
|
||||
public override async UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
EventCoordinator.Publish(
|
||||
new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CanUseKnife())
|
||||
{
|
||||
PublishFailureMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
EventCoordinator.Publish(
|
||||
new DisplayInteractEvent(InteractEventIDs.Get(EnvironmentInteractKey.UsingKnife)));
|
||||
|
||||
await Remove();
|
||||
}
|
||||
|
||||
protected override UniTask OnRemoved()
|
||||
{
|
||||
SaveManager.SetLevelFlag(_levelFlag, true);
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
private bool CanUseKnife()
|
||||
{
|
||||
if (SettingsService.Game.AutoUseTools)
|
||||
return PlayerManager.HasAccessToTool(ToolID.Knife);
|
||||
|
||||
return PlayerManager.GetEquippedTool() == ToolID.Knife;
|
||||
}
|
||||
|
||||
private void PublishFailureMessage()
|
||||
{
|
||||
var message = SettingsService.Game.AutoUseTools
|
||||
? InteractEventIDs.Get(LevelInteractKey.CutVines)
|
||||
: InteractEventIDs.Get(ItemInteractKey.WrongTool);
|
||||
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 716b29e16fd1452b87eaf8903c0275a0
|
||||
timeCreated: 1770982267
|
||||
3
Assets/Scripts/Game/Items/HoverZones.meta
Normal file
3
Assets/Scripts/Game/Items/HoverZones.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b350acb8634b46a5a5e890e64813f2a2
|
||||
timeCreated: 1773590247
|
||||
3
Assets/Scripts/Game/Items/HoverZones/ChapterOne.meta
Normal file
3
Assets/Scripts/Game/Items/HoverZones/ChapterOne.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bceb9c6179804ca6a6ab860091497bec
|
||||
timeCreated: 1773590266
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b96e740c17be4776b814df0cdf3e4ba9
|
||||
timeCreated: 1773837562
|
||||
@@ -0,0 +1,13 @@
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Data.IO.Saves;
|
||||
|
||||
namespace BriarQueen.Game.Items.HoverZones.ChapterOne.Village
|
||||
{
|
||||
public class FountainInteractZone : InteractZone
|
||||
{
|
||||
protected override bool CheckUnlockStatus()
|
||||
{
|
||||
return SaveManager.GetLevelFlag(LevelFlag.PumpWaterRestored);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91690066830a4fc18ef4d37e59c35f77
|
||||
timeCreated: 1773492836
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf66aebc6b634be6835a5cb959b676bc
|
||||
timeCreated: 1773590266
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3eccc4b792f428e998c154badaf8df2
|
||||
timeCreated: 1773859979
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace BriarQueen.Game.Items.HoverZones.ChapterOne.Workshop.Downstairs
|
||||
{
|
||||
public class WorkshopBookcaseInteractZone : InteractZone
|
||||
{
|
||||
public override string InteractableName => !CanvasGroup.interactable ? string.Empty : "Inspect Bookcase";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 075b00fc69004603b54fe09287b25112
|
||||
timeCreated: 1773859979
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a842be13bc18495282b2baad5f07b164
|
||||
timeCreated: 1773590266
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f5eb751f8264020972f1f38d92567ba
|
||||
timeCreated: 1773591269
|
||||
@@ -0,0 +1,19 @@
|
||||
using BriarQueen.Game.Puzzles.ChapterOne.Workshop.BoxPuzzle;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Game.Items.HoverZones.ChapterOne.Workshop.Upstairs.PuzzleBox
|
||||
{
|
||||
public class PuzzleBoxInteractZone : InteractZone
|
||||
{
|
||||
[SerializeField]
|
||||
private WorkshopBasePuzzleBox _basePuzzleBox;
|
||||
|
||||
private string _interactName = string.Empty;
|
||||
public override string InteractableName => _interactName;
|
||||
|
||||
public void SetInteractableName()
|
||||
{
|
||||
_interactName = "Open Box";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2700af83a384ed2a2003a64ecd72f1a
|
||||
timeCreated: 1773515450
|
||||
@@ -0,0 +1,40 @@
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Data.IO.Saves;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace BriarQueen.Game.Items.HoverZones.ChapterOne.Workshop.Upstairs
|
||||
{
|
||||
public class WorkshopSafeInteractZone : InteractZone
|
||||
{
|
||||
public override string InteractableName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!SaveManager.GetLevelFlag(LevelFlag.WorkshopSafeUnlocked))
|
||||
return "Locked Safe";
|
||||
|
||||
return "Unlocked Safe";
|
||||
}
|
||||
}
|
||||
|
||||
public override async UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SaveManager.GetLevelFlag(LevelFlag.WorkshopSafeUnlocked))
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(
|
||||
InteractEventIDs.Get(LevelInteractKey.WorkshopLockedSafe)));
|
||||
return;
|
||||
}
|
||||
|
||||
await base.OnInteract(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9fb667aaff5490b9478cddc37e24c95
|
||||
timeCreated: 1772812658
|
||||
@@ -0,0 +1,12 @@
|
||||
using BriarQueen.Data.IO.Saves;
|
||||
|
||||
namespace BriarQueen.Game.Items.HoverZones.ChapterOne.Workshop
|
||||
{
|
||||
public class WorkshopDownstairsDoorInteractZone : InteractZone
|
||||
{
|
||||
protected override bool CheckUnlockStatus()
|
||||
{
|
||||
return SaveManager.GetLevelFlag(LevelFlag.WorkshopDownstairsDoorOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36a0b0a0b0714c4ea5138830f1405a11
|
||||
timeCreated: 1773572899
|
||||
112
Assets/Scripts/Game/Items/HoverZones/InteractZone.cs
Normal file
112
Assets/Scripts/Game/Items/HoverZones/InteractZone.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Coordinators.Events;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Interaction.Data;
|
||||
using BriarQueen.Framework.Managers.IO;
|
||||
using BriarQueen.Framework.Managers.Levels;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Framework.Managers.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
|
||||
namespace BriarQueen.Game.Items.HoverZones
|
||||
{
|
||||
public class InteractZone : MonoBehaviour, IInteractable
|
||||
{
|
||||
[Header("Level Setup")]
|
||||
[SerializeField]
|
||||
private LevelKey _levelToLoad;
|
||||
|
||||
[SerializeField]
|
||||
private string _levelName;
|
||||
|
||||
[SerializeField]
|
||||
private string _lockedTooltipText = string.Empty;
|
||||
[SerializeField]
|
||||
private string _lockedInteractText = string.Empty;
|
||||
|
||||
[SerializeField]
|
||||
private bool _locked;
|
||||
|
||||
[Header("UI Setup")]
|
||||
[SerializeField]
|
||||
private UICursorService.CursorStyle _cursorStyle = UICursorService.CursorStyle.Travel;
|
||||
|
||||
protected EventCoordinator EventCoordinator;
|
||||
protected LevelManager LevelManager;
|
||||
protected SaveManager SaveManager;
|
||||
|
||||
public CanvasGroup CanvasGroup;
|
||||
|
||||
protected void Awake()
|
||||
{
|
||||
if(CanvasGroup == null)
|
||||
CanvasGroup = GetComponent<CanvasGroup>();
|
||||
}
|
||||
|
||||
protected void Start()
|
||||
{
|
||||
if (_locked && CheckUnlockStatus())
|
||||
Unlock();
|
||||
}
|
||||
|
||||
public UICursorService.CursorStyle ApplicableCursorStyle => _cursorStyle;
|
||||
|
||||
public virtual string InteractableName => _locked ? _lockedTooltipText : _levelName;
|
||||
|
||||
public virtual async UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
if (_locked)
|
||||
{
|
||||
var message = !string.IsNullOrEmpty(_lockedInteractText) ? _lockedInteractText
|
||||
: InteractEventIDs.Get(EnvironmentInteractKey.Locked);
|
||||
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(message));
|
||||
return;
|
||||
}
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
return;
|
||||
}
|
||||
|
||||
var levelId = AssetKeyIdentifiers.Get(_levelToLoad);
|
||||
var loaded = await LevelManager.LoadLevel(levelId);
|
||||
|
||||
if (!loaded)
|
||||
{
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(EnvironmentInteractKey.CantGoThere)));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual UniTask EnterHover()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public virtual UniTask ExitHover()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
_locked = false;
|
||||
}
|
||||
|
||||
protected virtual bool CheckUnlockStatus()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
[Inject]
|
||||
public void Construct(LevelManager levelManager, EventCoordinator eventCoordinator, SaveManager saveManager)
|
||||
{
|
||||
LevelManager = levelManager;
|
||||
EventCoordinator = eventCoordinator;
|
||||
SaveManager = saveManager;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9528c00201e44fc2baf036655881cf0d
|
||||
timeCreated: 1770916856
|
||||
3
Assets/Scripts/Game/Items/Interactions.meta
Normal file
3
Assets/Scripts/Game/Items/Interactions.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 857b6aae0b004060bab06eb8854c0710
|
||||
timeCreated: 1771172388
|
||||
3
Assets/Scripts/Game/Items/Interactions/ChapterOne.meta
Normal file
3
Assets/Scripts/Game/Items/Interactions/ChapterOne.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ab38d47b61c4887836156eb319d0c63
|
||||
timeCreated: 1771172454
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b619d489d9440a0a3c1a9f46eda7fe6
|
||||
timeCreated: 1773780379
|
||||
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Coordinators.Events;
|
||||
using BriarQueen.Framework.Events.Gameplay;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Interaction.Data;
|
||||
using BriarQueen.Framework.Managers.Player;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace BriarQueen.Game.Items.Interactions.ChapterOne.Village
|
||||
{
|
||||
[Serializable]
|
||||
public class PliersInteraction : BaseInteraction
|
||||
{
|
||||
public override UniTask<bool> TryUseWith(
|
||||
ItemDataSo self,
|
||||
ItemDataSo other,
|
||||
PlayerManager playerManager,
|
||||
EventCoordinator eventCoordinator)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
eventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
return UniTask.FromResult(false);
|
||||
}
|
||||
|
||||
var pliersId = ItemIDs.Get(ItemKey.Pliers);
|
||||
|
||||
var emeraldAmuletId = ItemIDs.Get(ItemKey.EmeraldAmulet);
|
||||
var rubyRingId = ItemIDs.Get(ItemKey.RubyRing);
|
||||
var diamondTiaraId = ItemIDs.Get(ItemKey.DiamondTiara);
|
||||
|
||||
var emeraldId = ItemIDs.Get(ItemKey.Emerald);
|
||||
var rubyId = ItemIDs.Get(ItemKey.Ruby);
|
||||
var diamondId = ItemIDs.Get(ItemKey.Diamond);
|
||||
|
||||
var success = other.UniqueID switch
|
||||
{
|
||||
var id when id == emeraldAmuletId => ExtractGem(
|
||||
emeraldId,
|
||||
emeraldAmuletId,
|
||||
"You carefully pull the emerald out of the amulet."),
|
||||
|
||||
var id when id == rubyRingId => ExtractGem(
|
||||
rubyId,
|
||||
rubyRingId,
|
||||
"You carefully pull the ruby out of the ring."),
|
||||
|
||||
var id when id == diamondTiaraId => ExtractGem(
|
||||
diamondId,
|
||||
diamondTiaraId,
|
||||
"You carefully pull the diamond out of the tiara."),
|
||||
|
||||
_ => FailInteraction()
|
||||
};
|
||||
|
||||
return UniTask.FromResult(success);
|
||||
|
||||
bool ExtractGem(string gemId, string sourceItemId, string message)
|
||||
{
|
||||
eventCoordinator.Publish(new DisplayInteractEvent(message));
|
||||
playerManager.CollectItem(gemId);
|
||||
playerManager.RemoveItem(sourceItemId);
|
||||
|
||||
eventCoordinator.Publish(new SelectedItemChangedEvent(null));
|
||||
|
||||
CheckIfPliersBreak();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FailInteraction()
|
||||
{
|
||||
eventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.CantUseItem)));
|
||||
return false;
|
||||
}
|
||||
|
||||
void CheckIfPliersBreak()
|
||||
{
|
||||
var collectedItems = playerManager.GetAllCollectedItems();
|
||||
|
||||
var hasEmerald = collectedItems.Any(x => x.UniqueID == emeraldId);
|
||||
var hasRuby = collectedItems.Any(x => x.UniqueID == rubyId);
|
||||
var hasDiamond = collectedItems.Any(x => x.UniqueID == diamondId);
|
||||
|
||||
if (hasEmerald && hasRuby && hasDiamond)
|
||||
{
|
||||
eventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.PliersSnapped)));
|
||||
playerManager.RemoveItem(pliersId);
|
||||
|
||||
eventCoordinator.Publish(new SelectedItemChangedEvent(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b067daed4e5f4296a1a77f92af07cbc1
|
||||
timeCreated: 1773780295
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0adff31d53cb4f0197b3bfd4b779d036
|
||||
timeCreated: 1771172785
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Coordinators.Events;
|
||||
using BriarQueen.Framework.Events.Gameplay;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Interaction.Data;
|
||||
using BriarQueen.Framework.Managers.Player;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace BriarQueen.Game.Items.Interactions.ChapterOne.Workshop
|
||||
{
|
||||
[Serializable]
|
||||
public class SmallRagInteraction : BaseInteraction
|
||||
{
|
||||
public override async UniTask<bool> TryUseWith(ItemDataSo self, ItemDataSo other, PlayerManager playerManager,
|
||||
EventCoordinator eventCoordinator)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
if (other.UniqueID != ItemIDs.Get(ItemKey.DustySapphire))
|
||||
return false;
|
||||
|
||||
eventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.LooksImportant)));
|
||||
playerManager.CollectItem(ItemIDs.Get(ItemKey.Sapphire));
|
||||
playerManager.RemoveItem(ItemIDs.Get(ItemKey.DustySapphire));
|
||||
playerManager.RemoveItem(ItemIDs.Get(ItemKey.SmallRag));
|
||||
|
||||
eventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(ItemInteractKey.RagFallsApart)));
|
||||
eventCoordinator.Publish(new SelectedItemChangedEvent(null));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e41ece1b6efd4de3ae4a7c5fa0cf7a8a
|
||||
timeCreated: 1771172802
|
||||
3
Assets/Scripts/Game/Items/Pickups.meta
Normal file
3
Assets/Scripts/Game/Items/Pickups.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4442c407d64c4e038822ab7089063bb7
|
||||
timeCreated: 1769717587
|
||||
3
Assets/Scripts/Game/Items/Pickups/ChapterOne.meta
Normal file
3
Assets/Scripts/Game/Items/Pickups/ChapterOne.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e0f295f8d594ce4be759038d4584b3b
|
||||
timeCreated: 1770756534
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 497a6b1404a3420b8db86adb8ea0a814
|
||||
timeCreated: 1770991451
|
||||
@@ -0,0 +1,18 @@
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Events.Save;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace BriarQueen.Game.Items.Pickups.ChapterOne.Pumphouse
|
||||
{
|
||||
public class Pliers : BaseItem
|
||||
{
|
||||
protected override UniTask OnInteracted()
|
||||
{
|
||||
TutorialService.DisplayTutorial(TutorialPopupID.MultipleUseItems);
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 948e07af025b4fb7b0b3698c96d73f87
|
||||
timeCreated: 1770992135
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a11cd0830c544fa19956201c59d8d29d
|
||||
timeCreated: 1771003426
|
||||
@@ -0,0 +1,24 @@
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Game.Items.Pickups.ChapterOne.Workshop
|
||||
{
|
||||
public class Candle : BaseItem
|
||||
{
|
||||
[SerializeField]
|
||||
private CandleColour _colour;
|
||||
|
||||
public override string InteractableName => $"{_colour.ToString()} Candle";
|
||||
|
||||
internal enum CandleColour
|
||||
{
|
||||
Red,
|
||||
Orange,
|
||||
Yellow,
|
||||
Green,
|
||||
Blue,
|
||||
Indigo,
|
||||
Violet
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bec4d666bbcf43338c71dfa3ee9315c5
|
||||
timeCreated: 1771010785
|
||||
3
Assets/Scripts/Game/Items/WorldBuilding.meta
Normal file
3
Assets/Scripts/Game/Items/WorldBuilding.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e970ba2932634684a509d4de59098153
|
||||
timeCreated: 1772828379
|
||||
3
Assets/Scripts/Game/Items/WorldBuilding/ChapterOne.meta
Normal file
3
Assets/Scripts/Game/Items/WorldBuilding/ChapterOne.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 943af453313248b2a343c61ff9910099
|
||||
timeCreated: 1772828379
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6c9ad510e55448180517715f549734b
|
||||
timeCreated: 1772828379
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0bc65d47d744873bbd339fe2388bb69
|
||||
timeCreated: 1772828379
|
||||
@@ -0,0 +1,23 @@
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Events.UI;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using BriarQueen.Framework.Managers.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace BriarQueen.Game.Items.WorldBuilding.ChapterOne.Workshop.Upstairs
|
||||
{
|
||||
public class WorkshopUpstairsWindow : BaseItem
|
||||
{
|
||||
public override string InteractableName => "Window";
|
||||
|
||||
public override UICursorService.CursorStyle ApplicableCursorStyle => UICursorService.CursorStyle.Inspect;
|
||||
|
||||
public override UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
|
||||
EventCoordinator.Publish(new DisplayInteractEvent(InteractEventIDs.Get(EnvironmentInteractKey.DirtyWindow)));
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 690471ce902644e2a9c9758786435dbf
|
||||
timeCreated: 1772828385
|
||||
3
Assets/Scripts/Game/Levels.meta
Normal file
3
Assets/Scripts/Game/Levels.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c86f2f1ca4c4efc9b30099e2fb43a6a
|
||||
timeCreated: 1769725044
|
||||
3
Assets/Scripts/Game/Levels/ChapterOne.meta
Normal file
3
Assets/Scripts/Game/Levels/ChapterOne.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9b1b36bb3e74a68beb66483b88a7dd7
|
||||
timeCreated: 1770058841
|
||||
3
Assets/Scripts/Game/Levels/ChapterOne/PumpingHouse.meta
Normal file
3
Assets/Scripts/Game/Levels/ChapterOne/PumpingHouse.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0114dbf070ab429b8a99aed3853b3601
|
||||
timeCreated: 1773606763
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Linq;
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Game.Levels.ChapterOne.PumpingHouse
|
||||
{
|
||||
public class Pumphouse : BaseLevel
|
||||
{
|
||||
[SerializeField]
|
||||
private GameObject _pliers;
|
||||
|
||||
public override string LevelName => "Pumphouse";
|
||||
|
||||
protected override async UniTask PostLoadInternal()
|
||||
{
|
||||
if (SaveManager.CurrentSave.CollectedItems.Any(x => x.UniqueIdentifier == ItemIDs.Get(ItemKey.Pliers)))
|
||||
await DestructionService.Destroy(_pliers);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user