mirror of
https://gitee.com/freeyz/godot-mota.git
synced 2024-12-23 01:59:20 +08:00
27 lines
1.0 KiB
GDScript
27 lines
1.0 KiB
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()
|
|
AffectAudioPlayer.play_door()
|
|
GameArchiveManager.add_used_item(door_sprite.get_path())
|