2025-09-30 01:10:58 +00:00
|
|
|
extends Node2D
|
|
|
|
|
|
2025-10-28 01:02:15 +00:00
|
|
|
var coins_collected : int = 0
|
|
|
|
|
var total_coins : int = 0
|
2025-09-30 01:10:58 +00:00
|
|
|
|
|
|
|
|
func _on_trigger_fired(intent: Variant, body: PhysicsBody2D) -> void:
|
|
|
|
|
print("Game controller knows %s trigger fired " % intent)
|
|
|
|
|
match intent:
|
|
|
|
|
"destroy":
|
|
|
|
|
print("Destroy this thing!")
|
|
|
|
|
if body is RigidBody2D:
|
|
|
|
|
body.queue_free()
|
|
|
|
|
"powerup":
|
|
|
|
|
print("Power this thing up!")
|
2025-10-28 01:02:15 +00:00
|
|
|
|
|
|
|
|
func on_coin_collected(_body, coin) -> void:
|
|
|
|
|
print_debug("GC knows coin collected")
|
|
|
|
|
coins_collected += 1
|
|
|
|
|
print_debug("Coins collected: %s" % str(coins_collected))
|
|
|
|
|
print_debug("There are %s coins remaining" % str(total_coins - coins_collected))
|
|
|
|
|
coin.queue_free()
|
|
|
|
|
if coins_collected >= total_coins:
|
|
|
|
|
print_debug("You win!")
|
|
|
|
|
await get_tree().create_timer(1.0).timeout
|
|
|
|
|
get_tree().call_deferred("reload_current_scene")
|
|
|
|
|
|
|
|
|
|
func on_player_slimed(body, slime) -> void:
|
|
|
|
|
print_debug("GC knows player slimed")
|
|
|
|
|
|
|
|
|
|
func set_total_coins(value) -> void:
|
|
|
|
|
total_coins = value
|
|
|
|
|
print_debug("There are %s coins in the level" % str(total_coins))
|