28 lines
534 B
GDScript3
28 lines
534 B
GDScript3
|
extends Node
|
||
|
|
||
|
var coinsCollected:int = 0
|
||
|
var player:Resource
|
||
|
|
||
|
signal playerDeath
|
||
|
|
||
|
func _ready() -> void:
|
||
|
print("Game controller is ready")
|
||
|
player = load("res://scripts/resources/player.tres")
|
||
|
|
||
|
|
||
|
func coinCollected():
|
||
|
coinsCollected +=1
|
||
|
print("Game Controller Coin Collected : "+str(coinsCollected))
|
||
|
|
||
|
func resetPlayer():
|
||
|
player.health = player.max_health
|
||
|
|
||
|
func playerDamage():
|
||
|
player.health -= 20
|
||
|
print("Player health is : "+str(player.health) )
|
||
|
#is the player dead?
|
||
|
if player.health <= 0:
|
||
|
#kill him
|
||
|
playerDeath.emit()
|
||
|
|