rework : lighting & opti
This commit is contained in:
@@ -53,12 +53,19 @@ public class SpiralStaircase : MonoBehaviour
|
||||
[Min(7)] public int HalfTurns = 7;
|
||||
}
|
||||
|
||||
public enum ProgressionTriggerDirection
|
||||
{
|
||||
Up,
|
||||
Down,
|
||||
Both
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class HallucinationTrigger
|
||||
{
|
||||
[Range(0, 1)] public float Progression;
|
||||
public ProgressionTriggerDirection Direction = ProgressionTriggerDirection.Up;
|
||||
public UnityEvent OnReached;
|
||||
[HideInInspector] public bool Triggered;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
@@ -81,6 +88,7 @@ public class SpiralStaircase : MonoBehaviour
|
||||
private float _stairHeight;
|
||||
private float _startAngle;
|
||||
private float _endAngle;
|
||||
private bool _hasPreviousTotalProgression;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@@ -105,7 +113,7 @@ public class SpiralStaircase : MonoBehaviour
|
||||
|
||||
int lastIndex = _settings.HalfTurns / 2 - 3;
|
||||
|
||||
for (int i = 1; i < _settings.HalfTurns / 2 - 2; i++)
|
||||
for (int i = 1; i < _settings.HalfTurns / 2 - 2; i++)
|
||||
{
|
||||
GameObject obj = Instantiate(
|
||||
_references.WallMiddle,
|
||||
@@ -116,10 +124,10 @@ public class SpiralStaircase : MonoBehaviour
|
||||
_references.WallMiddle.transform.localPosition +
|
||||
Vector3.up * wallSegmentHeight * i;
|
||||
|
||||
if (i == lastIndex)
|
||||
if (i == lastIndex)
|
||||
{
|
||||
Vector3 scale = obj.transform.localScale;
|
||||
scale.y = 3f;
|
||||
scale.y = 3f;
|
||||
obj.transform.localScale = scale;
|
||||
}
|
||||
}
|
||||
@@ -134,6 +142,7 @@ public class SpiralStaircase : MonoBehaviour
|
||||
void OnDisable()
|
||||
{
|
||||
_state.PlayerInside = false;
|
||||
_hasPreviousTotalProgression = false;
|
||||
ManageInside();
|
||||
}
|
||||
|
||||
@@ -144,7 +153,6 @@ public class SpiralStaircase : MonoBehaviour
|
||||
Count();
|
||||
SetRtpc();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider col)
|
||||
@@ -155,6 +163,7 @@ public class SpiralStaircase : MonoBehaviour
|
||||
{
|
||||
_entryAngle = _state.TotalAngle - _settings.TotalProgressionOffset;
|
||||
_state.PlayerInside = true;
|
||||
_hasPreviousTotalProgression = false;
|
||||
ManageInside();
|
||||
}
|
||||
}
|
||||
@@ -167,6 +176,7 @@ public class SpiralStaircase : MonoBehaviour
|
||||
if (_state.PlayerInside)
|
||||
{
|
||||
_state.PlayerInside = false;
|
||||
_hasPreviousTotalProgression = false;
|
||||
ManageInside();
|
||||
}
|
||||
}
|
||||
@@ -193,7 +203,7 @@ public class SpiralStaircase : MonoBehaviour
|
||||
Quaternion originRotL = door.Left.transform.localRotation;
|
||||
Quaternion originRotR = door.Right.transform.localRotation;
|
||||
Quaternion targetRotL = Quaternion.Euler(0, open ? 0 : 13.1f, 0);
|
||||
Quaternion targetRotR = Quaternion.Euler(0, open ? 0 :-13.1f, 0);
|
||||
Quaternion targetRotR = Quaternion.Euler(0, open ? 0 : -13.1f, 0);
|
||||
|
||||
if (animate)
|
||||
{
|
||||
@@ -219,6 +229,7 @@ public class SpiralStaircase : MonoBehaviour
|
||||
_state.Progression = 0;
|
||||
_state.PlayerInside = true;
|
||||
_state.Quarters = (int)_endAngle / 90;
|
||||
_hasPreviousTotalProgression = false;
|
||||
Count();
|
||||
ManageInside();
|
||||
}
|
||||
@@ -228,6 +239,7 @@ public class SpiralStaircase : MonoBehaviour
|
||||
_state.Progression = 1;
|
||||
_state.PlayerInside = true;
|
||||
_state.Quarters = 0;
|
||||
_hasPreviousTotalProgression = false;
|
||||
Count();
|
||||
ManageInside();
|
||||
}
|
||||
@@ -268,22 +280,21 @@ public class SpiralStaircase : MonoBehaviour
|
||||
|
||||
_state.Progression = progression;
|
||||
|
||||
float previousTotalProgression = _state.TotalProgression;
|
||||
|
||||
_state.TotalProgression = Mathf.Clamp01(
|
||||
Mathf.InverseLerp(_entryAngle, _endAngle + _settings.TotalProgressionOffset, _state.TotalAngle)
|
||||
);
|
||||
|
||||
foreach (var trigger in _events.HallucinationTriggers)
|
||||
if (_hasPreviousTotalProgression)
|
||||
{
|
||||
if (!trigger.Triggered && _state.TotalProgression >= trigger.Progression)
|
||||
{
|
||||
trigger.Triggered = true;
|
||||
trigger.OnReached?.Invoke();
|
||||
}
|
||||
else if (trigger.Triggered && _state.TotalProgression < trigger.Progression)
|
||||
{
|
||||
trigger.Triggered = false;
|
||||
}
|
||||
}
|
||||
CheckHallucinationTriggers(previousTotalProgression, _state.TotalProgression);
|
||||
}
|
||||
else
|
||||
{
|
||||
_hasPreviousTotalProgression = true;
|
||||
}
|
||||
|
||||
Vector3 targetPosition = new Vector3(0, _state.Progression * _settings.HalfTurns * -_stairHeight, 0);
|
||||
Vector3 offset = targetPosition - _references.Stairs.transform.localPosition;
|
||||
|
||||
@@ -293,6 +304,34 @@ public class SpiralStaircase : MonoBehaviour
|
||||
OctoPlayer.Instance.Move(offset);
|
||||
}
|
||||
|
||||
private void CheckHallucinationTriggers(float previousTotalProgression, float currentTotalProgression)
|
||||
{
|
||||
if (_events.HallucinationTriggers == null) return;
|
||||
|
||||
foreach (var trigger in _events.HallucinationTriggers)
|
||||
{
|
||||
if (trigger == null) continue;
|
||||
|
||||
bool crossedUp =
|
||||
previousTotalProgression < trigger.Progression &&
|
||||
currentTotalProgression >= trigger.Progression;
|
||||
|
||||
bool crossedDown =
|
||||
previousTotalProgression > trigger.Progression &&
|
||||
currentTotalProgression <= trigger.Progression;
|
||||
|
||||
bool shouldTrigger =
|
||||
(trigger.Direction == ProgressionTriggerDirection.Up && crossedUp) ||
|
||||
(trigger.Direction == ProgressionTriggerDirection.Down && crossedDown) ||
|
||||
(trigger.Direction == ProgressionTriggerDirection.Both && (crossedUp || crossedDown));
|
||||
|
||||
if (shouldTrigger)
|
||||
{
|
||||
trigger.OnReached?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ManageInside()
|
||||
{
|
||||
foreach (GameObject obj in _references.Inside) obj.SetActive(_state.PlayerInside);
|
||||
@@ -322,4 +361,4 @@ public class SpiralStaircase : MonoBehaviour
|
||||
float rtpcValue = _state.TotalProgression;
|
||||
AKRESULT aKRESULT = AkSoundEngine.SetRTPCValue("BinauralFREQ_Rtpc", rtpcValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user