extends StaticBody2D

# 第一次对话
export var once_talked : bool = false
# 第二次对话
export var second_talked : bool = false

func _ready():
	if once_talked and second_talked:
		queue_free()

func on_player_touched(player):
	var anim_player = $AnimationPlayer as AnimationPlayer
	if not once_talked:
		player.stop()
		yield(Messages.showDialog("你清醒了吗 你到监狱时还处在昏迷中 魔法警卫把你扔到我这个房间 但你很幸运 我刚完成逃跑的暗道你就醒了 我们一起越狱吧"),"popup_hide")
		var hidden_door = $"../Items/HiddenDoor" as Door
		var navigation_tile_map = $"../NavigationTileMap" as NavigationTileMap
		navigation_tile_map.add_navigation_cell(hidden_door.position)
		anim_player.play("open_door")
		once_talked = true
		return
	if not second_talked:
		player.stop()
		yield(Messages.showDialog("我们终于逃出来了 你的剑盾被警卫拿走了 你必须先找到武器 我知道铁建在5楼 铁盾在9楼 你最好先取得它们 我现在还有事没发帮你 再见"),"popup_hide")
		anim_player.play("leave")
		yield(anim_player,"animation_finished")
		second_talked = true
		queue_free()
		return
