extends StaticBody2D

enum KEY_COLOR{
	yellow,
	red,
	green,
	blue
}
export(KEY_COLOR) var key_color = "yellow"

func _ready():
	$Sprite.texture = load("res://objects/key/assets/" + str(KEY_COLOR.keys()[key_color]) + ".svg")
	$Sprite/AnimationPlayer.play("default")

func _on_PlayerCollision(body):
	if visible:
		GlobalState.keys[str(KEY_COLOR.keys()[key_color])] = true
		$SoundCollected.play()
		hide()

func _on_SoundCollected_finished():
	queue_free()
	get_parent().remove_child(self)
