Merge branch 'main' of clone.gloom.garden:puregarlic/ld58-collector into game-state-info
This commit is contained in:
commit
0f09ea3165
5 changed files with 88 additions and 43 deletions
|
|
@ -27,6 +27,8 @@ var currently_animated_collector = null
|
|||
var current_ask: int
|
||||
var latest_bidder: ArtCollector
|
||||
|
||||
var acceptable_raise = 0
|
||||
|
||||
func _ready() -> void:
|
||||
desk.numpad.ask_proposed.connect(_handle_ask_proposed)
|
||||
timer.timeout.connect(_handle_bid_delay_timeout)
|
||||
|
|
@ -35,7 +37,6 @@ func _ready() -> void:
|
|||
desk.gavel.gavel_hit.connect(try_clear_currently_animated_collector)
|
||||
|
||||
func raise_paddle():
|
||||
#need to add in logic to animate paddle being raised
|
||||
game_manager.state = game_manager.bidding_state.BID
|
||||
print("Audience accepts the bid at $" + str(current_ask))
|
||||
game_manager.current_bid = desk.numpad.proposed_ask
|
||||
|
|
@ -65,7 +66,9 @@ func _handle_auctioneer_bark():
|
|||
bark_critical = true
|
||||
timer.stop()
|
||||
timer.timeout.emit()
|
||||
pass
|
||||
else:
|
||||
acceptable_raise += randi_range(100, 1000)
|
||||
|
||||
|
||||
func _handle_bid_delay_timeout():
|
||||
if game_manager.state == game_manager.bidding_state.ASKING:
|
||||
|
|
@ -76,8 +79,16 @@ func _handle_bid_delay_timeout():
|
|||
func _handle_ask_proposed(amount):
|
||||
current_ask = amount
|
||||
|
||||
if randf() <= think_chance:
|
||||
timer.stop()
|
||||
var ask_duration: float = randf_range(min_audience_think_time, max_audience_think_time)
|
||||
timer.wait_time = ask_duration
|
||||
timer.start()
|
||||
if acceptable_raise == 0:
|
||||
acceptable_raise = randf_range(0.1, 0.2) * current_ask
|
||||
|
||||
if game_manager.current_bid == 0:
|
||||
if randf() < think_chance: _start_bid_timer()
|
||||
elif current_ask - game_manager.current_bid <= acceptable_raise:
|
||||
_start_bid_timer()
|
||||
|
||||
func _start_bid_timer():
|
||||
timer.stop()
|
||||
var ask_duration: float = randf_range(min_audience_think_time, max_audience_think_time)
|
||||
timer.wait_time = ask_duration
|
||||
timer.start()
|
||||
|
|
|
|||
19
desk.tscn
19
desk.tscn
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=60 format=3 uid="uid://bohp0o2smdkwe"]
|
||||
[gd_scene load_steps=62 format=3 uid="uid://bohp0o2smdkwe"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c2mrlu8d75ry4" path="res://gavel.gd" id="1_ep8l3"]
|
||||
[ext_resource type="Script" uid="uid://d2ophrxm0wtr6" path="res://desk.gd" id="1_yugeg"]
|
||||
|
|
@ -49,6 +49,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://b5ijw66s6ibkb" path="res://assets/numpad/backspace-depressed.png" id="26_e06cl"]
|
||||
[ext_resource type="Texture2D" uid="uid://cgdy173ukgmo1" path="res://assets/gavel/gavel-hit-frame_22.png" id="26_kpd5h"]
|
||||
[ext_resource type="Texture2D" uid="uid://mm2l5d1s3rah" path="res://assets/gavel/gavel-hit-frame_23.png" id="27_6p2km"]
|
||||
[ext_resource type="FontFile" uid="uid://cm28kqtqj3a6n" path="res://assets/amiga4ever pro.ttf" id="27_k4eer"]
|
||||
[ext_resource type="Texture2D" uid="uid://bwhf5712gd67h" path="res://assets/numpad/ask.png" id="27_unpof"]
|
||||
[ext_resource type="Texture2D" uid="uid://cxwxmqnnbyl3s" path="res://assets/numpad/ask-depressed.png" id="28_4l1rv"]
|
||||
[ext_resource type="AudioStream" uid="uid://bvto7ghmy8j0o" path="res://assets/gavel/audio/invalid-bet.wav" id="31_v5y5a"]
|
||||
|
|
@ -146,6 +147,10 @@ animations = [{
|
|||
"speed": 15.0
|
||||
}]
|
||||
|
||||
[sub_resource type="Theme" id="Theme_857t2"]
|
||||
default_font = ExtResource("27_k4eer")
|
||||
default_font_size = 12
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8sdgr"]
|
||||
bg_color = Color(0.5109665, 0, 0.077832855, 1)
|
||||
|
||||
|
|
@ -191,11 +196,23 @@ progress_bar = NodePath("../ProgressBar")
|
|||
reminder_timer = NodePath("ReminderTimer")
|
||||
error_audio_player = NodePath("ErrorSoundPlayer")
|
||||
success_audio_player = NodePath("SuccessSoundPlayer")
|
||||
base_timer_duration = 10.0
|
||||
timer_reduction_step = 0.4
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Numpad"]
|
||||
texture_filter = 1
|
||||
texture = ExtResource("5_r8wvv")
|
||||
|
||||
[node name="NumpadDisplay" type="RichTextLabel" parent="Numpad"]
|
||||
unique_name_in_owner = true
|
||||
offset_left = -160.0
|
||||
offset_top = -136.0
|
||||
offset_right = 156.0
|
||||
offset_bottom = -113.0
|
||||
theme = SubResource("Theme_857t2")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="0" parent="Numpad" instance=ExtResource("3_se7ci")]
|
||||
offset_left = -53.0
|
||||
offset_top = 60.0
|
||||
|
|
|
|||
|
|
@ -19,24 +19,28 @@ var current_painting_idx := 0
|
|||
var current_bid := 0:
|
||||
set(value):
|
||||
if is_instance_valid(going_price_label):
|
||||
going_price_label.display_caption("Bid: $%sk" % [floor(value / 1000.0)])
|
||||
going_price_label.text = "Bid: $%sk" % [int(floor(value / 1000.0))]
|
||||
current_bid = value
|
||||
var starting_price := 0:
|
||||
set(value):
|
||||
if is_instance_valid(starting_price_label):
|
||||
if value == 0:
|
||||
starting_price_label.display_caption("Starting Price: ")
|
||||
if value == 0 or state == bidding_state.CLOSED:
|
||||
starting_price_label.text = "Starting Price: Pending"
|
||||
else:
|
||||
starting_price_label.display_caption("Starting Price: $%sk" % [floor(value / 1000.0)])
|
||||
starting_price_label.text = "Starting Price: $%sk" % [int(floor(value / 1000.0))]
|
||||
starting_price = value
|
||||
var final_bid := 0:
|
||||
set(value):
|
||||
if is_instance_valid(going_price_label):
|
||||
going_price_label.display_caption("Sold for $%sk!" % [floor(value / 1000.0)])
|
||||
@export var current_bid_display: RichTextLabel
|
||||
going_price_label.text = "Sold for $%sk!" % [int(floor(value / 1000.0))]
|
||||
final_bid = value
|
||||
|
||||
var target_sales := 0:
|
||||
set(value):
|
||||
if is_instance_valid(quota_label):
|
||||
quota_label.display_caption("Quota: $%sk Progress: 0%%" % [floor(value / 1000.0)])
|
||||
quota_label.text = "Quota: $%sk Progress: 0%%" % [int(floor(value / 1000.0))]
|
||||
target_sales = value
|
||||
|
||||
#var total_sales: int = 0
|
||||
@export var sales_magnitude := 100000
|
||||
@export var single_painting_magnitude := 1000
|
||||
|
|
@ -46,9 +50,9 @@ var target_sales := 0:
|
|||
var bidding_open := false
|
||||
var state := bidding_state.CLOSED
|
||||
|
||||
@export var quota_label: CaptionLabel
|
||||
@export var starting_price_label: CaptionLabel
|
||||
@export var going_price_label: CaptionLabel
|
||||
@export var quota_label: Label
|
||||
@export var starting_price_label: Label
|
||||
@export var going_price_label: Label
|
||||
|
||||
func _ready() -> void:
|
||||
audience_manager.ask_accepted.connect(_handle_ask_accepted)
|
||||
|
|
@ -83,8 +87,7 @@ func _handle_gavel_hit():
|
|||
match state:
|
||||
bidding_state.CLOSED:
|
||||
state = bidding_state.READY
|
||||
#starting_price_label.display_caption("Starting price: $%s" % [starting_price])
|
||||
#current_bid_display.set_text("Starting price: $%s" % [starting_price])
|
||||
starting_price = starting_price
|
||||
bidding_state.ASKING:
|
||||
if current_bid != 0:
|
||||
sell_painting()
|
||||
|
|
@ -110,13 +113,8 @@ func sell_painting():
|
|||
cancel_bidding()
|
||||
move_painting_to_bidders_pile()
|
||||
paintings[current_painting_idx].sold_for = current_bid
|
||||
#current_bid_display.set_text("Sold for $%s!" % [current_bid])
|
||||
var total_sold = 0
|
||||
for painting in paintings:
|
||||
total_sold += painting.sold_for
|
||||
turn_manager.speak_sentence("Sold for $%s!" % [current_bid])
|
||||
@warning_ignore("integer_division")
|
||||
quota_label.display_caption("Quota: $%sk Progress: %s%%" % [floor(target_sales / 1000.0), floor((total_sold / target_sales) * 100.0)])
|
||||
quota_label.text = "Quota: $%sk Progress: %s%%" % [floor(target_sales / 1000.0), floor((float(get_total_sales()) / float(target_sales) * 100.0))]
|
||||
print("Congrats on selling your painting for $%s! You have made $%s so far." % [current_bid, get_total_sales()])
|
||||
|
||||
|
||||
|
|
@ -134,7 +132,6 @@ func next_painting() -> bool:
|
|||
var info := paintings[current_painting_idx]
|
||||
starting_price = info.value
|
||||
current_bid = 0
|
||||
#going_price_label.display_caption("Current bid: $%s" % [current_bid])
|
||||
$NextPainting.play()
|
||||
get_painting_display().animate_show_painting()
|
||||
return true
|
||||
|
|
@ -142,7 +139,6 @@ func next_painting() -> bool:
|
|||
|
||||
func _handle_ask_accepted():
|
||||
pass
|
||||
#current_bid_display.set_text("Current bid: $" + str(current_bid))
|
||||
|
||||
|
||||
func end_auction():
|
||||
|
|
|
|||
|
|
@ -66,13 +66,12 @@ position = Vector2(1074, 162)
|
|||
unique_name_in_owner = true
|
||||
position = Vector2(1075, 162)
|
||||
|
||||
[node name="GameManager" type="Node2D" parent="." node_paths=PackedStringArray("audience_manager", "desk", "turn_manager", "current_bid_display", "quota_label", "starting_price_label", "going_price_label")]
|
||||
[node name="GameManager" type="Node2D" parent="." node_paths=PackedStringArray("audience_manager", "desk", "turn_manager", "quota_label", "starting_price_label", "going_price_label")]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("1_ig7tw")
|
||||
audience_manager = NodePath("../AudienceManager")
|
||||
desk = NodePath("../Desk")
|
||||
turn_manager = NodePath("../TurnManager")
|
||||
current_bid_display = NodePath("../UI/RichTextLabel")
|
||||
quota_label = NodePath("../UI/Quota")
|
||||
starting_price_label = NodePath("../UI/StartingPrice")
|
||||
going_price_label = NodePath("../UI/GoingPrice")
|
||||
|
|
@ -98,6 +97,7 @@ layout_mode = 3
|
|||
anchors_preset = 0
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="UI"]
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
offset_left = 480.0
|
||||
offset_top = 434.0
|
||||
|
|
@ -129,7 +129,6 @@ text = "Quota: 500k Progress: 50%"
|
|||
label_settings = SubResource("LabelSettings_ryguw")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
script = ExtResource("10_ryguw")
|
||||
|
||||
[node name="StartingPrice" type="Label" parent="UI"]
|
||||
layout_mode = 0
|
||||
|
|
@ -141,7 +140,6 @@ text = "Starting Price: 25k"
|
|||
label_settings = SubResource("LabelSettings_ryguw")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
script = ExtResource("10_ryguw")
|
||||
|
||||
[node name="GoingPrice" type="Label" parent="UI"]
|
||||
layout_mode = 0
|
||||
|
|
@ -153,7 +151,6 @@ text = "Asking: 50k"
|
|||
label_settings = SubResource("LabelSettings_ryguw")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
script = ExtResource("10_ryguw")
|
||||
|
||||
[node name="AudienceManager" parent="." node_paths=PackedStringArray("desk", "game_manager") instance=ExtResource("6_272bh")]
|
||||
desk = NodePath("../Desk")
|
||||
|
|
|
|||
44
numpad.gd
44
numpad.gd
|
|
@ -1,10 +1,15 @@
|
|||
class_name Numpad extends Node2D
|
||||
|
||||
var numpad_buffer = Array()
|
||||
var numpad_buffer: String = "":
|
||||
set(value):
|
||||
if value.is_empty():
|
||||
%NumpadDisplay.text = "Enter a value"
|
||||
else:
|
||||
%NumpadDisplay.text = "%sk" % [value]
|
||||
numpad_buffer = value
|
||||
var proposed_ask: int
|
||||
signal ask_proposed(amount)
|
||||
|
||||
#var turn_manager: TurnManager
|
||||
var audience_manager: AudienceManager
|
||||
var game_manager: GameManager
|
||||
var turn_manager: TurnManager
|
||||
|
|
@ -14,6 +19,11 @@ var turn_manager: TurnManager
|
|||
@export var error_audio_player: AudioStreamPlayer2D
|
||||
@export var success_audio_player: AudioStreamPlayer2D
|
||||
|
||||
@export var base_timer_duration = 7.0
|
||||
var timer_duration = base_timer_duration
|
||||
|
||||
@export var timer_reduction_step = 0.3
|
||||
|
||||
func _ready() -> void:
|
||||
progress_bar.max_value = reminder_timer.wait_time
|
||||
|
||||
|
|
@ -23,14 +33,14 @@ func _process(_delta: float) -> void:
|
|||
|
||||
# number entry function called by numbered button children
|
||||
func keypad_entry(entry: int):
|
||||
numpad_buffer.append(str(entry))
|
||||
numpad_buffer += str(entry)
|
||||
|
||||
func keypad_backspace():
|
||||
if numpad_buffer.size() > 0:
|
||||
numpad_buffer.remove_at(-1)
|
||||
if not numpad_buffer.is_empty():
|
||||
numpad_buffer = numpad_buffer.erase(numpad_buffer.length() - 1)
|
||||
|
||||
func keypad_submit():
|
||||
var keypad_output: String = "".join(numpad_buffer)
|
||||
var keypad_output: String = numpad_buffer
|
||||
proposed_ask = int(keypad_output) * 1000
|
||||
|
||||
if proposed_ask == 0: return
|
||||
|
|
@ -42,7 +52,9 @@ func keypad_submit():
|
|||
success_audio_player.play()
|
||||
ask_proposed.emit(proposed_ask)
|
||||
print("starting the bidding at $" + str(proposed_ask))
|
||||
reminder_timer.start(-1)
|
||||
|
||||
reset_timer()
|
||||
start_timer()
|
||||
else:
|
||||
error_audio_player.play()
|
||||
game_manager.bidding_state.ASKING:
|
||||
|
|
@ -50,7 +62,8 @@ func keypad_submit():
|
|||
success_audio_player.play()
|
||||
ask_proposed.emit(proposed_ask)
|
||||
print("asking for $" + str(proposed_ask))
|
||||
reminder_timer.start(-1)
|
||||
|
||||
start_timer()
|
||||
else:
|
||||
error_audio_player.play()
|
||||
game_manager.bidding_state.BID:
|
||||
|
|
@ -59,7 +72,8 @@ func keypad_submit():
|
|||
success_audio_player.play()
|
||||
ask_proposed.emit(proposed_ask)
|
||||
print("asking for $" + str(proposed_ask))
|
||||
reminder_timer.start(-1)
|
||||
|
||||
start_timer()
|
||||
else:
|
||||
error_audio_player.play()
|
||||
_:
|
||||
|
|
@ -67,4 +81,14 @@ func keypad_submit():
|
|||
|
||||
# need to avoid starting the reminder timer before
|
||||
# the auction starts
|
||||
numpad_buffer.clear()
|
||||
numpad_buffer = ""
|
||||
|
||||
func reset_timer():
|
||||
timer_duration = base_timer_duration
|
||||
|
||||
func start_timer():
|
||||
reminder_timer.stop()
|
||||
progress_bar.max_value = timer_duration
|
||||
reminder_timer.start(timer_duration)
|
||||
|
||||
timer_duration -= timer_reduction_step
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue