forked from team-sg/hero-mark-2
58 lines
1.4 KiB
GDScript
58 lines
1.4 KiB
GDScript
extends Node
|
|
|
|
|
|
var file: Save.SaveFile = null
|
|
var difficulty: int = Game.Difficulty.SPICY
|
|
|
|
onready var face: Sprite = $"%Face"
|
|
onready var chosen_name: Label = $"%ChosenName"
|
|
|
|
|
|
func _ready() -> void:
|
|
# escape to file select if no file is assigned
|
|
if not file:
|
|
yield(get_tree(), "idle_frame")
|
|
SceneManager.current_scene = load("res://menus/file_select.tscn").instance()
|
|
return
|
|
|
|
# pause so that player can not move around until difficulty chosen
|
|
get_tree().paused = true
|
|
# initialize name
|
|
chosen_name.text = ""
|
|
file.name = ""
|
|
# fade in
|
|
Fade.fade_in(0.4)
|
|
# focus the difficulty
|
|
$"%Spicy".call_deferred("grab_focus")
|
|
|
|
|
|
func _set_difficulty(value: int) -> void:
|
|
difficulty = posmod(value, 4)
|
|
file.difficulty = difficulty
|
|
face.frame = difficulty
|
|
|
|
|
|
func _difficulty_selected() -> void:
|
|
Fade.fade_out(0.4)
|
|
yield(Fade, "fade_finished")
|
|
$"%DifficultySelect".queue_free()
|
|
$"%NameEntry".visible = true
|
|
get_tree().paused = false
|
|
Game.use_lives = false
|
|
Fade.fade_in(0.4)
|
|
|
|
func _on_letter_chosen(letter: String) -> void:
|
|
file.name += letter
|
|
chosen_name.text = file.name
|
|
if file.name.length() > 0:
|
|
$"%ExitDoor".frame = 1
|
|
|
|
|
|
func _on_Exit_area_entered(area: Area2D) -> void:
|
|
if file.name.length() > 0:
|
|
get_tree().paused = true
|
|
file.save_to_file()
|
|
Fade.fade_out(0.4)
|
|
yield(Fade, "fade_finished")
|
|
get_tree().paused = false
|
|
SceneManager.current_scene = load("res://menus/file_select.tscn").instance()
|