Code reorganizing
This commit is contained in:
@@ -0,0 +1,249 @@
|
||||
extends Control
|
||||
|
||||
#DeskAssets
|
||||
@onready var patient = $UpperHalf/ControlGlass/Patient
|
||||
@onready var supervisor = $UpperHalf/ControlGlass/Supervisor
|
||||
@onready var green_button = $LowerHalf/GreenButton
|
||||
@onready var red_button = $LowerHalf/RedButton
|
||||
@onready var journal = $LowerHalf/Journal/JournalButton
|
||||
@onready var journal_layer = $JournalLayer
|
||||
@onready var release = $LowerHalf/DecisionScreen/MarginContainer/HBoxContainer/Release
|
||||
@onready var terminate = $LowerHalf/DecisionScreen/MarginContainer/HBoxContainer/Terminate
|
||||
@onready var patient_color: Color
|
||||
@onready var computer = $LowerHalf/Computer
|
||||
@onready var middle_screen = $LowerHalf/MiddleScreen/MarginContainer/MiddleScreen
|
||||
@onready var console_screen = $LowerHalf/Console/Margin/ConsoleScreen
|
||||
|
||||
#RoomAssets
|
||||
@onready var cell_top = $RoomAssets/CellTop
|
||||
@onready var cell_bot = $RoomAssets/CellBot
|
||||
@onready var cell_animation = $RoomAssets/CellAnimation
|
||||
@onready var cell_wall = $RoomAssets/CellWall
|
||||
@onready var backwall_animation = $RoomAssets/Backwall/BackwallAnimation
|
||||
|
||||
#DialogueAssets
|
||||
@onready var patient_dialogue_resource: Resource
|
||||
@onready var balloon: Node
|
||||
@onready var patient_emotions : Dictionary
|
||||
@onready var message_array: Array[String]
|
||||
|
||||
var main: Node
|
||||
var accurate_diagnoses = 0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
#Referencing main node
|
||||
main = get_parent()
|
||||
|
||||
#Connecting signals
|
||||
computer.next_patient_button.pressed.connect(self._on_call_next_patient_pressed)
|
||||
red_button.decision_made.connect(self._on_decision_made)
|
||||
green_button.decision_made.connect(self._on_decision_made)
|
||||
journal.pressed.connect(journal_layer._on_journal_pressed)
|
||||
Globals.clear_patient.connect(self._on_clear_patient)
|
||||
Globals.color_change.connect(self._on_color_change)
|
||||
|
||||
#Hiding and showing appropriate RoomAssets
|
||||
for room_asset in [cell_top, cell_bot, cell_wall]:
|
||||
room_asset.hide()
|
||||
for room_asset in [$RoomAssets/Glass, $RoomAssets/Room, $RoomAssets/Backwall]:
|
||||
room_asset.show()
|
||||
#$RoomAssets/Backwall.position = Vector2(0, -2700)
|
||||
|
||||
hide() #Hiding ScreeningDesk
|
||||
|
||||
message_array.resize(3) #Setting up message array
|
||||
|
||||
|
||||
func new_patient():
|
||||
|
||||
var new_id = Patient.next_patient()
|
||||
#Patient.new_patient("it_that_smiles") #Line for testing purposes
|
||||
Patient.new_patient(new_id) #Line for generating new patient
|
||||
|
||||
computer.patient_file.text = Patient.file_text
|
||||
computer.recording.text = ""
|
||||
patient.texture = Patient.image
|
||||
|
||||
#Setting up UI
|
||||
computer.next_patient_button.show()
|
||||
console_screen.display(Globals.directives)
|
||||
|
||||
|
||||
func _on_call_next_patient_pressed(): #Brings in next patient and sets up the desk controls
|
||||
|
||||
#Hiding the next_patient button
|
||||
var scenes_to_hide = [computer.next_patient_button, supervisor]
|
||||
for scenes in scenes_to_hide:
|
||||
scenes.hide()
|
||||
|
||||
# Shows transition messages on computer and console
|
||||
var message : String
|
||||
message = Globals.colorize("COMPUTING CELL TRANSLATION...", "orange_red")
|
||||
computer.display(message)
|
||||
message = Globals.colorize("- BRINGING IN NEXT PATIENT -", "dark_orange")
|
||||
console_screen.display(message)
|
||||
|
||||
#Shutters entry animation
|
||||
cell_animation.play("incoming")
|
||||
cell_top.show()
|
||||
cell_bot.show()
|
||||
await cell_animation.animation_finished
|
||||
|
||||
#Showing the Patient and the Backroom
|
||||
var scenes_to_show = [patient, cell_wall]
|
||||
for scene in scenes_to_show:
|
||||
scene.show()
|
||||
|
||||
#Opening Shutters
|
||||
cell_animation.play("open")
|
||||
await cell_animation.animation_finished
|
||||
|
||||
#Activating Buttons
|
||||
green_button.set_disabled(false)
|
||||
red_button.set_disabled(false)
|
||||
|
||||
#Coloring Release and Terminate
|
||||
release.text = Globals.colorize("RELEASE", "dark_green")
|
||||
terminate.text = Globals.colorize("TERMINATE", "dark_red")
|
||||
|
||||
#Starting Dialogue and hiding console screen
|
||||
computer.screen.hide()
|
||||
console_screen.hide()
|
||||
main.start_balloon("screening", "patient", Patient.dialogue_resource, "start")
|
||||
|
||||
#Showing Computer Tabs and showing Patient File Screen by default
|
||||
for tab in computer.tab_list:
|
||||
tab.show()
|
||||
tab.set_mouse_filter(Control.MOUSE_FILTER_STOP)
|
||||
computer.patient_file.show()
|
||||
|
||||
#Updating patient_count
|
||||
Globals.patient_count += 1
|
||||
|
||||
|
||||
#Starts release or termination protocols when the corresponding button is pressed
|
||||
func _on_decision_made(choice: String):
|
||||
|
||||
#Hiding computer tabs screen
|
||||
for node in computer.tab_list + computer.screen_list:
|
||||
node.hide()
|
||||
|
||||
#Setting up console and computer displays
|
||||
if choice == "release":
|
||||
release.text = Globals.colorize("RELEASE", "green") #Highlighting the decision
|
||||
message_array = Globals.release_messages
|
||||
elif choice == "terminate":
|
||||
terminate.text = Globals.colorize("TERMINATE", "red") #Highlighting the decision
|
||||
message_array = Globals.terminate_messages
|
||||
console_screen.display(message_array[0])
|
||||
computer.display(message_array[2])
|
||||
|
||||
#Disabling Buttons
|
||||
green_button.set_mouse_filter(Control.MOUSE_FILTER_IGNORE)
|
||||
red_button.set_mouse_filter(Control.MOUSE_FILTER_IGNORE)
|
||||
|
||||
#Final Patient Dialogue
|
||||
main.start_balloon("screening", "patient", Patient.dialogue_resource, choice)
|
||||
|
||||
|
||||
#Clears patient and transitions towards next patient or end of day
|
||||
func _on_clear_patient(choice:String):
|
||||
|
||||
# Updating middle screen info and accurate_diagnoses value
|
||||
if (Patient.abnormal == true and choice == "terminate") or (Patient.abnormal == false and choice == "release"):
|
||||
accurate_diagnoses += 1
|
||||
else:
|
||||
accurate_diagnoses = 0 # Resetting to 0 if the player makes a wrong diagnosis
|
||||
middle_screen.update(Globals.day_count, Globals.floor_count, accurate_diagnoses, Globals.diagnoses_quota)
|
||||
|
||||
#Showing second console message
|
||||
console_screen.display(message_array[1])
|
||||
|
||||
#Closing Shutters
|
||||
cell_animation.play("close")
|
||||
await cell_animation.animation_finished
|
||||
|
||||
#Hiding the cell and restoring the backroom and patient's original colors
|
||||
for scene in [patient, cell_wall]:
|
||||
scene.hide()
|
||||
patient.modulate = Patient.original_color
|
||||
cell_wall.modulate = Patient.original_color
|
||||
|
||||
#Hiding Computer screen and resetting Console screen once the animation is done
|
||||
cell_animation.play(choice)
|
||||
await cell_animation.animation_finished
|
||||
computer.screen.hide()
|
||||
console_screen.hide()
|
||||
|
||||
#Reenabling mouse filter and resetting buttons
|
||||
for button in [green_button, red_button]:
|
||||
button.set_mouse_filter(Control.MOUSE_FILTER_STOP)
|
||||
button.set_pressed(false)
|
||||
button.set_toggle_mode(false)
|
||||
button.set_disabled(true)
|
||||
|
||||
#Resetting decision screen
|
||||
release.text = Globals.colorize("RELEASE", "web_gray")
|
||||
terminate.text = Globals.colorize("TERMINATE", "web_gray")
|
||||
|
||||
#Descending Floor if diagnoses_quota reached
|
||||
if accurate_diagnoses == Globals.diagnoses_quota:
|
||||
descend_floor()
|
||||
else:
|
||||
new_patient()
|
||||
|
||||
|
||||
func _on_color_change(color: String): #Modulating backroom and patient colors
|
||||
|
||||
var new_color: Color
|
||||
|
||||
match color:
|
||||
"red":
|
||||
new_color = Color(1,0.1,0.1,1)
|
||||
"green":
|
||||
new_color = Color(0.5,1,0.5,1)
|
||||
patient.modulate = new_color
|
||||
cell_wall.modulate = new_color
|
||||
print("Color changed to: " + str(new_color))
|
||||
|
||||
|
||||
func descend_floor(): #Descends to next floor
|
||||
|
||||
#Displaying information on screens
|
||||
var message : String
|
||||
message = Globals.colorize("DIAGNOSES QUOTA REACHED", "green_yellow") + "\n\n" + "SECURITY CLEARANCE UPDATED" + "\n\n" + Globals.colorize("ACCESS TO NEXT FLOOR AUTHORIZED", "green")
|
||||
computer.display(message)
|
||||
message = Globals.colorize("- DESCENT PROTOCOL INITIATED -\n\n- TRANSLATING TO NEXT FLOOR -", "dark_orange")
|
||||
console_screen.display(message)
|
||||
|
||||
#Descending animation
|
||||
backwall_animation.play("going_down_1")
|
||||
await backwall_animation.animation_finished
|
||||
backwall_animation.play("going_down_2")
|
||||
await backwall_animation.animation_finished
|
||||
|
||||
#Updating middle screen info
|
||||
Globals.floor_count -= 1
|
||||
accurate_diagnoses = 0
|
||||
Globals.diagnoses_quota += 1
|
||||
middle_screen.update(Globals.day_count, Globals.floor_count, accurate_diagnoses, Globals.diagnoses_quota)
|
||||
|
||||
#Resetting patient_count
|
||||
Globals.patient_count = 0
|
||||
|
||||
#Updating journal symptoms
|
||||
journal_layer.update_journal(Globals.floor_count)
|
||||
|
||||
#Hiding screen messages
|
||||
computer.screen.hide()
|
||||
console_screen.hide()
|
||||
|
||||
#Interfloor dialogue
|
||||
supervisor.dialogue("interfloor_" + str(-Globals.floor_count-1))
|
||||
await supervisor.dialogue_finished
|
||||
|
||||
#Setting up new patient
|
||||
new_patient()
|
||||
|
||||
Reference in New Issue
Block a user