38 lines
912 B
GDScript
38 lines
912 B
GDScript
extends Node
|
|
var tick: Timer
|
|
var tick_count: int = 0
|
|
@onready var tick_process: TickProcess = TickProcess.new()
|
|
var bridge = null
|
|
|
|
signal currency_goal_met()
|
|
|
|
func _ready():
|
|
Unlocks.apply_modifiers()
|
|
setup_tick_timer()
|
|
|
|
if OS.has_feature("web"):
|
|
bridge = JavaScriptBridge.get_interface("godotBridge")
|
|
|
|
func check_currency_goal():
|
|
if Global.game_continue_pressed == false:
|
|
if Inventory.get_currency() >= Global.target_currency:
|
|
currency_goal_met.emit()
|
|
|
|
## TODO
|
|
## Update this so there's some javascript that does something
|
|
## Maybe needs offloading to whatever UI we show when the game
|
|
## goal is completed. TBD.
|
|
if bridge != null:
|
|
bridge.ping()
|
|
|
|
func setup_tick_timer():
|
|
tick = Timer.new()
|
|
tick.wait_time = 1.0
|
|
tick.connect("timeout", _on_tick_timeout)
|
|
add_child(tick)
|
|
tick.start()
|
|
|
|
func _on_tick_timeout():
|
|
tick_count += 1
|
|
tick_process.tick()
|
|
check_currency_goal()
|