shirogamis-maze/src/Objects/InventoryItemPickup.gd
2021-05-27 01:44:39 -04:00

30 lines
639 B
GDScript

extends Area2D
export var item = ""
func _ready():
set_correct_sprite()
$AnimationPlayer.play("wave")
# warning-ignore:return_value_discarded
connect("body_entered",self,"body_entered")
func body_entered(_body):
if $Sprite.visible:
global.add_item(item)
global.update_item_hud()
global.show_message("You found the key to exit the level.")
var snd = $AudioStreamPlayer
$Sprite.visible = false
snd.play()
yield(snd,"finished")
queue_free()
func init(_item):
item = _item
set_correct_sprite()
func set_correct_sprite():
match item:
"KeyYellow":
$Sprite.set_texture(preload("res://assets/art/key_yellow.png"))