This commit is contained in:
Jennie Robinson Faber 2026-05-10 23:56:09 +01:00
parent 7ce2863cfd
commit e216364ec1
12 changed files with 84 additions and 71 deletions

View file

@ -1,6 +1,9 @@
extends PanelContainer
var current_floor := 10
@onready var _screen = $PanelMargin/PanelColumn/Screen
@onready var _close_button: Button = $PanelMargin/PanelColumn/CloseButton
var current_floor: int = EventBus.STARTING_FLOOR
var saved_count := 0
var doors_closing_flag := false
var _onboarded := false
@ -30,15 +33,13 @@ const PERFECT_STUN_DURATION := 0.25
const PRE_PULSE_DELAY := 3.5
func _ready():
var button = $PanelMargin/PanelColumn/CloseButton
button.text = "CLOSE"
button.pressed.connect(_on_block_pressed)
_close_button.text = "CLOSE"
_close_button.pressed.connect(_on_block_pressed)
var screen = $PanelMargin/PanelColumn/Screen
screen.pulse_started.connect(_on_pulse_started)
screen.pulse_blocked.connect(_on_pulse_blocked)
screen.pulse_blocked_perfect.connect(_on_pulse_blocked_perfect)
screen.doors_closing.connect(func(): _on_doors_closing(true))
_screen.pulse_started.connect(_on_pulse_started)
_screen.pulse_blocked.connect(_on_pulse_blocked)
_screen.pulse_blocked_perfect.connect(_on_pulse_blocked_perfect)
_screen.doors_closing.connect(func(): _on_doors_closing(true))
EventBus.game_started.connect(_start_floor)
@ -54,7 +55,7 @@ func _start_floor():
$SfxBell.play()
doors_closing_flag = false
people_in_elevator = 0
$PanelMargin/PanelColumn/CloseButton.text = "CLOSE"
_close_button.text = "CLOSE"
EventBus.doors_opened.emit()
var floors_remaining = current_floor - 1
@ -64,27 +65,26 @@ func _start_floor():
EventBus.floor_changed.emit(current_floor)
EventBus.floor_started.emit(survivors_remaining)
var floors_descended = 10 - current_floor
var floors_descended = EventBus.STARTING_FLOOR - current_floor
var robot_speed = robot_speed_top + floors_descended * robot_speed_per_floor
var robot_delay = max(robot_delay_min, robot_delay_top - floors_descended * robot_delay_per_floor)
EventBus.robot_floor_started.emit(robot_delay, robot_speed)
var screen = $PanelMargin/PanelColumn/Screen
screen.start(current_floor)
_screen.start(current_floor)
if current_floor <= MOVING_ZONE_START_FLOOR:
var floors_below = MOVING_ZONE_START_FLOOR - current_floor
screen.set_block_zone_movement(MOVING_ZONE_BASE_SPEED + floors_below * MOVING_ZONE_SPEED_PER_FLOOR)
_screen.set_block_zone_movement(MOVING_ZONE_BASE_SPEED + floors_below * MOVING_ZONE_SPEED_PER_FLOOR)
if not _onboarded:
_onboarded = true
screen.show_onboarding("BLOCK\nIN GREEN ZONE")
_screen.show_onboarding("BLOCK\nIN GREEN ZONE")
get_tree().create_timer(3.0).timeout.connect(
func():
if not is_instance_valid(screen):
if not is_instance_valid(_screen):
return
screen.end_onboarding()
screen.launch_pulse(),
_screen.end_onboarding()
_screen.launch_pulse(),
CONNECT_ONE_SHOT
)
else:
@ -92,28 +92,27 @@ func _start_floor():
func():
if not is_instance_valid(self) or doors_closing_flag:
return
screen.launch_pulse(),
_screen.launch_pulse(),
CONNECT_ONE_SHOT
)
func _on_block_pressed():
if doors_closing_flag:
return
var screen = $PanelMargin/PanelColumn/Screen
if screen.pulse_active:
screen.attempt_block()
if _screen.pulse_active:
_screen.attempt_block()
else:
_on_doors_closing(false)
func _on_pulse_started(duration: float):
$PanelMargin/PanelColumn/CloseButton.text = "BLOCK"
_close_button.text = "BLOCK"
EventBus.pulse_started.emit(duration)
func _on_pulse_blocked_perfect():
EventBus.robot_stun_requested.emit(PERFECT_STUN_DURATION)
func _on_pulse_blocked():
$PanelMargin/PanelColumn/CloseButton.text = "CLOSE"
_close_button.text = "CLOSE"
EventBus.pulse_blocked.emit()
survivors_remaining -= 1
people_in_elevator += 1
@ -124,12 +123,11 @@ func _on_pulse_blocked():
get_tree().create_timer(0.25).timeout.connect(_on_doors_closing, CONNECT_ONE_SHOT)
return
var screen = $PanelMargin/PanelColumn/Screen
var gap = screen.get_pulse_gap()
var gap = _screen.get_pulse_gap()
get_tree().create_timer(gap).timeout.connect(
func():
if not doors_closing_flag:
screen.launch_pulse(),
_screen.launch_pulse(),
CONNECT_ONE_SHOT
)
@ -139,10 +137,8 @@ func _on_doors_closing(fast: bool = false):
doors_closing_flag = true
EventBus.doors_closed.emit(fast)
var screen = $PanelMargin/PanelColumn/Screen
if people_in_elevator < threshold:
screen.show_loss("TOO FEW")
_screen.show_loss("TOO FEW")
EventBus.game_lost.emit("TOO FEW")
return
@ -157,14 +153,14 @@ func _on_doors_closing(fast: bool = false):
current_floor -= 1
if current_floor <= 1:
screen.show_win()
_screen.show_win()
EventBus.floor_changed.emit(current_floor)
EventBus.game_won.emit()
return
$SfxClose.play()
screen.show_countdown()
screen.shrink_block_zone()
_screen.show_countdown()
_screen.shrink_block_zone()
var tween = create_tween()
tween.tween_interval(3.0)