22 lines
541 B
GDScript
22 lines
541 B
GDScript
extends Node2D
|
|
|
|
signal collected(shard_number)
|
|
|
|
export var value = 1
|
|
export var number = 0 #Used for saving which specific shards collected
|
|
|
|
func _ready():
|
|
var hud = get_tree().get_nodes_in_group("hud").pop_back()
|
|
if hud != null:
|
|
connect("collected",hud,"shard_popup")
|
|
$AnimationPlayer.play("glow")
|
|
|
|
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 += value
|
|
Game.shards_collected[number] = true
|
|
queue_free()
|