2022-07-18 12:58:38 +02:00
|
|
|
extends StaticBody2D
|
|
|
|
|
2022-07-19 22:22:16 +02:00
|
|
|
enum KEY_COLOR{
|
|
|
|
yellow,
|
|
|
|
red,
|
|
|
|
green,
|
|
|
|
blue
|
|
|
|
}
|
|
|
|
export(KEY_COLOR) var key_color = "yellow"
|
|
|
|
|
2022-07-18 12:58:38 +02:00
|
|
|
func _ready():
|
2022-07-19 22:22:16 +02:00
|
|
|
$Sprite.texture = load("res://objects/key/assets/" + str(KEY_COLOR.keys()[key_color]) + ".svg")
|
2022-07-18 12:58:38 +02:00
|
|
|
$Sprite/AnimationPlayer.play("default")
|
|
|
|
|
|
|
|
func _on_PlayerCollision(body):
|
|
|
|
if visible:
|
2022-07-19 22:22:16 +02:00
|
|
|
GlobalState.keys[str(KEY_COLOR.keys()[key_color])] = true
|
2022-07-18 12:58:38 +02:00
|
|
|
$SoundCollected.play()
|
|
|
|
hide()
|
|
|
|
|
|
|
|
func _on_SoundCollected_finished():
|
|
|
|
queue_free()
|
|
|
|
get_parent().remove_child(self)
|