end_of_day_dialogue started
This commit is contained in:
+88
-68
@@ -9,48 +9,60 @@ extends Control
|
||||
@onready var face_zoom = $Background/HBoxContainer/MarginContainer/VBoxContainer/FaceMarginContainer/FaceZoom
|
||||
@onready var alone_controls = $Background/HBoxContainer/MarginContainer/VBoxContainer/ControlsMarginContainer/Alone
|
||||
@onready var patient_controls = $Background/HBoxContainer/MarginContainer/VBoxContainer/ControlsMarginContainer/Patient
|
||||
@onready var end_of_day_controls = $Background/HBoxContainer/MarginContainer/VBoxContainer/ControlsMarginContainer/EndOfDay
|
||||
@onready var patient_texture = $Background/HBoxContainer/Desk/PatientTextureRect
|
||||
@onready var dialogue_resource: Resource
|
||||
@onready var patient_dialogue_resource: Resource
|
||||
@onready var end_of_day_dialogue_resource = load("res://Dialogues/end_of_day.dialogue")
|
||||
@onready var balloon: Node
|
||||
@onready var patient_emotions : Dictionary
|
||||
|
||||
var patient_count = 0
|
||||
|
||||
signal recovery_pressed
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
|
||||
#Connecting signals
|
||||
alone_controls.get_node("PatientFile").pressed.connect(self._patient_file)
|
||||
alone_controls.get_node("Guidebook").pressed.connect(self._guidebook)
|
||||
alone_controls.get_node("CallNextPatient").pressed.connect(self._call_next_patient)
|
||||
alone_controls.get_node("PatientFile").pressed.connect(self._on_patient_file_pressed)
|
||||
alone_controls.get_node("Guidebook").pressed.connect(self._on_guidebook_pressed)
|
||||
alone_controls.get_node("CallNextPatient").pressed.connect(self._on_call_next_patient_pressed)
|
||||
|
||||
patient_controls.get_node("PatientFile").pressed.connect(self._patient_file)
|
||||
patient_controls.get_node("Guidebook").pressed.connect(self._guidebook)
|
||||
patient_controls.get_node("PatientRecording").pressed.connect(self._patient_recording)
|
||||
patient_controls.get_node("Examine").pressed.connect(self._examine)
|
||||
patient_controls.get_node("PatientFile").pressed.connect(self._on_patient_file_pressed)
|
||||
patient_controls.get_node("Guidebook").pressed.connect(self._on_guidebook_pressed)
|
||||
patient_controls.get_node("PatientRecording").pressed.connect(self._on_patient_recording_pressed)
|
||||
patient_controls.get_node("Examine").pressed.connect(self._on_examine_pressed)
|
||||
patient_controls.get_node("Containment").pressed.connect(self._on_containment_pressed)
|
||||
patient_controls.get_node("PsychWard").pressed.connect(self._on_psych_ward_pressed)
|
||||
|
||||
end_of_day_controls.get_node("Recovery").pressed.connect(self._on_recovery_pressed)
|
||||
|
||||
#Hiding everything
|
||||
self.hide()
|
||||
#Hiding Top Right Panel
|
||||
panel_container.hide()
|
||||
for node in margin_container.get_children():
|
||||
node.hide()
|
||||
panel_container.hide()
|
||||
face_zoom.hide()
|
||||
#Hiding Bottom Right Panel
|
||||
alone_controls.hide()
|
||||
patient_controls.hide()
|
||||
end_of_day_controls.hide()
|
||||
#Hiding Patient
|
||||
patient_texture.hide()
|
||||
|
||||
|
||||
|
||||
func gameplay_loop(patient_id):
|
||||
#Game Loop
|
||||
func game_loop(patient_id):
|
||||
|
||||
new_patient(patient_id)
|
||||
|
||||
|
||||
|
||||
#Sets Up New Patient
|
||||
func new_patient(patient_id):
|
||||
|
||||
#Connecting Signals
|
||||
patient_controls.get_node("Containment").pressed.connect(self._on_containment_pressed)
|
||||
patient_controls.get_node("PsychWard").pressed.connect(self._on_psych_ward_pressed)
|
||||
|
||||
#Loading Patient Files
|
||||
var file_path: String = "res://Dialogues/Patients/patient_" + patient_id + "_file.txt"
|
||||
var file = FileAccess.open(file_path, FileAccess.READ)
|
||||
@@ -84,11 +96,11 @@ func new_patient(patient_id):
|
||||
|
||||
#Loading Dialogue Resource
|
||||
var dialogue_resource_path = "res://Dialogues/Patients/patient_" + patient_id + ".dialogue"
|
||||
dialogue_resource = load(dialogue_resource_path)
|
||||
patient_dialogue_resource = load(dialogue_resource_path)
|
||||
|
||||
|
||||
|
||||
func _patient_file():
|
||||
func _on_patient_file_pressed():
|
||||
|
||||
for node in margin_container.get_children():
|
||||
node.hide()
|
||||
@@ -98,7 +110,7 @@ func _patient_file():
|
||||
|
||||
|
||||
|
||||
func _guidebook():
|
||||
func _on_guidebook_pressed():
|
||||
|
||||
for node in margin_container.get_children():
|
||||
node.hide()
|
||||
@@ -108,7 +120,7 @@ func _guidebook():
|
||||
|
||||
|
||||
|
||||
func _call_next_patient():
|
||||
func _on_call_next_patient_pressed():
|
||||
|
||||
#Hiding and Showing appropriate scenes
|
||||
var scenes_to_hide = [alone_controls, panel_container] + margin_container.get_children()
|
||||
@@ -117,11 +129,11 @@ func _call_next_patient():
|
||||
await TransitionScreen.transition_finished
|
||||
|
||||
#Starting Dialogue
|
||||
start_balloon("start")
|
||||
start_balloon(patient_dialogue_resource, "start")
|
||||
|
||||
|
||||
|
||||
func _patient_recording():
|
||||
func _on_patient_recording_pressed():
|
||||
|
||||
for node in margin_container.get_children():
|
||||
node.hide()
|
||||
@@ -151,7 +163,7 @@ func _recording_text(dialogue_line):
|
||||
|
||||
|
||||
|
||||
func _examine():
|
||||
func _on_examine_pressed():
|
||||
|
||||
for node in margin_container.get_children():
|
||||
node.hide()
|
||||
@@ -174,9 +186,10 @@ func _change_emotion(dialogue_line) -> void:
|
||||
func _on_containment_pressed():
|
||||
|
||||
#Asking for Confirmation
|
||||
var lambda = func(): clear_patient("containment")
|
||||
UI.confirmation_text.text = "[center]Do you really want to send this patient to [color=darkred]Containment[/color] ?[/center]"
|
||||
UI.confirmation_yes.pressed.connect(send_to_containment, CONNECT_ONE_SHOT)
|
||||
UI.confirmation_no.pressed.connect(func(): UI.confirmation_yes.disconnect("pressed", send_to_containment))
|
||||
UI.confirmation_yes.pressed.connect(lambda, CONNECT_ONE_SHOT)
|
||||
UI.confirmation_no.pressed.connect(func(): UI.confirmation_yes.disconnect("pressed", lambda))
|
||||
UI.confirmation_dialog.show()
|
||||
TransitionScreen.mask.visible = true
|
||||
|
||||
@@ -184,54 +197,19 @@ func _on_containment_pressed():
|
||||
func _on_psych_ward_pressed():
|
||||
|
||||
#Asking for Confirmation
|
||||
var lambda = func(): clear_patient("psych_ward")
|
||||
UI.confirmation_text.text = "[center]Do you really want to send this patient to the [color=darkgreen]Psych Ward[/color] ?[/center]"
|
||||
UI.confirmation_yes.pressed.connect(send_to_psych_ward, CONNECT_ONE_SHOT)
|
||||
UI.confirmation_no.pressed.connect(func(): UI.confirmation_yes.disconnect("pressed", send_to_psych_ward))
|
||||
UI.confirmation_yes.pressed.connect(lambda, CONNECT_ONE_SHOT)
|
||||
UI.confirmation_no.pressed.connect(func(): UI.confirmation_yes.disconnect("pressed", lambda))
|
||||
UI.confirmation_dialog.show()
|
||||
TransitionScreen.mask.visible = true
|
||||
|
||||
|
||||
func send_to_containment():
|
||||
|
||||
#Disconnecting signals
|
||||
var containment_node = patient_controls.get_node("Containment")
|
||||
var psych_ward_node = patient_controls.get_node("PsychWard")
|
||||
if containment_node.is_connected("pressed", _on_containment_pressed):
|
||||
containment_node.disconnect("pressed", _on_containment_pressed)
|
||||
if psych_ward_node.is_connected("pressed", _on_psych_ward_pressed):
|
||||
psych_ward_node.disconnect("pressed", _on_psych_ward_pressed)
|
||||
|
||||
start_balloon("containment")
|
||||
await DialogueManager.dialogue_ended
|
||||
clear_patient()
|
||||
|
||||
|
||||
|
||||
func send_to_psych_ward():
|
||||
|
||||
#Disconnecting signals to prevent changing choice
|
||||
var containment_node = patient_controls.get_node("Containment")
|
||||
var psych_ward_node = patient_controls.get_node("PsychWard")
|
||||
if containment_node.is_connected("pressed", _on_containment_pressed):
|
||||
containment_node.disconnect("pressed", _on_containment_pressed)
|
||||
if psych_ward_node.is_connected("pressed", _on_psych_ward_pressed):
|
||||
psych_ward_node.disconnect("pressed", _on_psych_ward_pressed)
|
||||
|
||||
start_balloon("psych_ward")
|
||||
await DialogueManager.dialogue_ended
|
||||
clear_patient()
|
||||
|
||||
|
||||
|
||||
func start_balloon(start_title: String):
|
||||
func start_balloon(dialogue_resource: Resource, start_title: String):
|
||||
|
||||
#Freeing Previous Balloon and Disconnecting DialogueManager signals
|
||||
if is_instance_valid(balloon):
|
||||
balloon.queue_free()
|
||||
if DialogueManager.is_connected("got_dialogue", _change_emotion):
|
||||
DialogueManager.disconnect("got_dialogue", _change_emotion)
|
||||
if DialogueManager.is_connected("got_dialogue", _recording_text):
|
||||
DialogueManager.disconnect("got_dialogue", _recording_text)
|
||||
clean_balloon()
|
||||
|
||||
#Instantiating a custom balloon
|
||||
var Balloon: Resource = load("res://Dialogues/balloon_small.tscn")
|
||||
@@ -245,16 +223,58 @@ func start_balloon(start_title: String):
|
||||
|
||||
|
||||
|
||||
func clear_patient():
|
||||
func clear_patient(choice:String):
|
||||
|
||||
#Hiding Patient Controls and showing Patient Face
|
||||
patient_controls.hide()
|
||||
_on_examine_pressed()
|
||||
|
||||
#Final Patient Dialogue
|
||||
start_balloon(patient_dialogue_resource, choice)
|
||||
await DialogueManager.dialogue_ended
|
||||
|
||||
#Transitioning
|
||||
var scenes_to_hide = [patient_controls, patient_texture, face_zoom, panel_container] + margin_container.get_children()
|
||||
var scenes_to_show:Array[Node]
|
||||
|
||||
patient_count += 1
|
||||
if patient_count < Globals.daily_patient_limit:
|
||||
scenes_to_show.append(alone_controls)
|
||||
else:
|
||||
scenes_to_show.append(end_of_day_controls)
|
||||
|
||||
#Hiding and Showing appropriate scenes
|
||||
var scenes_to_hide = [patient_controls, patient_texture, face_zoom] + margin_container.get_children()
|
||||
var scenes_to_show = [alone_controls, panel_container]
|
||||
TransitionScreen.transition("big", scenes_to_hide, scenes_to_show)
|
||||
await TransitionScreen.transition_finished
|
||||
new_patient("564")
|
||||
|
||||
|
||||
if patient_count < Globals.daily_patient_limit:
|
||||
#Setting Up Next Patient
|
||||
new_patient("564")
|
||||
else:
|
||||
patient_count = 0
|
||||
|
||||
#Starting End of Day Dialogue
|
||||
var start_title = "end_of_day_" + str(Globals.day_count)
|
||||
start_balloon(end_of_day_dialogue_resource, start_title)
|
||||
|
||||
|
||||
|
||||
func _on_recovery_pressed():
|
||||
|
||||
clean_balloon()
|
||||
recovery_pressed.emit()
|
||||
|
||||
|
||||
|
||||
func clean_balloon():
|
||||
|
||||
#Freeing Previous Balloon and Disconnecting DialogueManager signals
|
||||
if is_instance_valid(balloon):
|
||||
balloon.queue_free()
|
||||
if DialogueManager.is_connected("got_dialogue", _change_emotion):
|
||||
DialogueManager.disconnect("got_dialogue", _change_emotion)
|
||||
if DialogueManager.is_connected("got_dialogue", _recording_text):
|
||||
DialogueManager.disconnect("got_dialogue", _recording_text)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user