Who knows what
This commit is contained in:
parent
0fe23420ab
commit
9214d13054
422 changed files with 1412 additions and 4783 deletions
|
|
@ -5,6 +5,13 @@ extends Control
|
|||
@onready var stock_label: Label = %StockLabel
|
||||
|
||||
@onready var modifiers_label: Label = %ModifiersLabel
|
||||
@onready var timer_label : Label = %Timer
|
||||
|
||||
@onready var game_complete_screen : Panel = %GameCompleted
|
||||
@onready var continue_button : TextureButton = %ContinueButton
|
||||
|
||||
var game_timer : Timer
|
||||
var elapsed_time := 0.0
|
||||
|
||||
func _ready():
|
||||
populate_modifiers_display()
|
||||
|
|
@ -12,6 +19,14 @@ func _ready():
|
|||
update_currency_label()
|
||||
update_wood_label()
|
||||
update_stock_label()
|
||||
|
||||
game_timer = Timer.new()
|
||||
game_timer.wait_time = 1.0
|
||||
game_timer.one_shot = false
|
||||
game_timer.autostart = true
|
||||
add_child(game_timer)
|
||||
|
||||
game_timer.timeout.connect(_on_timer_tick)
|
||||
|
||||
currency_label.add_theme_color_override("font_color", Global.money_color)
|
||||
wood_label.add_theme_color_override("font_color", Global.wood_color)
|
||||
|
|
@ -24,6 +39,10 @@ func _ready():
|
|||
Inventory.stock_added.connect(spawn_stock_increase)
|
||||
Inventory.stock_changed.connect(_on_currency_changed)
|
||||
Unlocks.item_unlocked.connect(populate_unlock_buttons)
|
||||
GameManager.currency_goal_met.connect(_on_currency_goal_met)
|
||||
|
||||
# get_tree().paused = true
|
||||
|
||||
|
||||
func update_currency_label():
|
||||
currency_label.text = Global.currency_symbol + " " + str(int(Inventory.get_currency()))
|
||||
|
|
@ -99,3 +118,30 @@ func _on_currency_changed(_value):
|
|||
update_currency_label()
|
||||
update_wood_label()
|
||||
update_stock_label()
|
||||
|
||||
if Inventory.get_currency() >= Global.target_currency:
|
||||
game_timer.stop()
|
||||
|
||||
func _on_timer_tick():
|
||||
elapsed_time += 1
|
||||
timer_label.text = format_time(elapsed_time)
|
||||
|
||||
func _on_currency_goal_met():
|
||||
Log.pr("Currency goal met!")
|
||||
get_tree().paused = true
|
||||
game_complete_screen.visible = true
|
||||
|
||||
func format_time(seconds: float) -> String:
|
||||
var total_seconds := int(seconds)
|
||||
|
||||
var hours := total_seconds / 3600
|
||||
var minutes := (total_seconds % 3600) / 60
|
||||
var secs := total_seconds % 60
|
||||
|
||||
return "%02d:%02d:%02d" % [hours, minutes, secs]
|
||||
|
||||
|
||||
func _on_continue_button_pressed() -> void:
|
||||
Global.game_continue_pressed = true
|
||||
game_complete_screen.visible = false
|
||||
get_tree().paused = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue