forked from cgvr/DeltaVR
cafe waiter NPC goes and brings food after dialogue
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -166,7 +166,7 @@ MonoBehaviour:
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
m_PresetInfoIsWorld: 0
|
||||
m_PresetInfoIsWorld: 1
|
||||
--- !u!114 &6105090838799004608
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -204,9 +204,12 @@ MonoBehaviour:
|
||||
- Chef/Ulrich_Get_Correctly
|
||||
- Chef/Ulrich_Excellent
|
||||
- Chef/Ulrich_Terribly_Sorry_1
|
||||
notepadText: {fileID: 0}
|
||||
notepadTransform: {fileID: 0}
|
||||
- Chef/Ulrich_Enjoy
|
||||
fmodWhisperBridge: {fileID: 0}
|
||||
notepadText: {fileID: 0}
|
||||
notepad: {fileID: 0}
|
||||
backRoom: {fileID: 0}
|
||||
backRoomMovingTime: 5
|
||||
--- !u!114 &7699707098595015193
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
Binary file not shown.
@@ -4,17 +4,23 @@ using UnityEngine;
|
||||
|
||||
public class CafeWaiterNPC : NPCController
|
||||
{
|
||||
public TextMeshProUGUI notepadText;
|
||||
public Transform notepadTransform;
|
||||
public FMODWhisperBridge fmodWhisperBridge;
|
||||
public TextMeshProUGUI notepadText;
|
||||
public GameObject notepad;
|
||||
|
||||
public Transform backRoom;
|
||||
public float backRoomMovingTime = 5f;
|
||||
|
||||
private Vector3 notepadOriginalRotation;
|
||||
private Vector3 notepadFlippedRotation;
|
||||
private Vector3 startingPosition;
|
||||
|
||||
// states:
|
||||
// 0 - waiting for player order
|
||||
// 1 - waiting for player to answer "is this correct?"
|
||||
// 2 - bringing food
|
||||
// 0 - idle
|
||||
// 1 - waiting for player order
|
||||
// 2 - waiting for player to answer "is this correct?"
|
||||
// 3 - bringing food
|
||||
// 4 - waiting for player to go away
|
||||
private int state;
|
||||
private float lastPlayerVoiceUpdateTime;
|
||||
|
||||
@@ -22,29 +28,40 @@ public class CafeWaiterNPC : NPCController
|
||||
{
|
||||
state = 0;
|
||||
lastPlayerVoiceUpdateTime = Time.time;
|
||||
startingPosition = transform.position;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
notepadOriginalRotation = notepadTransform.localRotation.eulerAngles;
|
||||
notepadOriginalRotation = notepad.transform.localRotation.eulerAngles;
|
||||
notepadFlippedRotation = notepadOriginalRotation + new Vector3(0, 180, 0);
|
||||
}
|
||||
|
||||
protected override void OnPlayerApproach()
|
||||
{
|
||||
AudioManager.Instance.PlayDialogue(voiceLineKeys[0], gameObject);
|
||||
if (state == 0)
|
||||
{
|
||||
AudioManager.Instance.PlayDialogue(voiceLineKeys[0], gameObject);
|
||||
|
||||
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdate;
|
||||
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
|
||||
fmodWhisperBridge.ActivateRecording();
|
||||
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdate;
|
||||
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
|
||||
fmodWhisperBridge.ActivateRecording();
|
||||
|
||||
state = 1;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPlayerLeave()
|
||||
{
|
||||
//AudioManager.Instance.PlayDialogue(voiceLineKeys[1], gameObject);
|
||||
fmodWhisperBridge.OnWhisperSegmentUpdated -= OnPlayerSpeechUpdate;
|
||||
fmodWhisperBridge.OnWhisperSegmentFinished -= OnPlayerSpeechFinished;
|
||||
fmodWhisperBridge.DeactivateRecording();
|
||||
|
||||
// If currently not bringing food and the player leaves, then go back to idle state
|
||||
if (state != 3)
|
||||
{
|
||||
state = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPlayerSpeechFinished(string playerText)
|
||||
@@ -62,26 +79,27 @@ public class CafeWaiterNPC : NPCController
|
||||
lastPlayerVoiceUpdateTime = Time.time;
|
||||
Debug.Log("state = " + state.ToString() + ", voiceline: player text: " + playerText);
|
||||
|
||||
if (state == 0)
|
||||
if (state == 1)
|
||||
{
|
||||
// Show transcription and ask whether it is correct
|
||||
notepadText.text = playerText;
|
||||
notepadTransform.DOLocalRotate(notepadFlippedRotation, 0.5f);
|
||||
notepad.transform.DOLocalRotate(notepadFlippedRotation, 0.5f);
|
||||
AudioManager.Instance.PlayDialogue(voiceLineKeys[1], gameObject);
|
||||
state = 1;
|
||||
} else if (state == 1)
|
||||
state = 2;
|
||||
} else if (state == 2)
|
||||
{
|
||||
// Flip notepad back
|
||||
notepadTransform.DOLocalRotate(notepadOriginalRotation, 0.5f);
|
||||
notepad.transform.DOLocalRotate(notepadOriginalRotation, 0.5f);
|
||||
// if player answered positively, bring food, otherwise ask again
|
||||
if (playerText.ToLower().Contains("yes"))
|
||||
{
|
||||
AudioManager.Instance.PlayDialogue(voiceLineKeys[2], gameObject);
|
||||
state = 2;
|
||||
BringFood();
|
||||
state = 3;
|
||||
} else
|
||||
{
|
||||
AudioManager.Instance.PlayDialogue(voiceLineKeys[3], gameObject);
|
||||
state = 0;
|
||||
state = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,4 +112,20 @@ public class CafeWaiterNPC : NPCController
|
||||
}
|
||||
notepadText.text = playerText;
|
||||
}
|
||||
|
||||
private void BringFood()
|
||||
{
|
||||
notepad.SetActive(false);
|
||||
transform.DOMove(backRoom.position, backRoomMovingTime).OnComplete(() =>
|
||||
{
|
||||
// Come back
|
||||
transform.DOMove(startingPosition, backRoomMovingTime).OnComplete(() =>
|
||||
{
|
||||
notepad.SetActive(true);
|
||||
AudioManager.Instance.PlayDialogue(voiceLineKeys[4], gameObject);
|
||||
|
||||
state = 4;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user