Implement end of auction logic
This commit is contained in:
parent
a96ec6cc92
commit
523a18d29a
5 changed files with 41 additions and 15 deletions
|
|
@ -37,7 +37,7 @@ func raise_paddle():
|
||||||
|
|
||||||
|
|
||||||
func _handle_bid_delay_timeout():
|
func _handle_bid_delay_timeout():
|
||||||
if randf_range(1.2, 5.3) >= bid_threshold:
|
if randf_range(1.2, 5.3) >= bid_threshold and game_manager.state != game_manager.bidding_state.CLOSED:
|
||||||
raise_paddle()
|
raise_paddle()
|
||||||
|
|
||||||
timer.stop()
|
timer.stop()
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ class_name GameManager extends Node2D
|
||||||
|
|
||||||
@export var audience_manager: AudienceManager
|
@export var audience_manager: AudienceManager
|
||||||
@export var desk: Desk
|
@export var desk: Desk
|
||||||
|
@export var turn_manager: TurnManager
|
||||||
|
|
||||||
var paintings_sold = 0
|
var paintings_sold = 0
|
||||||
@export var paintings_total = 7
|
@export var paintings_total = 7
|
||||||
|
|
@ -46,7 +47,10 @@ func _ready() -> void:
|
||||||
|
|
||||||
print(paintings)
|
print(paintings)
|
||||||
print("You have " + str(paintings_total) + " paintings. Sell them for at least $" + str(target_sales) + " or face the consequences!")
|
print("You have " + str(paintings_total) + " paintings. Sell them for at least $" + str(target_sales) + " or face the consequences!")
|
||||||
print("Hit the gavel and input a starting bid to begin!")
|
print("Hit the gavel and input the starting price to begin!")
|
||||||
|
|
||||||
|
DisplayServer.tts_speak("You have " + str(paintings_total) + " paintings. Sell them fast for at least $" + str(target_sales) + " or face the consequences!", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch)
|
||||||
|
DisplayServer.tts_speak("Hit the gavel and input the starting price to begin!", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch)
|
||||||
|
|
||||||
next_painting(0)
|
next_painting(0)
|
||||||
#build out the initialization process, which should:
|
#build out the initialization process, which should:
|
||||||
|
|
@ -65,17 +69,27 @@ func _handle_gavel_hit():
|
||||||
elif state == bidding_state.ASKING:
|
elif state == bidding_state.ASKING:
|
||||||
if current_bid != 0:
|
if current_bid != 0:
|
||||||
state = bidding_state.CLOSED
|
state = bidding_state.CLOSED
|
||||||
|
desk.numpad.reminder_timer.stop()
|
||||||
sell_painting()
|
sell_painting()
|
||||||
print("Congrats on selling your painting for $" + str(current_bid) + "! You have made $" + str(total_sales) + " so far.")
|
print("Congrats on selling your painting for $" + str(current_bid) + "! You have made $" + str(total_sales) + " so far.")
|
||||||
current_painting += 1
|
current_painting += 1
|
||||||
|
if current_painting <= paintings_total - 1:
|
||||||
next_painting((current_painting))
|
next_painting((current_painting))
|
||||||
print("The next painting is valued at $" + str(starting_price) + " (should be $" + str(paintings[current_painting]) + ")")
|
print("The next painting is valued at $" + str(starting_price) + " (should be $" + str(paintings[current_painting]) + ")")
|
||||||
(print(str(state)))
|
(print(str(state)))
|
||||||
|
else:
|
||||||
|
end_auction()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func destroy_painting():
|
func destroy_painting():
|
||||||
pass
|
# Painting destruction animation/particle effect
|
||||||
|
current_painting += 1
|
||||||
|
DisplayServer.tts_speak("Oh nooooooo! Took too long!", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch)
|
||||||
|
DisplayServer.tts_speak("Try to make it up on the next painting!", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch)
|
||||||
|
desk.numpad.reminder_timer.stop()
|
||||||
|
next_painting(current_painting)
|
||||||
|
|
||||||
func sell_painting():
|
func sell_painting():
|
||||||
total_sales = total_sales + current_bid
|
total_sales = total_sales + current_bid
|
||||||
|
|
@ -88,7 +102,17 @@ func next_painting(a: int):
|
||||||
new_painting_displayed.emit()
|
new_painting_displayed.emit()
|
||||||
|
|
||||||
func _handle_ask_accepted():
|
func _handle_ask_accepted():
|
||||||
current_bid_display.text = str(current_bid)
|
current_bid_display.set_text(str(current_bid))
|
||||||
|
|
||||||
|
func end_auction():
|
||||||
|
#add in logic for displaying/transitioning to score screen
|
||||||
|
if total_sales >= target_sales:
|
||||||
|
#add context specific score text?
|
||||||
|
DisplayServer.tts_speak("Congratulations! The auction house will run another day.", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch)
|
||||||
|
else:
|
||||||
|
#add context specific score text?
|
||||||
|
DisplayServer.tts_speak("You have failed. We must find a new auctioneer.", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch)
|
||||||
|
|
||||||
# OTHER THINGS TO ADD:
|
# OTHER THINGS TO ADD:
|
||||||
# UI elements for score
|
# UI elements for score
|
||||||
# Bark manager
|
# Bark manager
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,11 @@ texture = ExtResource("2_7mycd")
|
||||||
position = Vector2(640, 360)
|
position = Vector2(640, 360)
|
||||||
texture = ExtResource("3_272bh")
|
texture = ExtResource("3_272bh")
|
||||||
|
|
||||||
[node name="GameManager" type="Node2D" parent="." node_paths=PackedStringArray("audience_manager", "desk", "current_bid_display")]
|
[node name="GameManager" type="Node2D" parent="." node_paths=PackedStringArray("audience_manager", "desk", "turn_manager", "current_bid_display")]
|
||||||
script = ExtResource("1_ig7tw")
|
script = ExtResource("1_ig7tw")
|
||||||
audience_manager = NodePath("../AudienceManager")
|
audience_manager = NodePath("../AudienceManager")
|
||||||
desk = NodePath("../Desk")
|
desk = NodePath("../Desk")
|
||||||
|
turn_manager = NodePath("../TurnManager")
|
||||||
current_bid_display = NodePath("../UI/RichTextLabel")
|
current_bid_display = NodePath("../UI/RichTextLabel")
|
||||||
|
|
||||||
[node name="Timer" type="Timer" parent="GameManager"]
|
[node name="Timer" type="Timer" parent="GameManager"]
|
||||||
|
|
|
||||||
|
|
@ -38,14 +38,14 @@ func keypad_submit():
|
||||||
game_manager.state = game_manager.bidding_state.ASKING
|
game_manager.state = game_manager.bidding_state.ASKING
|
||||||
success_audio_player.play()
|
success_audio_player.play()
|
||||||
ask_proposed.emit(proposed_ask)
|
ask_proposed.emit(proposed_ask)
|
||||||
print("asking for $" + str(proposed_ask))
|
print("starting the bidding at $" + str(proposed_ask))
|
||||||
else:
|
else:
|
||||||
error_audio_player.play()
|
error_audio_player.play()
|
||||||
game_manager.bidding_state.ASKING:
|
game_manager.bidding_state.ASKING:
|
||||||
if proposed_ask == game_manager.starting_price or proposed_ask == game_manager.current_bid or proposed_ask == audience_manager.current_ask and proposed_ask != 0:
|
if proposed_ask == game_manager.starting_price or proposed_ask == game_manager.current_bid or proposed_ask == audience_manager.current_ask and proposed_ask != 0:
|
||||||
success_audio_player.play()
|
success_audio_player.play()
|
||||||
ask_proposed.emit(proposed_ask)
|
ask_proposed.emit(proposed_ask)
|
||||||
print("starting the bidding at $" + str(proposed_ask))
|
print("asking for $" + str(proposed_ask))
|
||||||
else:
|
else:
|
||||||
error_audio_player.play()
|
error_audio_player.play()
|
||||||
game_manager.bidding_state.BID:
|
game_manager.bidding_state.BID:
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ class_name TurnManager extends Node2D
|
||||||
@export var tts_pitch = 1.0
|
@export var tts_pitch = 1.0
|
||||||
|
|
||||||
@export var desk: Desk
|
@export var desk: Desk
|
||||||
@export var timer: Timer
|
var timer: Timer
|
||||||
@export var game_manager: GameManager
|
@export var game_manager: GameManager
|
||||||
@export var audience_manager: AudienceManager
|
@export var audience_manager: AudienceManager
|
||||||
|
|
||||||
|
|
@ -15,10 +15,11 @@ var voices = DisplayServer.tts_get_voices_for_language("en")
|
||||||
var voice_id = voices[0]
|
var voice_id = voices[0]
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
DisplayServer.tts_speak("Hello, world!", voice_id)
|
|
||||||
audience_manager.ask_accepted.connect(_handle_ask_accepted)
|
audience_manager.ask_accepted.connect(_handle_ask_accepted)
|
||||||
desk.numpad.ask_proposed.connect(_speak_ask_proposed)
|
desk.numpad.ask_proposed.connect(_speak_ask_proposed)
|
||||||
|
timer = desk.numpad.reminder_timer
|
||||||
timer.wait_time = turn_timer
|
timer.wait_time = turn_timer
|
||||||
|
desk.numpad.reminder_timer.timeout.connect(_handle_reminder_timer_timeout)
|
||||||
|
|
||||||
func turn_timer_animation():
|
func turn_timer_animation():
|
||||||
pass
|
pass
|
||||||
|
|
@ -38,8 +39,8 @@ func _handle_ask_accepted():
|
||||||
timer.start()
|
timer.start()
|
||||||
turn_timer_animation()
|
turn_timer_animation()
|
||||||
|
|
||||||
func _on_turn_timer_timeout() -> void:
|
func _handle_reminder_timer_timeout() -> void:
|
||||||
if game_manager.bidding_open == true:
|
if game_manager.state == game_manager.bidding_state.ASKING or game_manager.state == game_manager.bidding_state.BID:
|
||||||
game_manager.bidding_open = false
|
game_manager.state = game_manager.bidding_state.CLOSED
|
||||||
game_manager.destroy_painting()
|
game_manager.destroy_painting()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue