Skip to content

Commit 8ade957

Browse files
committed
feat: add simple path for finishing the game
1 parent 071c77a commit 8ade957

File tree

6 files changed

+263
-31
lines changed

6 files changed

+263
-31
lines changed

Assets/Environment/Floodlight.cs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Typewriter;
88
using UnityEngine;
99
using Utils;
10+
using Utils.Tweening;
1011

1112
namespace Environment {
1213
public class Floodlight : MonoBehaviour {
@@ -20,22 +21,35 @@ public class Floodlight : MonoBehaviour {
2021
[SerializeField] private Light[] _lights;
2122

2223
private TypewriterWatcher _watcher;
24+
private SpringTween _lightTween;
2325
private Cached<bool> _turnedOn;
26+
private float[] _intensities;
27+
28+
private void Start() {
29+
Update();
30+
_lightTween.ForceSet(_turnedOn ? 1 : 0);
31+
32+
_intensities = new float[_lights.Length];
33+
for (var i = 0; i < _lights.Length; i++) {
34+
_intensities[i] = _lights[i].intensity;
35+
if (!_turnedOn) {
36+
_lights[i].intensity = 0;
37+
}
38+
}
39+
}
2440

2541
private void Update() {
26-
if (!_watcher.ShouldUpdate()
27-
|| !_turnedOn.HasChanged(_interactable.Context.Get(_itemFilter) == 1)) {
28-
return;
42+
if (_watcher.ShouldUpdate()
43+
&& _turnedOn.HasChanged(_interactable.Context.Get(_itemFilter) == 1)) {
44+
_interactable.Context.Set(_turnedOnFact, _turnedOn.Value ? 1 : 0);
45+
_lightTween.Set(_turnedOn ? 1 : 0);
2946
}
47+
}
3048

31-
_interactable.Context.Set(_turnedOnFact, _turnedOn.Value ? 1 : 0);
32-
if (_turnedOn) {
33-
foreach (var lightItem in _lights) {
34-
lightItem.enabled = true;
35-
}
36-
} else {
37-
foreach (var lightItem in _lights) {
38-
lightItem.enabled = false;
49+
private void FixedUpdate() {
50+
if (_lightTween.FixedUpdate(SpringConfig.Slow)) {
51+
for (var i = 0; i < _lights.Length; i++) {
52+
_lights[i].intensity = _intensities[i] * _lightTween.X;
3953
}
4054
}
4155
}

Assets/Framework/StoryState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void Save() {
141141
}
142142

143143
public bool TryGetBlackboard(int scope, out IBlackboard blackboard) {
144-
if (scope == InteractionContext.GlobalScope) {
144+
if (_saveController != null && scope == InteractionContext.GlobalScope) {
145145
blackboard = _saveController.GlobalData.Blackboard;
146146
return true;
147147
}

Assets/Scenes/Intro/LoadingDocks.unity

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scenes/Outro/Outro.unity

Lines changed: 15 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Typewriter/Tables/LoadingDocs.asset

Lines changed: 204 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)