wip : critical path - flash hallu
This commit is contained in:
@@ -25,6 +25,7 @@ public class SpiralStaircase : MonoBehaviour
|
||||
public int Turns;
|
||||
public float TotalAngle;
|
||||
[Range(0, 1)] public float Progression;
|
||||
[Range(0, 1)] public float TotalProgression;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
@@ -43,6 +44,15 @@ public class SpiralStaircase : MonoBehaviour
|
||||
public float Offset = -12.25f;
|
||||
public float StartAngle = 450;
|
||||
public float EndAngle = 720;
|
||||
public float AdditionalTopAngle = 360;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class HallucinationTrigger
|
||||
{
|
||||
[Range(0, 1)] public float Progression;
|
||||
public UnityEvent OnReached;
|
||||
[HideInInspector] public bool Triggered;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
@@ -51,6 +61,7 @@ public class SpiralStaircase : MonoBehaviour
|
||||
public UnityEvent<bool> OnInside;
|
||||
public UnityEvent OnTopReached;
|
||||
public UnityEvent OnBottomReached;
|
||||
public HallucinationTrigger[] HallucinationTriggers;
|
||||
}
|
||||
|
||||
[SerializeField, OctoReadOnly] private State _state;
|
||||
@@ -60,6 +71,8 @@ public class SpiralStaircase : MonoBehaviour
|
||||
|
||||
private List<IEnumerator> _doorsCoroutine;
|
||||
|
||||
private float _entryAngle = 0f;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_doorsCoroutine = new List<IEnumerator>();
|
||||
@@ -87,6 +100,7 @@ public class SpiralStaircase : MonoBehaviour
|
||||
|
||||
void OnTriggerEnter(Collider col)
|
||||
{
|
||||
_entryAngle = _state.TotalAngle;
|
||||
if (OctoPlayer.Instance && OctoPlayer.Instance.gameObject == col.gameObject)
|
||||
{
|
||||
if (!_state.PlayerInside)
|
||||
@@ -205,6 +219,23 @@ public class SpiralStaircase : MonoBehaviour
|
||||
|
||||
_state.Progression = progression;
|
||||
|
||||
_state.TotalProgression = Mathf.Clamp01(
|
||||
Mathf.InverseLerp(_entryAngle, _settings.EndAngle + _settings.AdditionalTopAngle, _state.TotalAngle)
|
||||
);
|
||||
|
||||
foreach (var trigger in _events.HallucinationTriggers)
|
||||
{
|
||||
if (!trigger.Triggered && _state.TotalProgression >= trigger.Progression)
|
||||
{
|
||||
trigger.Triggered = true;
|
||||
trigger.OnReached?.Invoke();
|
||||
}
|
||||
else if (trigger.Triggered && _state.TotalProgression < trigger.Progression)
|
||||
{
|
||||
trigger.Triggered = false;
|
||||
}
|
||||
}
|
||||
|
||||
_references.Stairs.transform.localPosition = new Vector3(0, _state.Progression * _settings.Offset, 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user