2024-08-13 01:21:31 +00:00
|
|
|
extends Node
|
2024-07-23 01:20:27 +00:00
|
|
|
|
2024-08-13 01:21:31 +00:00
|
|
|
var crate = preload("res://scenes/crate.tscn")
|
|
|
|
@onready var boxtrap = $"../crates/boxtrap"
|
|
|
|
@onready var timer = $Timer
|
|
|
|
@onready var player = $"../CharacterBody2D"
|
2024-07-23 01:20:27 +00:00
|
|
|
|
|
|
|
|
2024-08-13 01:21:31 +00:00
|
|
|
var totalCoins = 0
|
2024-07-23 01:20:27 +00:00
|
|
|
|
2024-07-30 01:07:00 +00:00
|
|
|
func _on_area_2d_areatrigger(effect, body):
|
2024-08-13 01:21:31 +00:00
|
|
|
print("Game Controller sees the trigger "+effect)
|
2024-07-30 01:07:00 +00:00
|
|
|
match effect:
|
|
|
|
"alert":
|
2024-08-13 01:21:31 +00:00
|
|
|
#do stuff
|
2024-07-30 01:07:00 +00:00
|
|
|
print("hi")
|
|
|
|
if body.is_in_group("player"):
|
2024-08-13 01:21:31 +00:00
|
|
|
for n in 3:
|
|
|
|
var box = crate.instantiate()
|
|
|
|
owner.add_child(box)
|
|
|
|
box.position = boxtrap.position
|
2024-07-30 01:07:00 +00:00
|
|
|
"powerup":
|
|
|
|
print("you got power")
|
2024-08-13 01:21:31 +00:00
|
|
|
|
|
|
|
func coinCollected():
|
|
|
|
totalCoins += 1
|
|
|
|
print("Game controller will add coin " + str(totalCoins))
|
|
|
|
|
|
|
|
func playerDeath():
|
|
|
|
player.die()
|
|
|
|
timer.start()
|
|
|
|
|
|
|
|
func resetWorld():
|
|
|
|
get_tree().reload_current_scene()
|
|
|
|
|
|
|
|
|