Flopsy/objects/coin/coin.gd

31 lines
466 B
GDScript3
Raw Permalink Normal View History

2022-07-17 14:24:15 +02:00
extends StaticBody2D
enum TYPE {
bronze,
silver,
gold
}
export(TYPE) var type = TYPE.bronze
export var value : int = 0
const COIN_DEFAULT_VALUES = [
1,
2,
5
]
func _ready():
$Sprite.animation = TYPE.keys()[type]
if value == 0:
value = COIN_DEFAULT_VALUES[type]
func _on_Player_entered(body):
if visible:
2022-07-18 12:58:38 +02:00
GlobalState.coins += value
2022-07-17 14:24:15 +02:00
$SoundCollected.play()
hide()
func _on_SoundCollected_finished():
queue_free()
get_parent().remove_child(self)