Add Table, taking orders require player present
This commit is contained in:
+35
-6
@@ -3,10 +3,11 @@ extends StaticBody3D
|
|||||||
|
|
||||||
const GAME_MANAGER = preload("res://GameManager.gd")
|
const GAME_MANAGER = preload("res://GameManager.gd")
|
||||||
|
|
||||||
@export var thinking_duration: float = 3.0
|
@export var thinking_duration: float = 5.0
|
||||||
@export var primary_duration: float = 60.0
|
@export var ordering_duration: float = 40.0
|
||||||
|
@export var primary_duration: float = 40.0
|
||||||
@export var friend_duration: float = 10.0
|
@export var friend_duration: float = 10.0
|
||||||
@export var eating_duration: float = 4.0
|
@export var eating_duration: float = 5.0
|
||||||
@export var money_sound: AudioStream
|
@export var money_sound: AudioStream
|
||||||
|
|
||||||
@onready var label_3d: Label3D = $Label3D
|
@onready var label_3d: Label3D = $Label3D
|
||||||
@@ -14,8 +15,11 @@ const GAME_MANAGER = preload("res://GameManager.gd")
|
|||||||
@onready var snap_zones: Array[XRToolsSnapZone] = []
|
@onready var snap_zones: Array[XRToolsSnapZone] = []
|
||||||
@onready var progress_bar: ProgressBar3D = $ProgressBar3D
|
@onready var progress_bar: ProgressBar3D = $ProgressBar3D
|
||||||
@onready var audio_player: AudioStreamPlayer3D = $AudioStreamPlayer3D
|
@onready var audio_player: AudioStreamPlayer3D = $AudioStreamPlayer3D
|
||||||
|
@onready var customers: Node3D = $Customers
|
||||||
|
@onready var player_detect_area_3d: Area3D = $PlayerDetectArea3D
|
||||||
|
|
||||||
const lbl_thinking: String = "Thinking"
|
const lbl_thinking: String = "..."
|
||||||
|
const lbl_ordering: String = "!"
|
||||||
const lbl_gameover: String = "Game Over!"
|
const lbl_gameover: String = "Game Over!"
|
||||||
const lbl_eating: String = "Eating..."
|
const lbl_eating: String = "Eating..."
|
||||||
|
|
||||||
@@ -24,6 +28,7 @@ const lbl_eating: String = "Eating..."
|
|||||||
enum TableState {
|
enum TableState {
|
||||||
EMPTY, # Just finished eating or havent eaten yet
|
EMPTY, # Just finished eating or havent eaten yet
|
||||||
THINKING,
|
THINKING,
|
||||||
|
ORDERING, # Wating for player to take their order
|
||||||
WAITING_PRIMARY, # Inital wait to be served
|
WAITING_PRIMARY, # Inital wait to be served
|
||||||
WAITING_FRIEND, # Waiting for friends food to arrive
|
WAITING_FRIEND, # Waiting for friends food to arrive
|
||||||
EATING
|
EATING
|
||||||
@@ -68,6 +73,7 @@ func _ready() -> void:
|
|||||||
for snap_zone_node in snap_zones:
|
for snap_zone_node in snap_zones:
|
||||||
snap_zone_node.has_picked_up.connect(_on_object_picked_up)
|
snap_zone_node.has_picked_up.connect(_on_object_picked_up)
|
||||||
snap_zone_node.has_dropped.connect(_on_object_dropped)
|
snap_zone_node.has_dropped.connect(_on_object_dropped)
|
||||||
|
player_detect_area_3d.body_entered.connect(_on_player_detected)
|
||||||
set_process(true)
|
set_process(true)
|
||||||
_setState(TableState.EMPTY)
|
_setState(TableState.EMPTY)
|
||||||
|
|
||||||
@@ -83,6 +89,14 @@ func _on_object_dropped() -> void:
|
|||||||
print("Table: object dropped ")
|
print("Table: object dropped ")
|
||||||
|
|
||||||
|
|
||||||
|
func _on_player_detected(player):
|
||||||
|
print("Table _on_player_detected(), ", player)
|
||||||
|
if _state != TableState.ORDERING:
|
||||||
|
return
|
||||||
|
|
||||||
|
place_order()
|
||||||
|
_set_state(TableState.WAITING_PRIMARY)
|
||||||
|
|
||||||
func _get_plate_from_item(_item: Node) -> PlateController:
|
func _get_plate_from_item(_item: Node) -> PlateController:
|
||||||
return _item.get_children().filter(func(c): return c is PlateController).front() as PlateController
|
return _item.get_children().filter(func(c): return c is PlateController).front() as PlateController
|
||||||
|
|
||||||
@@ -112,6 +126,7 @@ func _absorb_item_if_correct(_item: Node) -> void:
|
|||||||
_setState(TableState.EATING)
|
_setState(TableState.EATING)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func place_order() -> void:
|
func place_order() -> void:
|
||||||
print("Table: place_order()")
|
print("Table: place_order()")
|
||||||
var new_orders = _unsatisfied_orders.duplicate()
|
var new_orders = _unsatisfied_orders.duplicate()
|
||||||
@@ -154,9 +169,13 @@ func _setState(newState: TableState) -> void:
|
|||||||
TableState.EMPTY:
|
TableState.EMPTY:
|
||||||
_state_time = 5.0
|
_state_time = 5.0
|
||||||
_state_duration = 5.0
|
_state_duration = 5.0
|
||||||
|
customers.visible = false
|
||||||
TableState.THINKING:
|
TableState.THINKING:
|
||||||
_state_time = thinking_duration
|
_state_time = thinking_duration
|
||||||
_state_duration = thinking_duration # Can't be done in _set_state(), will set duration inside timer
|
_state_duration = thinking_duration # Can't be done in _set_state(), will set duration inside timer
|
||||||
|
TableState.ORDERING:
|
||||||
|
_state_time = ordering_duration
|
||||||
|
_state_duration = ordering_duration
|
||||||
TableState.WAITING_PRIMARY:
|
TableState.WAITING_PRIMARY:
|
||||||
_state_time = primary_duration
|
_state_time = primary_duration
|
||||||
_state_duration = primary_duration
|
_state_duration = primary_duration
|
||||||
@@ -188,6 +207,10 @@ func _refresh_display() -> void:
|
|||||||
TableState.THINKING:
|
TableState.THINKING:
|
||||||
progress_bar.set_bar_visible(false)
|
progress_bar.set_bar_visible(false)
|
||||||
label_3d.text = lbl_thinking
|
label_3d.text = lbl_thinking
|
||||||
|
TableState.ORDERING:
|
||||||
|
progress_bar.set_bar_visible(true)
|
||||||
|
progress_bar.override_fill_color(Color.RED if _state_time < 10 else Color.YELLOW)
|
||||||
|
label_3d.text = lbl_ordering
|
||||||
TableState.WAITING_PRIMARY:
|
TableState.WAITING_PRIMARY:
|
||||||
label_3d.text = "%s\n%s" % [TableState.keys()[_state], "\n".join(_unsatisfied_orders)]
|
label_3d.text = "%s\n%s" % [TableState.keys()[_state], "\n".join(_unsatisfied_orders)]
|
||||||
progress_bar.set_bar_visible(true)
|
progress_bar.set_bar_visible(true)
|
||||||
@@ -232,12 +255,18 @@ func _process(delta: float) -> void:
|
|||||||
match _state:
|
match _state:
|
||||||
TableState.EMPTY:
|
TableState.EMPTY:
|
||||||
print("Table State EMPTY finish")
|
print("Table State EMPTY finish")
|
||||||
|
customers.visible = true
|
||||||
_setState(TableState.THINKING)
|
_setState(TableState.THINKING)
|
||||||
|
|
||||||
TableState.THINKING:
|
TableState.THINKING:
|
||||||
print("Table State THINKING finish")
|
print("Table State THINKING finish")
|
||||||
place_order()
|
_setState(TableState.ORDERING)
|
||||||
_setState(TableState.WAITING_PRIMARY)
|
|
||||||
|
TableState.ORDERING:
|
||||||
|
print("Table State ORDERING finish")
|
||||||
|
label_3d.text = lbl_gameover
|
||||||
|
GAME_MANAGER.game_over()
|
||||||
|
|
||||||
|
|
||||||
TableState.WAITING_PRIMARY:
|
TableState.WAITING_PRIMARY:
|
||||||
print("Table State WAITING_PRIMARY finish")
|
print("Table State WAITING_PRIMARY finish")
|
||||||
|
|||||||
+13
-4
@@ -1,10 +1,10 @@
|
|||||||
[gd_scene format=3 uid="uid://caf0xanmxbshy"]
|
[gd_scene format=3 uid="uid://caf0xanmxbshy"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://caeikc7e3igkd" path="res://Stations/table.gd" id="1_2vcpj"]
|
[ext_resource type="Script" uid="uid://caeikc7e3igkd" path="res://stations/table.gd" id="1_2vcpj"]
|
||||||
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="1_8j1nt"]
|
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="1_8j1nt"]
|
||||||
[ext_resource type="AudioStream" uid="uid://clkjwcawdqvta" path="res://Sounds/money.mp3" id="2_jslhm"]
|
[ext_resource type="AudioStream" uid="uid://clkjwcawdqvta" path="res://sounds/money.mp3" id="2_jslhm"]
|
||||||
[ext_resource type="AudioStream" uid="uid://daiv8ubwdbidf" path="res://Sounds/220195__gameaudio__click-wooden-1.wav" id="3_0s6ir"]
|
[ext_resource type="AudioStream" uid="uid://daiv8ubwdbidf" path="res://sounds/220195__gameaudio__click-wooden-1.wav" id="3_0s6ir"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bxbocxdaayvwx" path="res://UI/progress_bar.tscn" id="3_kjf1i"]
|
[ext_resource type="PackedScene" uid="uid://bxbocxdaayvwx" path="res://ui/progress_bar.tscn" id="3_kjf1i"]
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_24d3s"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_24d3s"]
|
||||||
size = Vector3(0.6, 1, 0.6)
|
size = Vector3(0.6, 1, 0.6)
|
||||||
@@ -26,6 +26,9 @@ properties/2/path = NodePath(".:_unsatisfied_orders")
|
|||||||
properties/2/spawn = true
|
properties/2/spawn = true
|
||||||
properties/2/replication_mode = 1
|
properties/2/replication_mode = 1
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_vlqg6"]
|
||||||
|
size = Vector3(2.1, 0.5, 2.1)
|
||||||
|
|
||||||
[node name="Table" type="StaticBody3D" unique_id=1863572470 groups=["station"]]
|
[node name="Table" type="StaticBody3D" unique_id=1863572470 groups=["station"]]
|
||||||
script = ExtResource("1_2vcpj")
|
script = ExtResource("1_2vcpj")
|
||||||
money_sound = ExtResource("2_jslhm")
|
money_sound = ExtResource("2_jslhm")
|
||||||
@@ -198,3 +201,9 @@ y_billboard = true
|
|||||||
|
|
||||||
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="." unique_id=724610642]
|
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="." unique_id=724610642]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.2935008, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.2935008, 0)
|
||||||
|
|
||||||
|
[node name="PlayerDetectArea3D" type="Area3D" parent="." unique_id=913445150]
|
||||||
|
collision_mask = 524288
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="PlayerDetectArea3D" unique_id=1538221021]
|
||||||
|
shape = SubResource("BoxShape3D_vlqg6")
|
||||||
|
|||||||
Reference in New Issue
Block a user