extends Button

var current_scene
var next_scene

func _on_pressed() -> void:
	current_scene = self.get_parent().get_parent().get_parent()
	
	var tween := create_tween()
	tween.parallel().tween_property(current_scene.get_node("Fade"), "modulate:a", 1, 0.5).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
	
	self.get_parent().get_parent().visible = false
	
	if current_scene.game_mode == "cascade":
		$ButtonPress.play()
		await $ButtonPress.finished
		next_scene = load("res://scenes/game/fish_cascade.tscn").instantiate()
		next_scene.word_set = self.text.to_lower().replace(" ", "")
		get_tree().change_scene_to_node(next_scene)
	elif current_scene.game_mode == "comet":
		$ButtonPress.play()
		await $ButtonPress.finished
		next_scene = load("res://scenes/game/comet_zap.tscn").instantiate()
		next_scene.word_set = self.text.to_lower().replace(" ", "")
		get_tree().change_scene_to_node(next_scene)
		
