forked from cgvr/DeltaVR
add pen, animate writing when npc listening to order
This commit is contained in:
@@ -7,8 +7,9 @@ using UnityEngine.XR.Interaction.Toolkit;
|
||||
public class CafeWaiterNPC : NPCController
|
||||
{
|
||||
public FMODWhisperBridge fmodWhisperBridge;
|
||||
public TextMeshProUGUI notepadText;
|
||||
public GameObject notepad;
|
||||
public TextMeshProUGUI notepadText;
|
||||
public PenWriter pen;
|
||||
|
||||
public Transform backRoom;
|
||||
public Transform plate;
|
||||
@@ -42,6 +43,7 @@ public class CafeWaiterNPC : NPCController
|
||||
notepadOriginalRotation = notepad.transform.localRotation.eulerAngles;
|
||||
notepadFlippedRotation = notepadOriginalRotation + new Vector3(0, 180, 0);
|
||||
notepad.SetActive(false);
|
||||
pen.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
protected override void OnPlayerApproach()
|
||||
@@ -55,6 +57,7 @@ public class CafeWaiterNPC : NPCController
|
||||
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
|
||||
|
||||
notepad.SetActive(true);
|
||||
pen.gameObject.SetActive(true);
|
||||
state = 1;
|
||||
}
|
||||
}
|
||||
@@ -69,6 +72,8 @@ public class CafeWaiterNPC : NPCController
|
||||
if (state != 3)
|
||||
{
|
||||
notepad.SetActive(false);
|
||||
pen.StopWriting();
|
||||
pen.gameObject.SetActive(false);
|
||||
notepad.transform.localRotation = Quaternion.Euler(notepadOriginalRotation);
|
||||
state = 0;
|
||||
}
|
||||
@@ -87,6 +92,8 @@ public class CafeWaiterNPC : NPCController
|
||||
// Show transcription and ask whether it is correct
|
||||
fmodWhisperBridge.DeactivateRecording();
|
||||
notepadText.text = playerText;
|
||||
pen.StopWriting();
|
||||
pen.gameObject.SetActive(false);
|
||||
notepad.transform.DOLocalRotate(notepadFlippedRotation, 0.5f).OnComplete(() =>
|
||||
{
|
||||
fmodWhisperBridge.ActivateRecording();
|
||||
@@ -98,23 +105,25 @@ public class CafeWaiterNPC : NPCController
|
||||
} else if (state == 2)
|
||||
{
|
||||
fmodWhisperBridge.DeactivateRecording();
|
||||
bool positiveAnswer = playerText.ToLower().Contains("ye") || playerText.ToLower().Contains("correct") | playerText.ToLower().Contains("right");
|
||||
SpeakVoiceLine(positiveAnswer ? 2 : 3);
|
||||
// Flip notepad back
|
||||
notepad.transform.DOLocalRotate(notepadOriginalRotation, 0.5f);
|
||||
// if player answered positively, bring food, otherwise ask again
|
||||
if (playerText.ToLower().Contains("ye"))
|
||||
notepad.transform.DOLocalRotate(notepadOriginalRotation, 0.5f).OnComplete(() =>
|
||||
{
|
||||
|
||||
SpeakVoiceLine(2);
|
||||
Invoke("BringFood", 1f);
|
||||
state = 3;
|
||||
} else
|
||||
{
|
||||
SpeakVoiceLine(3);
|
||||
fmodWhisperBridge.ActivateRecording();
|
||||
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated;
|
||||
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
|
||||
state = 1;
|
||||
}
|
||||
if (positiveAnswer)
|
||||
{
|
||||
Invoke("BringFood", 1f);
|
||||
state = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
fmodWhisperBridge.ActivateRecording();
|
||||
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated;
|
||||
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
|
||||
pen.gameObject.SetActive(true);
|
||||
state = 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,10 +132,8 @@ public class CafeWaiterNPC : NPCController
|
||||
// Only update notepad text when currently listening to player order
|
||||
if (state == 1)
|
||||
{
|
||||
pen.StartWriting();
|
||||
notepadText.text = playerText;
|
||||
|
||||
// For now, when something is transcribed, treat it as player finished speaking
|
||||
OnPlayerSpeechFinished(playerText);
|
||||
}
|
||||
// faster reaction to player answering yes/no
|
||||
else if (state == 2)
|
||||
|
||||
Reference in New Issue
Block a user