diff --git a/3d-generation-pipeline/README.md b/3d-generation-pipeline/README.md index b31e9ea1..6cbb44a7 100644 --- a/3d-generation-pipeline/README.md +++ b/3d-generation-pipeline/README.md @@ -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 diff --git a/Assets/_PROJECT/Scenes/DeltaBuilding_base.unity b/Assets/_PROJECT/Scenes/DeltaBuilding_base.unity index 96206036..e9395d15 100644 --- a/Assets/_PROJECT/Scenes/DeltaBuilding_base.unity +++ b/Assets/_PROJECT/Scenes/DeltaBuilding_base.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1fbaa95f53267a271c6f7fa0e1131d37353c2d63dd8e1a5cd68ad454c051d933 -size 68555645 +oid sha256:2d51c15e14fa0ff9278d97cdc5d86078271412014a9ebac38bc395f4a76a101a +size 68550602 diff --git a/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/ShapeDetectionNPC.cs b/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/ShapeDetectionNPC.cs index e31db2bc..adad8fbe 100644 --- a/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/ShapeDetectionNPC.cs +++ b/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/ShapeDetectionNPC.cs @@ -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); } } @@ -141,14 +131,10 @@ public class ShapeDetectionNPC : NPCController GameObject spawnedObject = await ModelGenerationUtils.Instance.SpawnModel(encodedModel); - - modelGenerationButton.Deactivate(); if (state == 5) { state = 6; } } - - } diff --git a/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/ComputerPrinter.cs b/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/ComputerPrinter.cs index 958118b7..5edfaca1 100644 --- a/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/ComputerPrinter.cs +++ b/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/ComputerPrinter.cs @@ -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(); printableRigidbody.isKinematic = false; enterKey.Deactivate(); + OnImagePrinted?.Invoke(); }); } } diff --git a/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/Printer3DInputHole.cs b/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/Printer3DInputHole.cs index 7860e373..7cc006e4 100644 --- a/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/Printer3DInputHole.cs +++ b/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/Printer3DInputHole.cs @@ -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(); } } } diff --git a/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/RadioTransmitter.cs b/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/RadioTransmitter.cs index 446fbbc8..abb1cf31 100644 --- a/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/RadioTransmitter.cs +++ b/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/RadioTransmitter.cs @@ -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(); + } }