1
0
forked from cgvr/DeltaVR

cafe waiter brings food on a serving tray

This commit is contained in:
2026-03-05 12:27:38 +02:00
parent 73fad024c0
commit 22f6982c4c
12 changed files with 560 additions and 63 deletions

View File

@@ -6,20 +6,28 @@ using UnityEngine.XR.Interaction.Toolkit;
public class CafeWaiterNPC : NPCController
{
[Header("Delta Cafe Minigame Config")]
public FMODWhisperBridge fmodWhisperBridge;
public GameObject notepad;
public TextMeshProUGUI notepadText;
public PenWriter pen;
public Transform backRoom;
public Transform plate;
public float backRoomMovingTime = 5f;
public Transform servingTray;
public Transform servingTrayTop;
public Transform servingTrayFoodSpawnPoint;
public Transform servingTrayPresentingPosition;
public float servingTrayTopLiftAmount = 0.5f;
public float spawnedFoodDiameter = 0.5f;
public Transform backRoom;
public float backRoomMovingTime = 5f;
public int ignorePlayerCollisionLayer = 2;
private Vector3 notepadOriginalRotation;
private Vector3 notepadFlippedRotation;
private Vector3 servingTrayOriginalLocalPosition;
private Vector3 servingTrayTopOriginalLocalPosition;
private Vector3 startingPosition;
// states:
@@ -35,15 +43,18 @@ public class CafeWaiterNPC : NPCController
{
state = 0;
lastPlayerVoiceUpdateTime = Time.time;
startingPosition = transform.position;
}
private void Start()
{
startingPosition = transform.position;
notepadOriginalRotation = notepad.transform.localRotation.eulerAngles;
notepadFlippedRotation = notepadOriginalRotation + new Vector3(0, 180, 0);
servingTrayOriginalLocalPosition = servingTray.transform.localPosition;
servingTrayTopOriginalLocalPosition = servingTrayTop.localPosition;
notepad.SetActive(false);
pen.gameObject.SetActive(false);
servingTray.gameObject.SetActive(false);
}
protected override void OnPlayerApproach()
@@ -71,10 +82,16 @@ public class CafeWaiterNPC : NPCController
// If currently not bringing food and the player leaves, then go back to idle state
if (state != 3)
{
notepad.transform.localRotation = Quaternion.Euler(notepadOriginalRotation);
notepad.SetActive(false);
pen.StopWriting();
pen.gameObject.SetActive(false);
notepad.transform.localRotation = Quaternion.Euler(notepadOriginalRotation);
servingTray.parent = transform;
servingTray.localPosition = servingTrayOriginalLocalPosition;
servingTrayTop.localPosition = servingTrayTopOriginalLocalPosition;
servingTray.gameObject.SetActive(false);
state = 0;
}
}
@@ -157,14 +174,19 @@ public class CafeWaiterNPC : NPCController
GameObject spawnedObject = await ModelGenerationUtils.Instance.SpawnModel(encodedModel, spawnedFoodDiameter);
// Come back
servingTray.gameObject.SetActive(true);
transform.DOMove(startingPosition, backRoomMovingTime).OnComplete(() =>
{
spawnedObject.transform.position = plate.position + new Vector3(0, 1f, 0);
InitializeSpawnedObject(spawnedObject);
servingTray.parent = null;
servingTray.DOMove(servingTrayPresentingPosition.position, 1f).OnComplete(() =>
{
spawnedObject.transform.position = servingTrayFoodSpawnPoint.position;
InitializeSpawnedObject(spawnedObject);
servingTrayTop.DOLocalMove(servingTrayTop.localPosition + new Vector3(0, servingTrayTopLiftAmount, 0), 1f);
SpeakVoiceLine(4);
state = 4;
SpeakVoiceLine(4);
state = 4;
});
});
}

View File

@@ -1,31 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ButtonTrigger : MonoBehaviour
{
public bool isEnter;
public ReleasableButton button;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter(Collider other)
{
}
private void OnTriggerExit(Collider other)
{
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 26d1ade0a3771324eb46882393dce30a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: