extends Area2D

class_name HitPlot

export var used : bool = false

func _ready():
	if used:
		queue_free()

func _on_HitPlot_body_entered(body):
	if used:
		return
	# 魔王剧情
	body.stop()
	$Devil.visible = true
	yield(Messages.showDialog("欢迎来到魔塔 你是第100位挑战者 你若能打败我所有的手下 我就与你一对一的对决斗 现在你必须接受我的安排"),"popup_hide")
	$Devil/Devils.visible = true
	yield(Messages.showDialog("什么"),"popup_hide")
	# 初始化勇者位置
	var player : Player = body as Player
	player.position = Vector2(80,464)
	player.atk = 10
	player.def = 10
	to_second_level()

# 移动角色到二楼监狱
func to_second_level():
	var levels_manager = $"/root/Main/Level" as LevelsManager
	used = true
	levels_manager.connect("level_changed",self,"on_level_changed")
	levels_manager.call_deferred("set_level_and_position",2,Vector2(112,368))
