Rework elevator gameplay around pulse-blocking and per-floor spawning

This commit is contained in:
Jennie Robinson Faber 2026-05-10 14:54:49 +01:00
parent a95eaa4dfb
commit 150e703d29
12 changed files with 423 additions and 151 deletions

View file

@ -1,106 +1,165 @@
extends Panel
# my beautiful screen
var sweep_speed := 150.0
var sweep_direction := 1
var sweep_x := 0.0
var is_hacked := true
var style_box: StyleBoxFlat
# Pulse movement
var pulse_speed := 120.0
var pulse_speed_increase := 15.0
var pulse_x := 0.0
var pulse_active := false
var pulse_gap := 1.0
var pulse_gap_decrease := 0.05
var pulse_gap_min := 0.3
# Block zone (shrinks per floor, not per block)
var block_zone_shrink := 3.0
var block_zone_min := 12.0
# Visual
var base_color: Color
var target_shrink := 4.0
var target_min_width := 8.0
# State
var active := false
var pulses_blocked := 0
signal hack_defeated
signal hack_failed
signal pulse_blocked
signal doors_closing
func _ready():
style_box = get_theme_stylebox("panel").duplicate()
add_theme_stylebox_override("panel", style_box)
base_color = style_box.bg_color
var tz = $TargetZone
tz.position = Vector2((size.x - tz.size.x) / 2, 20)
tz.size = Vector2(40, size.y - 40)
# Block zone on right side of screen
var bz = $TargetZone
bz.size = Vector2(50, size.y - 40)
bz.position = Vector2(size.x - bz.size.x - 10, 20)
# Pulse line (hidden until first pulse)
var sl = $SweepLine
sl.position = Vector2(0, 20)
sl.size = Vector2(4, size.y - 40)
sweep_x = 0.0
sl.position = Vector2(0, 20)
sl.visible = false
# AI face
var face = $AIFace
face.position = Vector2(0, 0)
face.size = Vector2(size.x, 30)
face.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
face.text = ">:)"
func _process(delta):
if not is_hacked:
# Duplicate the StyleBoxFlat so flash tweens don't bleed into other panels
var style = get_theme_stylebox("panel") as StyleBoxFlat
if style:
style = style.duplicate()
add_theme_stylebox_override("panel", style)
base_color = style.bg_color
# --- Per-floor lifecycle ---
func start():
active = true
pulses_blocked = 0
pulse_speed = 120.0
pulse_gap = 1.0
$AIFace.text = ">:)"
$TargetZone.visible = true
func stop():
active = false
pulse_active = false
$SweepLine.visible = false
func shrink_block_zone():
var bz = $TargetZone
var new_width = max(bz.size.x - block_zone_shrink, block_zone_min)
bz.size.x = new_width
bz.position.x = size.x - new_width - 10
# --- Pulse logic ---
# Called by elevator_panel when a survivor reaches the door.
func launch_pulse():
if not active:
return
sweep_x += sweep_speed * sweep_direction * delta
if sweep_x >= size.x:
sweep_direction = -1
elif sweep_x <= 0:
sweep_direction = 1
$SweepLine.position.x = sweep_x
func flash(color: Color):
style_box.bg_color = color
var tween = create_tween()
tween.tween_property(style_box, "bg_color", base_color, 0.3)
func reset_hack():
is_hacked = true
sweep_x = 0.0
sweep_direction = 1
pulse_x = 0.0
pulse_active = true
$SweepLine.visible = true
$SweepLine.position.x = 0
$AIFace.text = ">:)"
var tz = $TargetZone
tz.size.x = max(tz.size.x - target_shrink, target_min_width)
tz.position.x = (size.x - tz.size.x) / 2
func get_pulse_gap() -> float:
return pulse_gap
# messtastic
func show_countdown():
func _process(delta):
if not active or not pulse_active:
return
pulse_x += pulse_speed * delta
$SweepLine.position.x = pulse_x
# Pulse reached the far side unblocked: AI wins, doors close
if pulse_x >= size.x:
pulse_active = false
$SweepLine.visible = false
$AIFace.text = ":D"
flash(Color.RED)
active = false
doors_closing.emit()
# Called by elevator_panel when player presses BLOCK.
func attempt_block() -> bool:
if not pulse_active:
return false # no pulse on screen, button does nothing
var bz = $TargetZone
var bz_left = bz.position.x
var bz_right = bz.position.x + bz.size.x
if pulse_x >= bz_left and pulse_x <= bz_right:
# Blocked: doors stay open, this survivor gets in
pulse_active = false
pulses_blocked += 1
pulse_speed += pulse_speed_increase
pulse_gap = max(pulse_gap - pulse_gap_decrease, pulse_gap_min)
$SweepLine.visible = false
$AIFace.text = ">:("
flash(Color.GREEN)
pulse_blocked.emit()
return true
else:
# Mistimed: same result as letting it through
pulse_active = false
$SweepLine.visible = false
$AIFace.text = ":D"
flash(Color.RED)
active = false
doors_closing.emit()
return false
# --- Display helpers ---
func flash(color: Color):
var style = get_theme_stylebox("panel") as StyleBoxFlat
if not style:
return
style.bg_color = color
var tween = create_tween()
tween.tween_property(style, "bg_color", base_color, 0.3)
func show_countdown():
stop()
$AIFace.text = "3"
tween.tween_callback(func(): $AIFace.text = "2").set_delay(0.6)
tween.tween_callback(func(): $AIFace.text = "1").set_delay(0.6)
tween.tween_callback(func(): $AIFace.text = "CLOSED").set_delay(0.6)
var tween = create_tween()
tween.tween_interval(0.6)
tween.tween_callback(func(): $AIFace.text = "2")
tween.tween_interval(0.6)
tween.tween_callback(func(): $AIFace.text = "1")
tween.tween_interval(0.6)
tween.tween_callback(func(): $AIFace.text = "CLOSED")
func show_win():
is_hacked = false
$SweepLine.visible = false
stop()
$TargetZone.visible = false
$AIFace.text = "ESCAPED"
flash(Color.GREEN)
func show_loss(message := "TOO FEW"):
is_hacked = false
$SweepLine.visible = false
func show_loss(message: String):
stop()
$TargetZone.visible = false
$AIFace.text = message
flash(Color.RED)
# target zones
func attempt_hack() -> bool:
var tz = $TargetZone
var tz_left = tz.position.x
var tz_right = tz.position.x + tz.size.x
if sweep_x >= tz_left and sweep_x <= tz_right:
is_hacked = false
$AIFace.text = ">:("
$SweepLine.visible = false
flash(Color.GREEN)
hack_defeated.emit()
return true
else:
sweep_speed += 20.0
$AIFace.text = ":D"
flash(Color.RED)
hack_failed.emit()
return false