the-crypt/objects/Door.gd

28 lines
552 B
GDScript3
Raw Normal View History

2020-07-22 18:15:21 -05:00
extends Sprite
export var unlocked: bool = true
2020-07-23 00:18:46 -05:00
export var next_scene: String = ""
2020-07-22 18:15:21 -05:00
onready var door = get_node("AnimationPlayer")
func _process(delta):
2020-07-23 00:18:46 -05:00
print(next_scene)
2020-07-22 18:15:21 -05:00
if $Area2D.get_overlapping_bodies().size() != 0:
2020-07-22 23:57:55 -05:00
if unlocked:
$Label.text = "F to Open"
2020-07-23 01:10:01 -05:00
if Input.is_action_just_pressed("open"):
2020-07-22 23:57:55 -05:00
Player.current_scene = next_scene
2020-07-23 01:10:01 -05:00
get_tree().change_scene(""+next_scene+"")
2020-07-22 23:57:55 -05:00
else:
$Label.text = "Locked"
$Label.visible = true
else:
$Label.visible = false
func lock():
unlocked = false
func unlock():
unlocked = true
2020-07-22 18:15:21 -05:00