2024-08-13 01:01:40 +00:00
|
|
|
extends Node
|
2024-07-22 22:23:44 +00:00
|
|
|
|
2024-07-30 01:01:19 +00:00
|
|
|
#preloading crate and marker for box trap
|
|
|
|
var myBox = preload("res://scenes/crate.tscn")
|
2024-08-13 01:01:40 +00:00
|
|
|
@onready var box_trap = $"../BoxTrap"
|
|
|
|
@onready var timer = $Timer
|
|
|
|
@onready var player = $"../CharacterBody2D"
|
|
|
|
|
|
|
|
var totalCoins = 0
|
2024-07-22 22:23:44 +00:00
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
|
|
|
pass # Replace with function body.
|
|
|
|
|
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
func _process(delta):
|
|
|
|
pass
|
|
|
|
|
2024-07-30 01:01:19 +00:00
|
|
|
func _on_area_2d_areatrigger(effect, body):
|
|
|
|
print("Game Controller sees the trigger " + effect)
|
|
|
|
match effect:
|
|
|
|
"alert":
|
|
|
|
#do stuff
|
|
|
|
print("hi")
|
|
|
|
if body.is_in_group("player"):
|
|
|
|
for n in 3:
|
|
|
|
var box = myBox.instantiate()
|
2024-08-13 01:01:40 +00:00
|
|
|
owner.add_child(box)
|
2024-07-30 01:01:19 +00:00
|
|
|
box.transform = box_trap.transform
|
2024-08-13 01:01:40 +00:00
|
|
|
|
|
|
|
func coinCollected():
|
|
|
|
totalCoins += 1
|
|
|
|
print("I have " + str(totalCoins) + " coins")
|
|
|
|
|
|
|
|
func playerDeath():
|
|
|
|
player.die()
|
|
|
|
timer.start()
|
|
|
|
|
|
|
|
func resetWorld():
|
|
|
|
get_tree().reload_current_scene()
|