forked from cgvr/DeltaVR
added Radio model, npc correctly speaks when interacting with elements
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* shape scanner peenikesemad kiired
|
||||
* 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
|
||||
* PC uus mudel, kus enter key liigub õigesti
|
||||
* PC uus mudel, kus enter key liigub õigesti + õige sound effect enter nupul
|
||||
* archery range:
|
||||
* kui midagi laeb (wire aktiivne), siis particle'id võiks voolata mööda toru
|
||||
* uued wire'id
|
||||
|
||||
Binary file not shown.
@@ -7,10 +7,10 @@ public class ShapeDetectionNPC : NPCController
|
||||
{
|
||||
[Header("Shape Detection Minigame Config")]
|
||||
public QuestMarker questMarker;
|
||||
public MicrophoneStand microphoneStand;
|
||||
public RadioTransmitter radio;
|
||||
public PushableButton imageGenerationButton;
|
||||
public PushableButton modelGenerationButton;
|
||||
public Transform computerKeyboardKey;
|
||||
public ComputerPrinter computerPrinter;
|
||||
public Printer3DInputHole printerInsertionHole;
|
||||
public Texture2D GeneratedTexture { get; private set; }
|
||||
public Image imageDisplay;
|
||||
public ShapeScanner shapeScanner;
|
||||
@@ -37,9 +37,9 @@ public class ShapeDetectionNPC : NPCController
|
||||
private void Start()
|
||||
{
|
||||
radio.OnPlayerPickUp += OnPlayerPickedUpRadio;
|
||||
microphoneStand.OnPlayerFinishedSpeaking += OnPlayerUsedMicrophone;
|
||||
imageGenerationButton.OnButtonPressed += OnPlayerPressedKeyboard;
|
||||
modelGenerationButton.OnButtonPressed += OnPlayerInitiatedPrinting;
|
||||
radio.OnPlayerFinishedSpeaking += OnPlayerSpokeIntoRadio;
|
||||
computerPrinter.OnImagePrinted += OnPlayerPrintedImage;
|
||||
printerInsertionHole.OnPlayerInsertedPrintable += OnPlayerInitiatedPrinting;
|
||||
}
|
||||
|
||||
protected async override void OnPlayerApproach()
|
||||
@@ -54,7 +54,7 @@ public class ShapeDetectionNPC : NPCController
|
||||
{
|
||||
state = 1;
|
||||
await CallPlayer();
|
||||
await Task.Delay(2000);
|
||||
await Task.Delay(1000);
|
||||
questMarker.MoveTo(radio.transform, true);
|
||||
}
|
||||
}
|
||||
@@ -94,36 +94,26 @@ public class ShapeDetectionNPC : NPCController
|
||||
SpeakVoiceLine(2, radio.gameObject, radioAmount);
|
||||
state = 2;
|
||||
await Task.Delay(5000);
|
||||
questMarker.MoveTo(microphoneStand.transform);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: replace microphone with radio
|
||||
private void OnPlayerUsedMicrophone()
|
||||
private void OnPlayerSpokeIntoRadio()
|
||||
{
|
||||
if (state == 2)
|
||||
{
|
||||
SpeakVoiceLine(3, radio.gameObject, radioAmount);
|
||||
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)
|
||||
{
|
||||
SpeakVoiceLine(4, radio.gameObject, radioAmount);
|
||||
state = 4;
|
||||
questMarker.MoveTo(modelGenerationButton.transform);
|
||||
modelGenerationButton.Deactivate();
|
||||
questMarker.MoveTo(printerInsertionHole.transform);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,13 +132,9 @@ public class ShapeDetectionNPC : NPCController
|
||||
GameObject spawnedObject = await ModelGenerationUtils.Instance.SpawnModel(encodedModel);
|
||||
|
||||
|
||||
modelGenerationButton.Deactivate();
|
||||
|
||||
if (state == 5)
|
||||
{
|
||||
state = 6;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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