added Radio model, npc correctly speaks when interacting with elements
This commit is contained in:
@@ -4,6 +4,9 @@ using UnityEngine;
|
||||
|
||||
public class ComputerPrinter : MonoBehaviour
|
||||
{
|
||||
public delegate void OnImagePrintedDelegate();
|
||||
public event OnImagePrintedDelegate OnImagePrinted;
|
||||
|
||||
public TextMeshProUGUI textDisplay;
|
||||
public PushableButton enterKey;
|
||||
public Transform ejectionOrigin;
|
||||
@@ -37,6 +40,7 @@ public class ComputerPrinter : MonoBehaviour
|
||||
Rigidbody printableRigidbody = printable.GetComponent<Rigidbody>();
|
||||
printableRigidbody.isKinematic = false;
|
||||
enterKey.Deactivate();
|
||||
OnImagePrinted?.Invoke();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ using UnityEngine.XR.Interaction.Toolkit;
|
||||
|
||||
public class Printer3DInputHole : MonoBehaviour
|
||||
{
|
||||
public delegate void OnPlayerInsertedPrintableDelegate();
|
||||
public event OnPlayerInsertedPrintableDelegate OnPlayerInsertedPrintable;
|
||||
|
||||
public Printer3D printer;
|
||||
public XRInteractionManager interactionManager;
|
||||
public Transform insertionOrigin;
|
||||
@@ -37,6 +40,7 @@ public class Printer3DInputHole : MonoBehaviour
|
||||
{
|
||||
ReleaseFromPlayer(printable);
|
||||
InsertPrintable(printable);
|
||||
OnPlayerInsertedPrintable?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
|
||||
@@ -7,11 +6,18 @@ public class RadioTransmitter : XRGrabInteractable
|
||||
{
|
||||
public delegate void OnPlayerPickUpDelegate();
|
||||
public event OnPlayerPickUpDelegate OnPlayerPickUp;
|
||||
public delegate void OnPlayerFinishedSpeakingDelegate();
|
||||
public event OnPlayerFinishedSpeakingDelegate OnPlayerFinishedSpeaking;
|
||||
|
||||
[Header("Custom Config")]
|
||||
public FMODWhisperBridge fmodWhisperBridge;
|
||||
public PushableButton radioButton;
|
||||
public TextMeshProUGUI computerScreen;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
radioButton.OnButtonPressed += OnRadioButtonPressed;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -25,4 +31,23 @@ public class RadioTransmitter : XRGrabInteractable
|
||||
base.OnSelectEntered(args);
|
||||
OnPlayerPickUp?.Invoke();
|
||||
}
|
||||
|
||||
private void OnRadioButtonPressed()
|
||||
{
|
||||
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated;
|
||||
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject);
|
||||
fmodWhisperBridge.ActivateRecording();
|
||||
// TODO: deactivate when button is released
|
||||
}
|
||||
|
||||
private void OnPlayerSpeechUpdated(string text)
|
||||
{
|
||||
computerScreen.text = text;
|
||||
}
|
||||
|
||||
private void OnPlayerSpeechFinished(string playerText)
|
||||
{
|
||||
OnPlayerFinishedSpeaking?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user