glass layer occlusion, previous event occlusion changes, locomotaion steps change, ui hovers (for some reason currently play when a new location is set)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -10,34 +11,38 @@ public class ContinuoslocomotionConfigurator : MonoBehaviour
|
||||
public Button turnOnButton;
|
||||
public ContinuousMoveProviderBase locomotion;
|
||||
|
||||
// Events for listeners
|
||||
public event Action<bool> OnLocomotionToggled; // true = enabled, false = disabled
|
||||
public event Action<float> OnSpeedChanged; // sends new speed
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
turnOnButton.onClick.AddListener(enableLocomotion);
|
||||
turnOffButton.onClick.AddListener(disableLocomotion);
|
||||
turnOffButton.gameObject.SetActive(false); // off by default
|
||||
turnOffButton.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void UpdateSpeed(float speed)
|
||||
{
|
||||
locomotion.moveSpeed = speed;
|
||||
OnSpeedChanged?.Invoke(speed);
|
||||
}
|
||||
|
||||
private void enableLocomotion()
|
||||
{
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, gameObject); //3d oneshot sound
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, gameObject);
|
||||
locomotion.enabled = true;
|
||||
turnOnButton.gameObject.SetActive(false);
|
||||
turnOffButton.gameObject.SetActive(true);
|
||||
OnLocomotionToggled?.Invoke(true);
|
||||
}
|
||||
|
||||
private void disableLocomotion()
|
||||
{
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, gameObject); //3d oneshot sound
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, gameObject);
|
||||
locomotion.enabled = false;
|
||||
turnOnButton.gameObject.SetActive(true);
|
||||
turnOffButton.gameObject.SetActive(false);
|
||||
OnLocomotionToggled?.Invoke(false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public class MenuTeleportButton : MonoBehaviour
|
||||
|
||||
public void SetStateSelected()
|
||||
{
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, gameObject);
|
||||
if (button != null && HoverSprite != null)
|
||||
{
|
||||
button.targetGraphic.GetComponent<Image>().sprite = HoverSprite;
|
||||
|
||||
@@ -7,20 +7,24 @@ public class TutorialAudioListener : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private TutorialController tutorialController;
|
||||
[SerializeField] private ContinuoslocomotionConfigurator locomotionConfigurator;
|
||||
|
||||
private InputAction moveAction;
|
||||
private InputAction turnAction;
|
||||
private TeleportationProvider teleportationProvider;
|
||||
|
||||
private float lastStepTime;
|
||||
[SerializeField] private float stepCooldown = 0.5f; // seconds between steps
|
||||
[SerializeField] private float baseStepCooldown = 0.5f; // base interval at speed = 1
|
||||
private float stepCooldown;
|
||||
private bool locomotionEnabled = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (tutorialController == null)
|
||||
{
|
||||
tutorialController = FindObjectOfType<TutorialController>();
|
||||
}
|
||||
|
||||
if (locomotionConfigurator == null)
|
||||
locomotionConfigurator = FindObjectOfType<ContinuoslocomotionConfigurator>();
|
||||
|
||||
if (tutorialController != null)
|
||||
{
|
||||
@@ -28,10 +32,8 @@ public class TutorialAudioListener : MonoBehaviour
|
||||
turnAction = tutorialController.turnProvider.rightHandSnapTurnAction.action;
|
||||
teleportationProvider = tutorialController.teleportProvider;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.LogError("[TutorialAudioListener] No TutorialController found!");
|
||||
}
|
||||
|
||||
stepCooldown = baseStepCooldown;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
@@ -44,6 +46,12 @@ public class TutorialAudioListener : MonoBehaviour
|
||||
|
||||
if (teleportationProvider != null)
|
||||
teleportationProvider.endLocomotion += OnTeleportEnd;
|
||||
|
||||
if (locomotionConfigurator != null)
|
||||
{
|
||||
locomotionConfigurator.OnLocomotionToggled += HandleLocomotionToggled;
|
||||
locomotionConfigurator.OnSpeedChanged += HandleSpeedChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@@ -56,31 +64,52 @@ public class TutorialAudioListener : MonoBehaviour
|
||||
|
||||
if (teleportationProvider != null)
|
||||
teleportationProvider.endLocomotion -= OnTeleportEnd;
|
||||
|
||||
if (locomotionConfigurator != null)
|
||||
{
|
||||
locomotionConfigurator.OnLocomotionToggled -= HandleLocomotionToggled;
|
||||
locomotionConfigurator.OnSpeedChanged -= HandleSpeedChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleLocomotionToggled(bool enabled)
|
||||
{
|
||||
locomotionEnabled = enabled;
|
||||
Debug.Log($"[TutorialAudioListener] Locomotion toggled: {enabled}");
|
||||
}
|
||||
|
||||
private void HandleSpeedChanged(float newSpeed)
|
||||
{
|
||||
// Invert proportionality: faster speed = shorter step interval
|
||||
float calculatedCooldown = baseStepCooldown / Mathf.Max(newSpeed, 0.01f);
|
||||
|
||||
// Clamp the result between 0.4 and 0.6 seconds
|
||||
stepCooldown = Mathf.Clamp(calculatedCooldown, 0.3f, 0.69f);
|
||||
|
||||
Debug.Log($"[TutorialAudioListener] Step cooldown adjusted: {stepCooldown}");
|
||||
}
|
||||
|
||||
private void OnMovePerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
// Only play a sound if enough time has passed since the last one
|
||||
if (!locomotionEnabled)
|
||||
return;
|
||||
|
||||
if (Time.time - lastStepTime < stepCooldown)
|
||||
return;
|
||||
|
||||
lastStepTime = Time.time;
|
||||
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.StepOverall, gameObject);
|
||||
}
|
||||
|
||||
private void OnTurnPerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.StepSpin, gameObject);
|
||||
//Debug.Log("[TutorialAudioListener] Turn sound played.");
|
||||
}
|
||||
|
||||
private void OnTeleportEnd(LocomotionSystem locomotionSystem)
|
||||
{
|
||||
//TeleportationListen plays the required sound. To play it here, unattach the TeleportationListen.cs script.
|
||||
|
||||
|
||||
//AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Steps, gameObject);
|
||||
//Debug.Log("[TutorialAudioListener] Teleport sound played.");
|
||||
// Optional: Uncomment if teleport should play sound
|
||||
// AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Steps, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user