forked from cgvr/DeltaVR
moved archery range model generation logic to npc script, added corresponding voicelines
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user