shard respawn collection system
This commit is contained in:
parent
1c9291868a
commit
1755c6080a
2 changed files with 47 additions and 26 deletions
|
@ -4,7 +4,12 @@ signal collected(shard_number)
|
|||
|
||||
export var number = 0 #Used for saving which specific shards collected
|
||||
|
||||
onready var player: Node2D = get_tree().get_nodes_in_group("player").pop_back()
|
||||
|
||||
var gotten := false
|
||||
|
||||
func _ready():
|
||||
player.connect("died", self, "_on_player_died")
|
||||
var hud = get_tree().get_nodes_in_group("hud").pop_back()
|
||||
if hud != null:
|
||||
connect("collected",hud,"shard_popup")
|
||||
|
@ -12,11 +17,21 @@ func _ready():
|
|||
|
||||
func _on_Area2D_body_entered(body):
|
||||
#Collect
|
||||
if body.is_in_group("player"):
|
||||
emit_signal("collected",number)
|
||||
Audio.play_shard_sound()
|
||||
Game.score += 500
|
||||
Game.shards_collected[number] = true
|
||||
if Game._get_shards() >= 5 && Game.keys == 50:
|
||||
Audio.great_job()
|
||||
queue_free()
|
||||
if body.is_in_group("player") and not gotten:
|
||||
gotten = true
|
||||
$Sprite.visible = false
|
||||
Audio.play_sound(Audio.a_star,Audio.ac_collectible)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if gotten or Game.shards >= 4:
|
||||
var player: Node2D = get_tree().get_nodes_in_group("player").pop_back()
|
||||
if Game.get_sector(player.global_position) != Game.get_sector(global_position):
|
||||
Game.score += 500
|
||||
Game.shards_collected[number] = true
|
||||
emit_signal("collected",number)
|
||||
Audio.play_shard_sound()
|
||||
queue_free()
|
||||
|
||||
func _on_player_died() -> void:
|
||||
gotten = false
|
||||
$Sprite.visible = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue