Implement turn manager and TTS responses
This commit is contained in:
parent
d2f5914acd
commit
0cd6bd6cd0
11 changed files with 159 additions and 37 deletions
|
|
@ -1,4 +1,4 @@
|
|||
extends Node2D
|
||||
class_name AudienceManager extends Node2D
|
||||
|
||||
@export var desk: Desk
|
||||
@export var timer: Timer
|
||||
|
|
|
|||
11
audience_manager.tscn
Normal file
11
audience_manager.tscn
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://c1acpop6amvcl"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b1p0muntqup8a" path="res://audience_manager.gd" id="1_pl31w"]
|
||||
|
||||
[node name="AudienceManager" type="Node2D" node_paths=PackedStringArray("desk", "timer", "game_manager")]
|
||||
script = ExtResource("1_pl31w")
|
||||
desk = NodePath("")
|
||||
timer = NodePath("BidDelayTimer")
|
||||
game_manager = NodePath("")
|
||||
|
||||
[node name="BidDelayTimer" type="Timer" parent="."]
|
||||
4
desk.gd
4
desk.gd
|
|
@ -1,3 +1,7 @@
|
|||
class_name Desk extends Control
|
||||
|
||||
@export var numpad: Numpad
|
||||
@export var turn_manager: TurnManager
|
||||
|
||||
func _ready() -> void:
|
||||
numpad.turn_manager = turn_manager
|
||||
|
|
|
|||
69
desk.tscn
69
desk.tscn
|
|
@ -39,124 +39,137 @@ script = ExtResource("1_yugeg")
|
|||
numpad = NodePath("Numpad")
|
||||
|
||||
[node name="Gavel" type="Node2D" parent="."]
|
||||
position = Vector2(971, 563)
|
||||
script = ExtResource("1_ep8l3")
|
||||
|
||||
[node name="TextureButton" type="TextureButton" parent="Gavel"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
texture_normal = ExtResource("25_3ueqa")
|
||||
texture_pressed = ExtResource("26_e06cl")
|
||||
|
||||
[node name="Numpad" type="Node2D" parent="."]
|
||||
position = Vector2(638, 570)
|
||||
[node name="Numpad" type="Node2D" parent="." node_paths=PackedStringArray("progress_bar")]
|
||||
position = Vector2(640, 570)
|
||||
script = ExtResource("2_t5y75")
|
||||
progress_bar = NodePath("../ProgressBar")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Numpad"]
|
||||
texture = ExtResource("5_r8wvv")
|
||||
|
||||
[node name="0" parent="Numpad" instance=ExtResource("3_se7ci")]
|
||||
offset_left = -52.0
|
||||
offset_top = 85.0
|
||||
offset_right = 49.0
|
||||
offset_bottom = 133.0
|
||||
offset_left = -53.0
|
||||
offset_top = 60.0
|
||||
offset_right = 48.0
|
||||
offset_bottom = 108.0
|
||||
texture_normal = ExtResource("4_tm3w8")
|
||||
texture_pressed = ExtResource("6_d0do2")
|
||||
|
||||
[node name="1" parent="Numpad" instance=ExtResource("3_se7ci")]
|
||||
offset_left = -158.0
|
||||
offset_top = -90.0
|
||||
offset_top = -99.0
|
||||
offset_right = -57.0
|
||||
offset_bottom = -42.0
|
||||
offset_bottom = -51.0
|
||||
texture_normal = ExtResource("7_yugeg")
|
||||
texture_pressed = ExtResource("8_ky68s")
|
||||
button_value = 1
|
||||
|
||||
[node name="2" parent="Numpad" instance=ExtResource("3_se7ci")]
|
||||
offset_left = -53.0
|
||||
offset_top = -90.0
|
||||
offset_top = -99.0
|
||||
offset_right = 48.0
|
||||
offset_bottom = -42.0
|
||||
offset_bottom = -51.0
|
||||
texture_normal = ExtResource("9_jnk24")
|
||||
texture_pressed = ExtResource("10_v5y5a")
|
||||
button_value = 2
|
||||
|
||||
[node name="3" parent="Numpad" instance=ExtResource("3_se7ci")]
|
||||
offset_left = 53.0
|
||||
offset_top = -90.0
|
||||
offset_top = -99.0
|
||||
offset_right = 154.0
|
||||
offset_bottom = -42.0
|
||||
offset_bottom = -51.0
|
||||
texture_normal = ExtResource("11_dnpqj")
|
||||
texture_pressed = ExtResource("12_t3f8v")
|
||||
button_value = 3
|
||||
|
||||
[node name="4" parent="Numpad" instance=ExtResource("3_se7ci")]
|
||||
offset_left = -158.0
|
||||
offset_top = -33.0
|
||||
offset_top = -45.0
|
||||
offset_right = -57.0
|
||||
offset_bottom = 15.0
|
||||
offset_bottom = 3.0
|
||||
texture_normal = ExtResource("13_qtawj")
|
||||
texture_pressed = ExtResource("14_ndbkw")
|
||||
button_value = 4
|
||||
|
||||
[node name="5" parent="Numpad" instance=ExtResource("3_se7ci")]
|
||||
offset_left = -53.0
|
||||
offset_top = -33.0
|
||||
offset_top = -45.0
|
||||
offset_right = 48.0
|
||||
offset_bottom = 15.0
|
||||
offset_bottom = 3.0
|
||||
texture_normal = ExtResource("15_7517r")
|
||||
texture_pressed = ExtResource("16_mx6qw")
|
||||
button_value = 5
|
||||
|
||||
[node name="6" parent="Numpad" instance=ExtResource("3_se7ci")]
|
||||
offset_left = 53.0
|
||||
offset_top = -33.0
|
||||
offset_top = -45.0
|
||||
offset_right = 154.0
|
||||
offset_bottom = 15.0
|
||||
offset_bottom = 3.0
|
||||
texture_normal = ExtResource("17_8smoy")
|
||||
texture_pressed = ExtResource("18_0wwv4")
|
||||
button_value = 6
|
||||
|
||||
[node name="7" parent="Numpad" instance=ExtResource("3_se7ci")]
|
||||
offset_left = -158.0
|
||||
offset_top = 24.0
|
||||
offset_top = 8.0
|
||||
offset_right = -57.0
|
||||
offset_bottom = 72.0
|
||||
offset_bottom = 56.0
|
||||
texture_normal = ExtResource("19_8hhu5")
|
||||
texture_pressed = ExtResource("20_vlpsm")
|
||||
button_value = 7
|
||||
|
||||
[node name="8" parent="Numpad" instance=ExtResource("3_se7ci")]
|
||||
offset_left = -53.0
|
||||
offset_top = 24.0
|
||||
offset_top = 8.0
|
||||
offset_right = 48.0
|
||||
offset_bottom = 72.0
|
||||
offset_bottom = 56.0
|
||||
texture_normal = ExtResource("21_b3d1b")
|
||||
texture_pressed = ExtResource("22_s5h2f")
|
||||
button_value = 8
|
||||
|
||||
[node name="9" parent="Numpad" instance=ExtResource("3_se7ci")]
|
||||
offset_left = 53.0
|
||||
offset_top = 24.0
|
||||
offset_top = 9.0
|
||||
offset_right = 154.0
|
||||
offset_bottom = 72.0
|
||||
offset_bottom = 57.0
|
||||
texture_normal = ExtResource("23_wrs3y")
|
||||
texture_pressed = ExtResource("24_gi6o1")
|
||||
button_value = 9
|
||||
|
||||
[node name="Backspace" parent="Numpad" instance=ExtResource("3_se7ci")]
|
||||
offset_left = -158.0
|
||||
offset_top = 85.0
|
||||
offset_top = 60.0
|
||||
offset_right = -57.0
|
||||
offset_bottom = 133.0
|
||||
offset_bottom = 108.0
|
||||
texture_normal = ExtResource("25_3ueqa")
|
||||
texture_pressed = ExtResource("26_e06cl")
|
||||
button_value = 10
|
||||
|
||||
[node name="Submit" parent="Numpad" instance=ExtResource("3_se7ci")]
|
||||
offset_left = 54.0
|
||||
offset_top = 85.0
|
||||
offset_top = 61.0
|
||||
offset_right = 155.0
|
||||
offset_bottom = 133.0
|
||||
offset_bottom = 109.0
|
||||
texture_normal = ExtResource("27_unpof")
|
||||
texture_pressed = ExtResource("28_4l1rv")
|
||||
button_value = 11
|
||||
|
||||
[node name="ProgressBar" type="ProgressBar" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 477.0
|
||||
offset_top = 684.0
|
||||
offset_right = 804.0
|
||||
offset_bottom = 711.0
|
||||
fill_mode = 1
|
||||
show_percentage = false
|
||||
|
||||
[connection signal="button_down" from="Gavel/TextureButton" to="Gavel" method="_on_texture_button_button_down"]
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ var total_sales: int = 0
|
|||
|
||||
# state tracker for a given painting's auction
|
||||
var bidding_open: bool = false
|
||||
signal bidding_start
|
||||
|
||||
func _ready() -> void:
|
||||
paintings_total = randi_range(7,10)
|
||||
|
|
@ -24,6 +25,12 @@ func _ready() -> void:
|
|||
#if e <= paintings_total:
|
||||
#paintings.append()
|
||||
|
||||
#build out the initialization process, which should:
|
||||
# -- generate paintings and assign values
|
||||
# -- start the turn timer/auction timer
|
||||
# ---- also add an auction timer
|
||||
# -- have tts announcement of starting bid and start of auction
|
||||
|
||||
|
||||
print("You have " + str(paintings_total) + " paintings. Sell them for at least $" + str(target_sales) + " or face the consequences!")
|
||||
pass
|
||||
|
|
@ -35,4 +42,15 @@ func _on_gavel_gavel_hit():
|
|||
print("The new painting will start selling at $" + str(current_bid))
|
||||
else:
|
||||
total_sales = total_sales + current_bid
|
||||
paintings_sold += 1
|
||||
print("Congrats on selling your painting for $" + str(current_bid) + "! You have made $" + str(total_sales) + " so far.")
|
||||
|
||||
func destroy_painting():
|
||||
pass
|
||||
|
||||
func next_painting():
|
||||
pass
|
||||
|
||||
# OTHER THINGS TO ADD:
|
||||
# UI elements for score
|
||||
# Bark manager
|
||||
|
|
|
|||
19
main.tscn
19
main.tscn
|
|
@ -1,11 +1,12 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://dt4nq0nkmjiit"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://dt4nq0nkmjiit"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b5tcsve1oo5ht" path="res://game_manager.gd" id="1_ig7tw"]
|
||||
[ext_resource type="Texture2D" uid="uid://cvqsf1nlfqwpr" path="res://assets/background/background.png" id="1_lquwl"]
|
||||
[ext_resource type="PackedScene" uid="uid://bohp0o2smdkwe" path="res://desk.tscn" id="2_0xm2m"]
|
||||
[ext_resource type="Texture2D" uid="uid://cpj3xw8js3h3" path="res://assets/chairs/chairs_back.png" id="2_7mycd"]
|
||||
[ext_resource type="Texture2D" uid="uid://d03ot1f34pyhu" path="res://assets/chairs/chairs_front.png" id="3_272bh"]
|
||||
[ext_resource type="Script" uid="uid://b1p0muntqup8a" path="res://audience_manager.gd" id="6_7mycd"]
|
||||
[ext_resource type="PackedScene" uid="uid://c1acpop6amvcl" path="res://audience_manager.tscn" id="6_272bh"]
|
||||
[ext_resource type="PackedScene" uid="uid://b8key4hjaldui" path="res://turn_manager.tscn" id="7_272bh"]
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
||||
|
||||
|
|
@ -26,11 +27,15 @@ texture = ExtResource("3_272bh")
|
|||
[node name="GameManager" type="Node2D" parent="."]
|
||||
script = ExtResource("1_ig7tw")
|
||||
|
||||
[node name="Desk" parent="." instance=ExtResource("2_0xm2m")]
|
||||
[node name="Desk" parent="." node_paths=PackedStringArray("turn_manager") instance=ExtResource("2_0xm2m")]
|
||||
turn_manager = NodePath("../TurnManager")
|
||||
|
||||
[node name="AudienceManager" type="Node2D" parent="." node_paths=PackedStringArray("desk", "timer")]
|
||||
script = ExtResource("6_7mycd")
|
||||
[node name="AudienceManager" parent="." node_paths=PackedStringArray("desk", "game_manager") instance=ExtResource("6_272bh")]
|
||||
desk = NodePath("../Desk")
|
||||
timer = NodePath("BidDelayTimer")
|
||||
game_manager = NodePath("../GameManager")
|
||||
|
||||
[node name="BidDelayTimer" type="Timer" parent="AudienceManager"]
|
||||
[node name="TurnManager" parent="." node_paths=PackedStringArray("desk", "game_manager", "audience_manager") instance=ExtResource("7_272bh")]
|
||||
tts_sentence_speed = 4.5
|
||||
desk = NodePath("../Desk")
|
||||
game_manager = NodePath("../GameManager")
|
||||
audience_manager = NodePath("../AudienceManager")
|
||||
|
|
|
|||
10
numpad.gd
10
numpad.gd
|
|
@ -4,6 +4,13 @@ var numpad_buffer = Array()
|
|||
var proposed_ask: int
|
||||
signal ask_proposed
|
||||
|
||||
var turn_manager: TurnManager
|
||||
@export var progress_bar: ProgressBar
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
progress_bar.value = (turn_manager.timer.time_left/turn_manager.timer.wait_time) * 100
|
||||
print(str(progress_bar.value) + " " + str(turn_manager.timer.time_left) + " " + str(turn_manager.timer.wait_time))
|
||||
|
||||
# number entry function called by numbered button children
|
||||
func keypad_entry(entry: int):
|
||||
numpad_buffer.append(str(entry))
|
||||
|
|
@ -13,5 +20,6 @@ func keypad_backspace():
|
|||
|
||||
func keypad_submit():
|
||||
var keypad_output: String = "".join(numpad_buffer)
|
||||
proposed_ask = int(keypad_output)
|
||||
proposed_ask = int(keypad_output) * 1000
|
||||
ask_proposed.emit()
|
||||
numpad_buffer.clear()
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ run/main_scene="uid://dt4nq0nkmjiit"
|
|||
config/features=PackedStringArray("4.5", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[audio]
|
||||
|
||||
general/text_to_speech=true
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=1280
|
||||
|
|
@ -25,3 +29,4 @@ window/stretch/scale_mode="integer"
|
|||
[rendering]
|
||||
|
||||
textures/vram_compression/import_etc2_astc=true
|
||||
2d/snap/snap_2d_transforms_to_pixel=true
|
||||
|
|
|
|||
45
turn_manager.gd
Normal file
45
turn_manager.gd
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
class_name TurnManager extends Node2D
|
||||
|
||||
@export var turn_timer := 7.0
|
||||
@export var tts_number_speed = 7.0
|
||||
@export var tts_sentence_speed = 5.0
|
||||
@export var tts_volume = 75
|
||||
@export var tts_pitch = 1.0
|
||||
|
||||
@export var desk: Desk
|
||||
@export var timer: Timer
|
||||
@export var game_manager: GameManager
|
||||
@export var audience_manager: AudienceManager
|
||||
|
||||
var voices = DisplayServer.tts_get_voices_for_language("en")
|
||||
var voice_id = voices[0]
|
||||
|
||||
func _ready() -> void:
|
||||
DisplayServer.tts_speak("Hello, world!", voice_id)
|
||||
audience_manager.ask_accepted.connect(_handle_ask_accepted)
|
||||
desk.numpad.ask_proposed.connect(_speak_ask_proposed)
|
||||
timer.wait_time = turn_timer
|
||||
|
||||
func turn_timer_animation():
|
||||
pass
|
||||
|
||||
func _speak_ask_proposed():
|
||||
var speech_variance = randf()
|
||||
if speech_variance < 0.45:
|
||||
DisplayServer.tts_speak(str(desk.numpad.proposed_ask), voice_id, tts_volume, tts_pitch, tts_number_speed)
|
||||
elif speech_variance > 0.45 and speech_variance < 0.65:
|
||||
DisplayServer.tts_speak("Do I hear" + str(desk.numpad.proposed_ask), voice_id, tts_volume, tts_pitch, tts_sentence_speed)
|
||||
elif speech_variance > 0.65 and speech_variance < 0.8:
|
||||
DisplayServer.tts_speak(str(desk.numpad.proposed_ask) + ", anybody?", voice_id, tts_volume, tts_pitch, tts_sentence_speed)
|
||||
else:
|
||||
DisplayServer.tts_speak("Can I get a" + str(desk.numpad.proposed_ask), voice_id, tts_volume, tts_pitch, tts_sentence_speed)
|
||||
|
||||
func _handle_ask_accepted():
|
||||
timer.start()
|
||||
turn_timer_animation()
|
||||
|
||||
func _on_turn_timer_timeout() -> void:
|
||||
if game_manager.bidding_open == true:
|
||||
game_manager.bidding_open = false
|
||||
game_manager.destroy_painting()
|
||||
|
||||
1
turn_manager.gd.uid
Normal file
1
turn_manager.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ddslp2n284ils
|
||||
12
turn_manager.tscn
Normal file
12
turn_manager.tscn
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://b8key4hjaldui"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ddslp2n284ils" path="res://turn_manager.gd" id="1_u6owk"]
|
||||
|
||||
[node name="TurnManager" type="Node2D" node_paths=PackedStringArray("timer")]
|
||||
script = ExtResource("1_u6owk")
|
||||
timer = NodePath("TurnTimer")
|
||||
|
||||
[node name="TurnTimer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="timeout" from="TurnTimer" to="." method="_on_turn_timer_timeout"]
|
||||
Loading…
Add table
Reference in a new issue