42 lines
1.1 KiB
GDScript
42 lines
1.1 KiB
GDScript
extends Control
|
|
|
|
# I HAVE NO IDEA WHAT I'M DOIN!!!
|
|
# Original version
|
|
var current_floor := 10
|
|
var saved_count := 0
|
|
|
|
var doors_closing := false
|
|
|
|
|
|
func _ready():
|
|
$PanelMargin/PanelColumn/CloseButton.pressed.connect(_on_close_pressed)
|
|
# 10 floors is probably a lot but will make testing easier.
|
|
#$StatsMargin/StatsColumn/FloorLabel.text = "FLOOR: 10"
|
|
|
|
func _unhandled_input(event):
|
|
if event is InputEventKey and event.pressed and event.keycode == KEY_SPACE:
|
|
_on_close_pressed()
|
|
|
|
func _on_close_pressed():
|
|
# don't let 'em spam the button
|
|
if doors_closing:
|
|
return
|
|
var screen = $ElevatorPanel/PanelMargin/PanelColumn/Screen
|
|
var success = screen.attempt_hack()
|
|
if success:
|
|
doors_closing = true
|
|
saved_count += 1
|
|
current_floor -= 1
|
|
$StatsMargin/StatsColumn/SavedLabel.text = "SAVED: " + str(saved_count)
|
|
$StatsMargin/StatsColumn/FloorLabel.text = "FLOOR: " + str(current_floor)
|
|
if current_floor <= 1:
|
|
screen.show_win()
|
|
else:
|
|
screen.show_countdown()
|
|
var tween = create_tween()
|
|
tween.tween_callback(func():
|
|
screen.reset_hack()
|
|
doors_closing = false
|
|
).set_delay(2.0)
|
|
else:
|
|
print("MISSED! AI is faster now!")
|