1
0
mirror of https://gitee.com/freeyz/godot-mota.git synced 2024-12-23 07:09:22 +08:00
godot-mota/scripts/DoorStaticBody2D.gd
2020-07-23 15:47:32 +08:00

26 lines
993 B
GDScript

extends StaticBody2D
class_name DoorStaticBody2D
onready var door_sprite : DoorSprite = get_parent()
func on_player_touched():
match door_sprite.door_type:
DoorSprite.DoorType.Yellow:
if GameArchiveManager.player_info.yellow_key <= 0:
return
GameArchiveManager.player_info.yellow_key -= 1
$"/root/Main/UI/KeyBackground/YellowKeyCountLabel".text = GameArchiveManager.player_info.yellow_key as String
DoorSprite.DoorType.Blue:
if GameArchiveManager.player_info.blue_key <= 0:
return
GameArchiveManager.player_info.blue_key -= 1
$"/root/Main/UI/KeyBackground/BlueKeyCountLabel".text = GameArchiveManager.player_info.blue_key as String
DoorSprite.DoorType.Red:
if GameArchiveManager.player_info.red_key <= 0:
return
GameArchiveManager.player_info.red_key -= 1
$"/root/Main/UI/KeyBackground/RedKeyCountLabel".text = GameArchiveManager.player_info.red_key as String
door_sprite.queue_free()
GameArchiveManager.add_used_item(door_sprite.get_path())