From e9df21161034488a3fb2c51a5abaf19f48493797 Mon Sep 17 00:00:00 2001 From: henrisel Date: Thu, 29 Jan 2026 18:12:39 +0200 Subject: [PATCH] cafe waiter NPC goes and brings food after dialogue --- .../Fonts & Materials/Anton SDF.asset | 4 +- .../Fonts & Materials/Bangers SDF.asset | 4 +- .../Electronic Highway Sign SDF.asset | 4 +- .../Fonts & Materials/Oswald Bold SDF.asset | 4 +- .../Fonts & Materials/Roboto-Bold SDF.asset | 4 +- .../Characters/CafeWaiterNPC.prefab | 9 ++- .../_PROJECT/Scenes/DeltaBuilding_base.unity | 4 +- .../ModeGeneration/NPCs/CafeWaiterNPC.cs | 70 ++++++++++++++----- 8 files changed, 70 insertions(+), 33 deletions(-) diff --git a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Anton SDF.asset b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Anton SDF.asset index 9cf711af..c9dd0c9d 100644 --- a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Anton SDF.asset +++ b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Anton SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3d5cfcffff8dff4e78b27660e504f3f3c7e33bc90635f4ecea5fba734cea9076 -size 8426 +oid sha256:f435fea6bc4a529088adc67c39d424661d38f0b31a26563def17099ade8650d9 +size 2108207 diff --git a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Bangers SDF.asset b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Bangers SDF.asset index 055312d5..50ff39ad 100644 --- a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Bangers SDF.asset +++ b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Bangers SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ac4bd078e59332a73dc638ec2b7000fdbf517dafcbcd0ab6cbf94a80f35c11c0 -size 8408 +oid sha256:1b47997e80ccff54c264647b610f7eba06fffb0fe3db9149b56941e37d000399 +size 2175673 diff --git a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Electronic Highway Sign SDF.asset b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Electronic Highway Sign SDF.asset index d3d2e36b..0dae27c8 100644 --- a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Electronic Highway Sign SDF.asset +++ b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Electronic Highway Sign SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0b91d586ea5e3b650560f7626572004d37022e69998298493bd3bbbc7458d132 -size 8542 +oid sha256:3e7333394bc81dcc9782e8b20cf713c3eb64ec6fb7a1a8ec04c8c95eab39b2eb +size 2107703 diff --git a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Oswald Bold SDF.asset b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Oswald Bold SDF.asset index 9faa918e..07970f95 100644 --- a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Oswald Bold SDF.asset +++ b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Oswald Bold SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ff2bdb2307f28ff2b530b718137e1ed00f259e234503999fcac6c2bbb5d4a114 -size 69162 +oid sha256:8cf664ff0017780087734b43fb4a0d55baf838e06eb7f1e2c59b390d9842ddfb +size 2169374 diff --git a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Roboto-Bold SDF.asset b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Roboto-Bold SDF.asset index a68c4fcc..1a3fe5ba 100644 --- a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Roboto-Bold SDF.asset +++ b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Roboto-Bold SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:900c4efa2bf9fcd7e1d63aa108bf9a1b371a08ee7d50f0c193b7a2aa57ab1b59 -size 687978 +oid sha256:1be748bdc6f2f96214a19513747b4ebe53f3e0507fd1d7dbb479811bd4ea84c5 +size 2787854 diff --git a/Assets/_PROJECT/Prefabs/ModelGeneration/Characters/CafeWaiterNPC.prefab b/Assets/_PROJECT/Prefabs/ModelGeneration/Characters/CafeWaiterNPC.prefab index fc71c219..4e3b12da 100644 --- a/Assets/_PROJECT/Prefabs/ModelGeneration/Characters/CafeWaiterNPC.prefab +++ b/Assets/_PROJECT/Prefabs/ModelGeneration/Characters/CafeWaiterNPC.prefab @@ -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 diff --git a/Assets/_PROJECT/Scenes/DeltaBuilding_base.unity b/Assets/_PROJECT/Scenes/DeltaBuilding_base.unity index d9c7b234..a8ec826d 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:3bba46d5de0e186b27be15ecf21dd2088cd8f54a4159048dba8aa119cb6e3aa0 -size 67952595 +oid sha256:06a13c179207c3b4326310b1e3395bf5c34c6df1a0ad7b90e5b674644ad29bcb +size 67953883 diff --git a/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/CafeWaiterNPC.cs b/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/CafeWaiterNPC.cs index 3fe8802a..c29443ac 100644 --- a/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/CafeWaiterNPC.cs +++ b/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/CafeWaiterNPC.cs @@ -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; + }); + }); + } }