2026-06-23 01:04:00 +00:00
|
|
|
extends Node2D
|
|
|
|
|
|
|
|
|
|
var numberOfCrates = 2
|
2026-06-29 20:57:59 +00:00
|
|
|
var timeAvailable = 50
|
|
|
|
|
|
|
|
|
|
signal destroySignal(body)
|
|
|
|
|
signal levelChangeSignal(level)
|
|
|
|
|
signal fanUpSignal(body,direction)
|
2026-06-29 21:38:15 +00:00
|
|
|
signal teleportSignal(body)
|
2026-06-23 01:04:00 +00:00
|
|
|
|
|
|
|
|
var timer = Timer.new()
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
|
func _ready() -> void:
|
2026-06-29 20:57:59 +00:00
|
|
|
get_window().grab_focus()
|
2026-06-23 01:04:00 +00:00
|
|
|
add_child(timer)
|
|
|
|
|
timer.wait_time = 1
|
|
|
|
|
timer.one_shot = false
|
|
|
|
|
timer.connect("timeout", countdown)
|
|
|
|
|
timer.start()
|
|
|
|
|
|
|
|
|
|
func countdown()->void:
|
|
|
|
|
# reduce time left
|
|
|
|
|
timeAvailable-=1
|
|
|
|
|
if timeAvailable<=0 and numberOfCrates>0:
|
|
|
|
|
print("LOOOOOSAH")
|
2026-06-29 20:57:59 +00:00
|
|
|
levelChangeSignal.emit("res://scenes/game.tscn")
|
2026-06-23 01:04:00 +00:00
|
|
|
|
2026-06-29 20:57:59 +00:00
|
|
|
func _on_trigger(body: Variant, trigger: Variant, intent:String) -> void:
|
|
|
|
|
print("GC knows trigger fired "+intent)
|
|
|
|
|
match intent:
|
|
|
|
|
"destroy":
|
|
|
|
|
print("GC sending destroy signal")
|
|
|
|
|
destroySignal.emit(body)
|
|
|
|
|
"fan":
|
|
|
|
|
if body is RigidBody2D:
|
|
|
|
|
fanUpSignal.emit(body,Vector2(0,-1)*100*9)
|
2026-06-29 21:38:15 +00:00
|
|
|
"teleport":
|
|
|
|
|
if body is Crate:
|
|
|
|
|
teleportSignal.emit(body)
|
2026-06-29 20:57:59 +00:00
|
|
|
#from scene manager
|
2026-06-23 01:04:00 +00:00
|
|
|
func crateTotal(howmany):
|
|
|
|
|
numberOfCrates = howmany
|
|
|
|
|
print("GC knows about crates: "+str(numberOfCrates))
|
2026-06-29 20:57:59 +00:00
|
|
|
if numberOfCrates == 0:
|
|
|
|
|
print("YOU WON!!!")
|
|
|
|
|
levelChangeSignal.emit("res://scenes/game.tscn")
|
|
|
|
|
|
|
|
|
|
func bulletDamage()->void:
|
|
|
|
|
print("bullet damage")
|