1
0
forked from cgvr/DeltaVR

added Radio model, npc correctly speaks when interacting with elements

This commit is contained in:
2026-02-15 13:57:13 +02:00
parent 85df2ce45d
commit 8e606782ab
6 changed files with 50 additions and 31 deletions

View File

@@ -3,7 +3,7 @@
* shape scanner peenikesemad kiired * shape scanner peenikesemad kiired
* shape scanner mitte lihtsalt ontriggerenter ja -exit, sest kui mitu objekti lähevad samal ajal sisse * shape scanner mitte lihtsalt ontriggerenter ja -exit, sest kui mitu objekti lähevad samal ajal sisse
* shape scanner mustad kiired on halvasti nähtavad pruuni materjali taustal * shape scanner mustad kiired on halvasti nähtavad pruuni materjali taustal
* PC uus mudel, kus enter key liigub õigesti * PC uus mudel, kus enter key liigub õigesti + õige sound effect enter nupul
* archery range: * archery range:
* kui midagi laeb (wire aktiivne), siis particle'id võiks voolata mööda toru * kui midagi laeb (wire aktiivne), siis particle'id võiks voolata mööda toru
* uued wire'id * uued wire'id

View File

@@ -7,10 +7,10 @@ public class ShapeDetectionNPC : NPCController
{ {
[Header("Shape Detection Minigame Config")] [Header("Shape Detection Minigame Config")]
public QuestMarker questMarker; public QuestMarker questMarker;
public MicrophoneStand microphoneStand;
public RadioTransmitter radio; public RadioTransmitter radio;
public PushableButton imageGenerationButton; public Transform computerKeyboardKey;
public PushableButton modelGenerationButton; public ComputerPrinter computerPrinter;
public Printer3DInputHole printerInsertionHole;
public Texture2D GeneratedTexture { get; private set; } public Texture2D GeneratedTexture { get; private set; }
public Image imageDisplay; public Image imageDisplay;
public ShapeScanner shapeScanner; public ShapeScanner shapeScanner;
@@ -37,9 +37,9 @@ public class ShapeDetectionNPC : NPCController
private void Start() private void Start()
{ {
radio.OnPlayerPickUp += OnPlayerPickedUpRadio; radio.OnPlayerPickUp += OnPlayerPickedUpRadio;
microphoneStand.OnPlayerFinishedSpeaking += OnPlayerUsedMicrophone; radio.OnPlayerFinishedSpeaking += OnPlayerSpokeIntoRadio;
imageGenerationButton.OnButtonPressed += OnPlayerPressedKeyboard; computerPrinter.OnImagePrinted += OnPlayerPrintedImage;
modelGenerationButton.OnButtonPressed += OnPlayerInitiatedPrinting; printerInsertionHole.OnPlayerInsertedPrintable += OnPlayerInitiatedPrinting;
} }
protected async override void OnPlayerApproach() protected async override void OnPlayerApproach()
@@ -54,7 +54,7 @@ public class ShapeDetectionNPC : NPCController
{ {
state = 1; state = 1;
await CallPlayer(); await CallPlayer();
await Task.Delay(2000); await Task.Delay(1000);
questMarker.MoveTo(radio.transform, true); questMarker.MoveTo(radio.transform, true);
} }
} }
@@ -94,36 +94,26 @@ public class ShapeDetectionNPC : NPCController
SpeakVoiceLine(2, radio.gameObject, radioAmount); SpeakVoiceLine(2, radio.gameObject, radioAmount);
state = 2; state = 2;
await Task.Delay(5000); await Task.Delay(5000);
questMarker.MoveTo(microphoneStand.transform);
} }
} }
// TODO: replace microphone with radio private void OnPlayerSpokeIntoRadio()
private void OnPlayerUsedMicrophone()
{ {
if (state == 2) if (state == 2)
{ {
SpeakVoiceLine(3, radio.gameObject, radioAmount); SpeakVoiceLine(3, radio.gameObject, radioAmount);
state = 3; state = 3;
questMarker.MoveTo(imageGenerationButton.transform); questMarker.MoveTo(computerKeyboardKey);
} }
} }
private async void OnPlayerPressedKeyboard() private void OnPlayerPrintedImage()
{ {
//string inputPrompt = microphoneStand.GetTextOutput();
//byte[] imageBytes = await InvokeAiClient.Instance.GenerateImage(inputPrompt);
//GeneratedTexture = ModelGenerationUtils.CreateTexture(imageBytes);
//Sprite sprite = ModelGenerationUtils.CreateSprite(GeneratedTexture);
//imageDisplay.sprite = sprite;
imageGenerationButton.Deactivate();
if (state == 3) if (state == 3)
{ {
SpeakVoiceLine(4, radio.gameObject, radioAmount); SpeakVoiceLine(4, radio.gameObject, radioAmount);
state = 4; state = 4;
questMarker.MoveTo(modelGenerationButton.transform); questMarker.MoveTo(printerInsertionHole.transform);
modelGenerationButton.Deactivate();
} }
} }
@@ -142,13 +132,9 @@ public class ShapeDetectionNPC : NPCController
GameObject spawnedObject = await ModelGenerationUtils.Instance.SpawnModel(encodedModel); GameObject spawnedObject = await ModelGenerationUtils.Instance.SpawnModel(encodedModel);
modelGenerationButton.Deactivate();
if (state == 5) if (state == 5)
{ {
state = 6; state = 6;
} }
} }
} }

View File

@@ -4,6 +4,9 @@ using UnityEngine;
public class ComputerPrinter : MonoBehaviour public class ComputerPrinter : MonoBehaviour
{ {
public delegate void OnImagePrintedDelegate();
public event OnImagePrintedDelegate OnImagePrinted;
public TextMeshProUGUI textDisplay; public TextMeshProUGUI textDisplay;
public PushableButton enterKey; public PushableButton enterKey;
public Transform ejectionOrigin; public Transform ejectionOrigin;
@@ -37,6 +40,7 @@ public class ComputerPrinter : MonoBehaviour
Rigidbody printableRigidbody = printable.GetComponent<Rigidbody>(); Rigidbody printableRigidbody = printable.GetComponent<Rigidbody>();
printableRigidbody.isKinematic = false; printableRigidbody.isKinematic = false;
enterKey.Deactivate(); enterKey.Deactivate();
OnImagePrinted?.Invoke();
}); });
} }
} }

View File

@@ -4,6 +4,9 @@ using UnityEngine.XR.Interaction.Toolkit;
public class Printer3DInputHole : MonoBehaviour public class Printer3DInputHole : MonoBehaviour
{ {
public delegate void OnPlayerInsertedPrintableDelegate();
public event OnPlayerInsertedPrintableDelegate OnPlayerInsertedPrintable;
public Printer3D printer; public Printer3D printer;
public XRInteractionManager interactionManager; public XRInteractionManager interactionManager;
public Transform insertionOrigin; public Transform insertionOrigin;
@@ -37,6 +40,7 @@ public class Printer3DInputHole : MonoBehaviour
{ {
ReleaseFromPlayer(printable); ReleaseFromPlayer(printable);
InsertPrintable(printable); InsertPrintable(printable);
OnPlayerInsertedPrintable?.Invoke();
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using System.Collections; using TMPro;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit; using UnityEngine.XR.Interaction.Toolkit;
@@ -7,11 +6,18 @@ public class RadioTransmitter : XRGrabInteractable
{ {
public delegate void OnPlayerPickUpDelegate(); public delegate void OnPlayerPickUpDelegate();
public event OnPlayerPickUpDelegate OnPlayerPickUp; 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 // Start is called before the first frame update
void Start() void Start()
{ {
radioButton.OnButtonPressed += OnRadioButtonPressed;
} }
// Update is called once per frame // Update is called once per frame
@@ -25,4 +31,23 @@ public class RadioTransmitter : XRGrabInteractable
base.OnSelectEntered(args); base.OnSelectEntered(args);
OnPlayerPickUp?.Invoke(); 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();
}
} }