Reset the coin count after player is defeated

This commit is contained in:
winniewk committed 2024-09-02 23:01:45 -04:00
1 parent d26b61d855
commit 6286304ebf
22 files changed
+132 -87

No files matched your search

-1
View File
@@ -89,7 +89,6 @@ func _physics_process(delta):
#what did we hit?
if collider is Node:
if collider.is_in_group("boxes"):
print("This is a pushable box")
pushRightEnabled = true
pushTarget = collider
else:
-1
View File
@@ -3,7 +3,6 @@ class_name Coin extends Area2D
signal coinCollected
func _on_body_entered(body):
print("somebody hit a coin")
if body.is_in_group("player"):
coinCollected.emit()
queue_free()
+3 -3
View File
@@ -5,17 +5,17 @@ var coinsCollectedTotal: int = 0
# Called when the node enters the scene tree for the first time.
func _ready():
print("GameManager is loaded")
player = load("res://scripts/resources/playerStats.tres")
func coinCollected():
coinsCollectedTotal += 1
print("coins collected " + str(coinsCollectedTotal))
func resetCoinCollectedCount():
coinsCollectedTotal = 0
func playerDamage():
if player.currentHealth > 0:
player.currentHealth -= 20
print("player health is now " + str(player.currentHealth))
func resetPlayer():
player.currentHealth = player.maxHealth
+1 -2
View File
@@ -11,10 +11,10 @@ var myBox = preload("res://scenes/crate.tscn")
# Called when the node enters the scene tree for the first time.
func _ready():
GameManager.resetPlayer()
GameManager.resetCoinCollectedCount()
for n in coins.get_children():
if n is Coin:
#wire up our listener
n.coinCollected.connect(_on_area_2d_coin_collected)
for n in enemies.get_children():
if n is Enemy:
@@ -27,7 +27,6 @@ func _process(delta):
timer.start()
func _on_area_2d_areatrigger(effect, body):
print("Game Controller sees the trigger " + effect)
match effect:
"alert":
for n in 5: