Files
Sept26Game/scripts/gamecontroller.gd
T

52 lines
1.3 KiB
GDScript
Raw Normal View History

class_name GameController extends Node2D
signal teleportSignal(body:RigidBody2D)
signal destroySignal(body)
2026-10-27 21:03:58 -04:00
var numberOfCrates = 2
var totalCoins = 0
var coinsRemaining = 0
var coinsCollected = 0
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
get_window().grab_focus()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _on_trigger(effect: Variant, Object: Variant) -> void:
print("GC knows about trigger")
match effect:
"destroy":
if not Object is Player:
destroySignal.emit(Object)
"teleport":
print("Trigger wants to teleport")
if Object is Crate:
teleportSignal.emit(Object)
func _on_bullet_hit(body, bullet) -> void:
print("GC knows bullet hit")
if body is Crate:
destroySignal.emit(body)
destroySignal.emit(bullet)
2026-10-27 21:03:58 -04:00
func crateTotal(amount)->void:
numberOfCrates = amount
if numberOfCrates<=0:
print("YOU WON!!!")
func coinTotal(amount)->void:
if totalCoins == 0:
totalCoins = amount
coinsRemaining = amount
print("Collected "+str(totalCoins-coinsRemaining)+" of "+str(totalCoins) )
func coinCollected(body, coin)->void:
if body is Player:
#give them a coin
coinsCollected +=1
destroySignal.emit(coin)