1
0
forked from cgvr/DeltaVR

moved archery range model generation logic to npc script, added corresponding voicelines

This commit is contained in:
2026-02-08 12:28:59 +02:00
parent 53295a60ed
commit dc55e8d884
12 changed files with 323 additions and 145 deletions

View File

@@ -8,9 +8,11 @@ public class MicrophoneStand : MonoBehaviour
public GameObject microphoneOffStatus;
public GameObject microphoneOnStatus;
public NPCController npcController;
public FMODWhisperBridge fmodWhisperBridge;
public delegate void OnPlayerFinishedSpeakingDelegate();
public event OnPlayerFinishedSpeakingDelegate OnPlayerFinishedSpeaking;
// Start is called before the first frame update
void Start()
{
@@ -31,16 +33,12 @@ public class MicrophoneStand : MonoBehaviour
if (controller != null || other.gameObject.tag == "Player Head")
{
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeech;
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeech;
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated;
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
microphoneOffStatus.SetActive(false);
microphoneOnStatus.SetActive(true);
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject);
if (npcController != null)
{
npcController.SpeakVoiceLine(1);
}
fmodWhisperBridge.ActivateRecording();
}
}
@@ -50,31 +48,29 @@ public class MicrophoneStand : MonoBehaviour
KbmController controller = other.GetComponent<KbmController>();
if (controller != null | other.gameObject.tag == "Player Head")
{
fmodWhisperBridge.OnWhisperSegmentUpdated -= OnPlayerSpeech;
fmodWhisperBridge.OnWhisperSegmentFinished -= OnPlayerSpeech;
fmodWhisperBridge.OnWhisperSegmentUpdated -= OnPlayerSpeechUpdated;
fmodWhisperBridge.OnWhisperSegmentFinished -= OnPlayerSpeechFinished;
microphoneOffStatus.SetActive(true);
microphoneOnStatus.SetActive(false);
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject);
if (npcController != null)
{
npcController.SpeakVoiceLine(2);
}
fmodWhisperBridge.DeactivateRecording();
}
}
private void OnPlayerSpeech(string text)
private void OnPlayerSpeechUpdated(string text)
{
if (string.IsNullOrEmpty(text) || text.Contains("BLANK_AUDIO"))
{
return;
}
outputText.text = text;
}
private void OnPlayerSpeechFinished(string playerText)
{
OnPlayerFinishedSpeaking?.Invoke();
}
public string GetTextOutput()
{
return outputText.text;
}
}