2025-09-30 01:11:01 +00:00
|
|
|
extends Node2D
|
|
|
|
|
|
2025-10-06 20:01:50 +00:00
|
|
|
var totalCrates = 2 #This will be updated in the future, see SceneManager
|
|
|
|
|
var cratesDestroyed = 0
|
|
|
|
|
var timeLimit = 10
|
|
|
|
|
var timer:= Timer.new()
|
2025-09-30 01:11:01 +00:00
|
|
|
|
2025-10-28 01:02:09 +00:00
|
|
|
var coinsCollectedTotal:int = 0
|
|
|
|
|
var totalCoinsAvailable:int = 0
|
|
|
|
|
|
2025-09-30 01:11:01 +00:00
|
|
|
# Called when the node enters the scene tree for the first time.
|
2025-10-06 20:01:50 +00:00
|
|
|
func _ready():
|
|
|
|
|
add_child(timer)
|
|
|
|
|
timer.wait_time = 1
|
|
|
|
|
timer.one_shot = false
|
|
|
|
|
timer.connect("timeout", secondCounter)
|
|
|
|
|
timer.start()
|
|
|
|
|
$TimerLabel.text = str(timeLimit)
|
2025-09-30 01:11:01 +00:00
|
|
|
|
2025-10-06 20:01:50 +00:00
|
|
|
func secondCounter():
|
|
|
|
|
timeLimit -= 1
|
|
|
|
|
$TimerLabel.text = str(timeLimit)
|
|
|
|
|
if timeLimit <=0:
|
|
|
|
|
print("You lose baby!")
|
|
|
|
|
get_tree().reload_current_scene()
|
2025-09-30 01:11:01 +00:00
|
|
|
|
|
|
|
|
func _on_trigger_fired(intent: Variant, body) -> void:
|
2025-10-06 20:01:50 +00:00
|
|
|
#print("GC knows trigger fired " +intent)
|
2025-09-30 01:11:01 +00:00
|
|
|
match intent:
|
|
|
|
|
"destroy":
|
2025-10-06 20:01:50 +00:00
|
|
|
if body.name.begins_with("Crate"):
|
|
|
|
|
cratesDestroyed +=1
|
|
|
|
|
body.queue_free() # destroy the crate - again will move to SceneManager
|
|
|
|
|
if cratesDestroyed>=totalCrates:
|
|
|
|
|
print("You win baby!")
|
|
|
|
|
get_tree().reload_current_scene()
|
2025-09-30 01:11:01 +00:00
|
|
|
"powerup":
|
|
|
|
|
print("power up this thing")
|
2025-10-28 01:02:09 +00:00
|
|
|
|
|
|
|
|
func _on_coin_collected(body, coin):
|
|
|
|
|
print("GC knows coin collected")
|
|
|
|
|
coinsCollectedTotal += 1
|
|
|
|
|
coin.queue_free()
|
|
|
|
|
if coinsCollectedTotal >= totalCoinsAvailable:
|
|
|
|
|
print("You won the level!")
|
|
|
|
|
|
|
|
|
|
func totalCoins(value):
|
|
|
|
|
totalCoinsAvailable = value
|
|
|
|
|
|
|
|
|
|
func _on_slime_damage(body, slime):
|
|
|
|
|
print("GC knows slime damage")
|
|
|
|
|
|
|
|
|
|
func totalEnemies(value):
|
|
|
|
|
print("GC knows total enemies " + str(value))
|
|
|
|
|
#totalEnemies = value
|