Merge branch 'master' of https://git.ghostguild.org/henry/tojam20-elevator
This commit is contained in:
commit
6482d52a04
13 changed files with 219 additions and 80 deletions
BIN
audio/556700__nachtmahrtv__elevator-bell.wav
Normal file
BIN
audio/556700__nachtmahrtv__elevator-bell.wav
Normal file
Binary file not shown.
24
audio/556700__nachtmahrtv__elevator-bell.wav.import
Normal file
24
audio/556700__nachtmahrtv__elevator-bell.wav.import
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://c2iaspcnilk5"
|
||||
path="res://.godot/imported/556700__nachtmahrtv__elevator-bell.wav-6950997a5a23767b57ff571b61830129.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://audio/556700__nachtmahrtv__elevator-bell.wav"
|
||||
dest_files=["res://.godot/imported/556700__nachtmahrtv__elevator-bell.wav-6950997a5a23767b57ff571b61830129.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=2
|
||||
37
scenes/elevator.gd
Normal file
37
scenes/elevator.gd
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
extends Node3D
|
||||
|
||||
const DOOR_OPEN_X := 1.154
|
||||
const DOOR_CLOSED_X := 0.7
|
||||
const DOOR_DEFAULT_TIME := 3.0
|
||||
const DOOR_FAST_CLOSE_TIME := 1.0
|
||||
const DOOR_REOPEN_TIME := 0.4
|
||||
|
||||
var _tween: Tween = null
|
||||
|
||||
func _ready():
|
||||
$ElevatorDoorRight.position = Vector3(DOOR_CLOSED_X, 0, 0)
|
||||
$ElevatorDoorLeft.position = Vector3(-DOOR_CLOSED_X, 0, 0)
|
||||
EventBus.doors_opened.connect(_on_doors_opened)
|
||||
EventBus.doors_closed.connect(_on_doors_closed)
|
||||
EventBus.pulse_started.connect(_on_pulse_started)
|
||||
EventBus.pulse_blocked.connect(_on_pulse_blocked)
|
||||
|
||||
func _on_doors_opened():
|
||||
_tween_doors(DOOR_OPEN_X, DOOR_DEFAULT_TIME)
|
||||
|
||||
func _on_doors_closed(fast: bool):
|
||||
_tween_doors(DOOR_CLOSED_X, DOOR_FAST_CLOSE_TIME if fast else DOOR_DEFAULT_TIME)
|
||||
|
||||
func _on_pulse_started(duration: float):
|
||||
_tween_doors(DOOR_CLOSED_X, duration)
|
||||
|
||||
func _on_pulse_blocked():
|
||||
_tween_doors(DOOR_OPEN_X, DOOR_REOPEN_TIME)
|
||||
|
||||
func _tween_doors(target_x: float, duration: float):
|
||||
if _tween:
|
||||
_tween.kill()
|
||||
_tween = create_tween()
|
||||
_tween.set_parallel(true)
|
||||
_tween.tween_property($ElevatorDoorRight, "position:x", target_x, duration)
|
||||
_tween.tween_property($ElevatorDoorLeft, "position:x", -target_x, duration)
|
||||
1
scenes/elevator.gd.uid
Normal file
1
scenes/elevator.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cw4kqlft85a5g
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
[gd_scene format=3 uid="uid://brd3iponame0e"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://8ybwrid1vk4j" path="res://scenes/elevator_door.tscn" id="1_uuuf0"]
|
||||
[ext_resource type="Script" path="res://scenes/elevator.gd" id="2_elev"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_8o2wm"]
|
||||
length = 0.001
|
||||
|
|
@ -93,6 +94,7 @@ _data = {
|
|||
}
|
||||
|
||||
[node name="Elevator" type="Node3D" unique_id=242258467]
|
||||
script = ExtResource("2_elev")
|
||||
|
||||
[node name="ElevatorDoorLeft" parent="." unique_id=1751198646 instance=ExtResource("1_uuuf0")]
|
||||
transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, -1.25, 0, 0)
|
||||
|
|
|
|||
|
|
@ -1,41 +1,44 @@
|
|||
extends PanelContainer
|
||||
|
||||
# Floor state
|
||||
var current_floor := 10
|
||||
var saved_count := 0
|
||||
var doors_closing_flag := false
|
||||
var _onboarded := false
|
||||
|
||||
# Survivors per floor: more at top, fewer as you descend
|
||||
var base_survivors := 2
|
||||
var survivors_per_floor_increase := 1 # per floor above ground
|
||||
var survivors_per_floor_increase := 1
|
||||
var survivors_remaining := 0
|
||||
|
||||
# Flat threshold: must save at least this many per floor
|
||||
var threshold := 2
|
||||
|
||||
# Scoring
|
||||
var score := 0
|
||||
var points_per_person := 100 # base + bonus per person above threshold
|
||||
var points_per_person := 100
|
||||
|
||||
# Moving block zone (starts at floor 7, faster as we descend)
|
||||
const MOVING_ZONE_START_FLOOR := 7
|
||||
const MOVING_ZONE_BASE_SPEED := 40.0
|
||||
const MOVING_ZONE_SPEED_PER_FLOOR := 12.0
|
||||
|
||||
var robot_speed_top := 1.0
|
||||
var robot_speed_per_floor := 0.15
|
||||
var robot_delay_top := 8.0
|
||||
var robot_delay_per_floor := 0.6
|
||||
var robot_delay_min := 1.0
|
||||
|
||||
var people_in_elevator := 0
|
||||
|
||||
const PERFECT_STUN_DURATION := 0.25
|
||||
const PRE_PULSE_DELAY := 3.5
|
||||
|
||||
func _ready():
|
||||
var button = $PanelMargin/PanelColumn/CloseButton
|
||||
button.text = "BLOCK"
|
||||
button.text = "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(_on_doors_closing)
|
||||
screen.doors_closing.connect(func(): _on_doors_closing(true))
|
||||
|
||||
EventBus.game_started.connect(_start_floor)
|
||||
|
||||
|
|
@ -46,15 +49,14 @@ func _unhandled_input(event):
|
|||
elif event.keycode == KEY_R:
|
||||
get_tree().reload_current_scene()
|
||||
|
||||
# --- Floor lifecycle ---
|
||||
|
||||
func _start_floor():
|
||||
$SfxOpen.play()
|
||||
$SfxBell.play()
|
||||
doors_closing_flag = false
|
||||
people_in_elevator = 0
|
||||
$PanelMargin/PanelColumn/CloseButton.text = "CLOSE"
|
||||
EventBus.doors_opened.emit()
|
||||
|
||||
# More survivors on higher floors, fewer near the ground
|
||||
var floors_remaining = current_floor - 1
|
||||
survivors_remaining = base_survivors + (floors_remaining * survivors_per_floor_increase)
|
||||
|
||||
|
|
@ -62,8 +64,13 @@ func _start_floor():
|
|||
EventBus.floor_changed.emit(current_floor)
|
||||
EventBus.floor_started.emit(survivors_remaining)
|
||||
|
||||
var floors_descended = 10 - 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()
|
||||
screen.start(current_floor)
|
||||
|
||||
if current_floor <= MOVING_ZONE_START_FLOOR:
|
||||
var floors_below = MOVING_ZONE_START_FLOOR - current_floor
|
||||
|
|
@ -74,39 +81,49 @@ func _start_floor():
|
|||
screen.show_onboarding("BLOCK\nIN GREEN ZONE")
|
||||
get_tree().create_timer(3.0).timeout.connect(
|
||||
func():
|
||||
if not is_instance_valid(screen):
|
||||
return
|
||||
screen.end_onboarding()
|
||||
screen.launch_pulse(),
|
||||
CONNECT_ONE_SHOT
|
||||
)
|
||||
else:
|
||||
screen.launch_pulse() # first survivor arrives
|
||||
|
||||
# --- Input ---
|
||||
get_tree().create_timer(PRE_PULSE_DELAY).timeout.connect(
|
||||
func():
|
||||
if not is_instance_valid(self) or doors_closing_flag:
|
||||
return
|
||||
screen.launch_pulse(),
|
||||
CONNECT_ONE_SHOT
|
||||
)
|
||||
|
||||
func _on_block_pressed():
|
||||
if doors_closing_flag:
|
||||
return
|
||||
$PanelMargin/PanelColumn/Screen.attempt_block()
|
||||
var screen = $PanelMargin/PanelColumn/Screen
|
||||
if screen.pulse_active:
|
||||
screen.attempt_block()
|
||||
else:
|
||||
_on_doors_closing(false)
|
||||
|
||||
# --- Pulse callbacks ---
|
||||
func _on_pulse_started(duration: float):
|
||||
$PanelMargin/PanelColumn/CloseButton.text = "BLOCK"
|
||||
EventBus.pulse_started.emit(duration)
|
||||
|
||||
func _on_pulse_blocked_perfect():
|
||||
EventBus.robot_stun_requested.emit(PERFECT_STUN_DURATION)
|
||||
|
||||
func _on_pulse_blocked():
|
||||
# This survivor made it in
|
||||
$PanelMargin/PanelColumn/CloseButton.text = "CLOSE"
|
||||
EventBus.pulse_blocked.emit()
|
||||
survivors_remaining -= 1
|
||||
people_in_elevator += 1
|
||||
$SfxDing.play()
|
||||
EventBus.people_changed.emit(people_in_elevator, threshold)
|
||||
|
||||
if survivors_remaining <= 0:
|
||||
# Everyone's in, close doors (auto-success). Brief delay so the
|
||||
# last ding doesn't collide with the close sound.
|
||||
get_tree().create_timer(0.25).timeout.connect(_on_doors_closing, CONNECT_ONE_SHOT)
|
||||
return
|
||||
|
||||
# More survivors approaching: launch next pulse after gap
|
||||
var screen = $PanelMargin/PanelColumn/Screen
|
||||
var gap = screen.get_pulse_gap()
|
||||
get_tree().create_timer(gap).timeout.connect(
|
||||
|
|
@ -116,21 +133,19 @@ func _on_pulse_blocked():
|
|||
CONNECT_ONE_SHOT
|
||||
)
|
||||
|
||||
func _on_doors_closing():
|
||||
func _on_doors_closing(fast: bool = false):
|
||||
if doors_closing_flag:
|
||||
return
|
||||
doors_closing_flag = true
|
||||
EventBus.doors_closed.emit()
|
||||
EventBus.doors_closed.emit(fast)
|
||||
|
||||
var screen = $PanelMargin/PanelColumn/Screen
|
||||
|
||||
# Lose: not enough people
|
||||
if people_in_elevator < threshold:
|
||||
screen.show_loss("TOO FEW")
|
||||
EventBus.game_lost.emit("TOO FEW")
|
||||
return
|
||||
|
||||
# Score this floor
|
||||
var base_points = people_in_elevator * points_per_person
|
||||
var bonus = max(0, people_in_elevator - threshold) * points_per_person
|
||||
score += base_points + bonus
|
||||
|
|
@ -141,18 +156,16 @@ func _on_doors_closing():
|
|||
|
||||
current_floor -= 1
|
||||
|
||||
# Win: reached ground floor
|
||||
if current_floor <= 1:
|
||||
screen.show_win()
|
||||
EventBus.floor_changed.emit(current_floor)
|
||||
EventBus.game_won.emit()
|
||||
return
|
||||
|
||||
# Next floor after countdown
|
||||
$SfxClose.play()
|
||||
screen.show_countdown()
|
||||
screen.shrink_block_zone()
|
||||
|
||||
var tween = create_tween()
|
||||
tween.tween_interval(2.0)
|
||||
tween.tween_interval(3.0)
|
||||
tween.tween_callback(_start_floor)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
[ext_resource type="AudioStream" uid="uid://mqoxmuiw0obf" path="res://audio/ElevatorDing1.wav" id="4_p57ef"]
|
||||
[ext_resource type="AudioStream" uid="uid://bavo8f76jr7i6" path="res://audio/ElevatorOpen1.wav" id="5_u5sy4"]
|
||||
[ext_resource type="AudioStream" uid="uid://dgqb1rovgwuan" path="res://audio/ElevatorClose1.wav" id="6_gee14"]
|
||||
[ext_resource type="AudioStream" uid="uid://c2iaspcnilk5" path="res://audio/556700__nachtmahrtv__elevator-bell.wav" id="7_bell"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/component_spawn.tscn" id="9_0tnpc"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/end_screen.tscn" id="10_endsc"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/title_screen.tscn" id="11_title"]
|
||||
|
|
@ -35,6 +36,9 @@ stream = ExtResource("5_u5sy4")
|
|||
[node name="SfxClose" type="AudioStreamPlayer3D" parent="CanvasPanel/ElevatorPanel" unique_id=380307389]
|
||||
stream = ExtResource("6_gee14")
|
||||
|
||||
[node name="SfxBell" type="AudioStreamPlayer3D" parent="CanvasPanel/ElevatorPanel" unique_id=887766]
|
||||
stream = ExtResource("7_bell")
|
||||
|
||||
[node name="SfxChase" type="AudioStreamPlayer3D" parent="CanvasPanel/ElevatorPanel" unique_id=812445001]
|
||||
|
||||
[node name="ComponentSpawn" parent="." unique_id=649225939 instance=ExtResource("9_0tnpc")]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
extends MarginContainer
|
||||
|
||||
var _displayed_floor := -1
|
||||
|
||||
func _ready():
|
||||
$StatsColumn/FloorLabel.text = "FLOOR: 10"
|
||||
$StatsColumn/SavedLabel.text = "SAVED: 0"
|
||||
|
|
@ -12,7 +14,23 @@ func _ready():
|
|||
EventBus.score_changed.connect(update_score)
|
||||
|
||||
func update_floor(floor_num: int):
|
||||
$StatsColumn/FloorLabel.text = "FLOOR: " + str(floor_num)
|
||||
if _displayed_floor == floor_num:
|
||||
return
|
||||
var label = $StatsColumn/FloorLabel
|
||||
var new_text = "FLOOR: " + str(floor_num)
|
||||
if _displayed_floor == -1:
|
||||
label.text = new_text
|
||||
_displayed_floor = floor_num
|
||||
return
|
||||
_displayed_floor = floor_num
|
||||
label.pivot_offset = Vector2(0, label.size.y)
|
||||
var tween = create_tween()
|
||||
tween.tween_property(label, "scale:y", 0.0, 0.15).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_IN)
|
||||
tween.tween_callback(func():
|
||||
label.text = new_text
|
||||
label.pivot_offset = Vector2.ZERO
|
||||
)
|
||||
tween.tween_property(label, "scale:y", 1.0, 0.15).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
||||
|
||||
func update_saved(count: int):
|
||||
$StatsColumn/SavedLabel.text = "SAVED: " + str(count)
|
||||
|
|
|
|||
|
|
@ -1,38 +1,54 @@
|
|||
extends CharacterBody3D
|
||||
|
||||
var robot_delay = randf_range(3.5,7)
|
||||
var robot_ready: bool = false
|
||||
var robot_win: bool = false
|
||||
var speed: int = 3.5
|
||||
var speed: float = 1.0
|
||||
var doors_open: bool = false
|
||||
var stun_remaining: float = 0.0
|
||||
|
||||
var _delay_remaining: float = 0.0
|
||||
var _spawn_transform: Transform3D
|
||||
|
||||
@onready var safety_zone = get_node("/root/Game/World/ElevatorSafeZone")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_spawn_transform = transform
|
||||
EventBus.doors_opened.connect(func(): doors_open = true)
|
||||
EventBus.doors_closed.connect(func(): doors_open = false)
|
||||
EventBus.doors_closed.connect(func(_fast: bool): doors_open = false)
|
||||
EventBus.robot_stun_requested.connect(func(d: float): stun_remaining += d)
|
||||
await get_tree().create_timer(robot_delay).timeout
|
||||
robot_ready = true
|
||||
EventBus.robot_floor_started.connect(_on_floor_started)
|
||||
|
||||
func _on_floor_started(delay: float, new_speed: float) -> void:
|
||||
if robot_win:
|
||||
return
|
||||
transform = _spawn_transform
|
||||
velocity = Vector3.ZERO
|
||||
stun_remaining = 0.0
|
||||
speed = new_speed
|
||||
_delay_remaining = delay
|
||||
robot_ready = false
|
||||
|
||||
func _physics_process(delta):
|
||||
if robot_win:
|
||||
return
|
||||
|
||||
if robot_win == true: return
|
||||
if robot_ready == false: return
|
||||
if not robot_ready:
|
||||
if _delay_remaining > 0.0:
|
||||
_delay_remaining -= delta
|
||||
if _delay_remaining <= 0.0:
|
||||
robot_ready = true
|
||||
return
|
||||
|
||||
if stun_remaining > 0.0:
|
||||
stun_remaining -= delta
|
||||
velocity = Vector3.ZERO
|
||||
move_and_slide()
|
||||
return
|
||||
|
||||
if robot_ready == true:
|
||||
velocity.z -= speed * delta
|
||||
velocity = Vector3(0, 0, -speed)
|
||||
move_and_slide()
|
||||
|
||||
if robot_win == true: return
|
||||
|
||||
|
||||
|
||||
func _on_area_3d_area_entered(area: Area3D) -> void:
|
||||
var safety = safety_zone
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
extends Panel
|
||||
|
||||
# Pulse movement
|
||||
var pulse_speed := 120.0
|
||||
var pulse_speed_initial := 120.0
|
||||
var pulse_speed_per_floor := 8.0
|
||||
var pulse_speed_increase := 15.0
|
||||
var pulse_x := 0.0
|
||||
var pulse_active := false
|
||||
|
|
@ -9,17 +10,17 @@ 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
|
||||
|
||||
# Block zone movement (enabled per-floor by elevator_panel)
|
||||
var block_zone_moving := false
|
||||
var block_zone_speed := 0.0
|
||||
var block_zone_direction := -1
|
||||
var block_zone_min_x := 0.0
|
||||
var block_zone_max_x := 0.0
|
||||
const BLOCK_ZONE_RANGE_LEFT_RATIO := 0.5
|
||||
const MOVING_RANGE_RATIO := 0.6
|
||||
const PULSE_TOP_MARGIN := 40.0
|
||||
const PULSE_BOTTOM_MARGIN := 16.0
|
||||
|
||||
const TRAIL_GHOSTS := 8
|
||||
const TRAIL_SPACING := 3.0
|
||||
|
|
@ -29,10 +30,8 @@ const GLOW_COLOR := Color(1, 0.3, 0.3, 0.35)
|
|||
const PERFECT_ZONE_RATIO := 0.3
|
||||
const PERFECT_ZONE_COLOR := Color(1.0, 0.95, 0.4, 0.85)
|
||||
|
||||
# Visual
|
||||
var base_color: Color
|
||||
|
||||
# State
|
||||
var active := false
|
||||
var pulses_blocked := 0
|
||||
var _ready_pulse_tween: Tween = null
|
||||
|
|
@ -41,16 +40,17 @@ var _glow: ColorRect
|
|||
var _perfect_zone: ColorRect
|
||||
var _face_scale_tween: Tween
|
||||
var _face_shake_tween: Tween
|
||||
var _floor_label: Label
|
||||
|
||||
signal pulse_started(duration: float)
|
||||
signal pulse_blocked
|
||||
signal pulse_blocked_perfect
|
||||
signal doors_closing
|
||||
|
||||
func _ready():
|
||||
# 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)
|
||||
bz.size = Vector2(50, size.y - PULSE_TOP_MARGIN - PULSE_BOTTOM_MARGIN)
|
||||
bz.position = Vector2((size.x - bz.size.x) / 2, PULSE_TOP_MARGIN)
|
||||
|
||||
_perfect_zone = ColorRect.new()
|
||||
_perfect_zone.color = PERFECT_ZONE_COLOR
|
||||
|
|
@ -58,13 +58,11 @@ func _ready():
|
|||
bz.add_child(_perfect_zone)
|
||||
_update_perfect_zone()
|
||||
|
||||
# Pulse line (hidden until first pulse)
|
||||
var sl = $SweepLine
|
||||
sl.size = Vector2(4, size.y - 40)
|
||||
sl.position = Vector2(0, 20)
|
||||
sl.size = Vector2(4, size.y - PULSE_TOP_MARGIN - PULSE_BOTTOM_MARGIN)
|
||||
sl.position = Vector2(0, PULSE_TOP_MARGIN)
|
||||
sl.visible = false
|
||||
|
||||
# AI face
|
||||
var face = $AIFace
|
||||
face.position = Vector2(0, 0)
|
||||
face.size = Vector2(size.x, 30)
|
||||
|
|
@ -88,32 +86,39 @@ func _ready():
|
|||
move_child(ghost, 0)
|
||||
_trail.append(ghost)
|
||||
|
||||
# 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 ---
|
||||
_floor_label = Label.new()
|
||||
_floor_label.add_theme_font_size_override("font_size", 14)
|
||||
_floor_label.position = Vector2(8, 4)
|
||||
_floor_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
add_child(_floor_label)
|
||||
EventBus.floor_changed.connect(_update_floor_label)
|
||||
|
||||
func start():
|
||||
func start(floor_num: int = 10):
|
||||
active = true
|
||||
pulses_blocked = 0
|
||||
pulse_speed = 120.0
|
||||
var floors_descended = 10 - floor_num
|
||||
pulse_speed = pulse_speed_initial + floors_descended * pulse_speed_per_floor
|
||||
pulse_gap = 1.0
|
||||
$AIFace.text = ">:)"
|
||||
$TargetZone.visible = true
|
||||
block_zone_moving = false
|
||||
$TargetZone.position.x = size.x - $TargetZone.size.x - 10
|
||||
$TargetZone.position.x = (size.x - $TargetZone.size.x) / 2
|
||||
|
||||
func set_block_zone_movement(speed: float):
|
||||
block_zone_speed = speed
|
||||
block_zone_moving = speed > 0.0
|
||||
var bz = $TargetZone
|
||||
block_zone_max_x = size.x - bz.size.x - 10
|
||||
block_zone_min_x = size.x * BLOCK_ZONE_RANGE_LEFT_RATIO
|
||||
bz.position.x = block_zone_max_x
|
||||
var range_half = size.x * MOVING_RANGE_RATIO / 2
|
||||
var center_x = size.x / 2
|
||||
block_zone_min_x = center_x - range_half
|
||||
block_zone_max_x = center_x + range_half - bz.size.x
|
||||
bz.position.x = (size.x - bz.size.x) / 2
|
||||
block_zone_direction = -1
|
||||
|
||||
func stop():
|
||||
|
|
@ -125,22 +130,39 @@ func stop():
|
|||
func shrink_block_zone():
|
||||
var bz = $TargetZone
|
||||
var new_width = max(bz.size.x - block_zone_shrink, block_zone_min)
|
||||
var new_x = size.x - new_width - 10
|
||||
var new_x = (size.x - new_width) / 2
|
||||
var tween = create_tween()
|
||||
tween.set_parallel(true)
|
||||
tween.tween_property(bz, "size:x", new_width, 0.3)
|
||||
tween.tween_property(bz, "position:x", new_x, 0.3)
|
||||
tween.tween_method(func(_v): _update_perfect_zone(), 0.0, 1.0, 0.3)
|
||||
|
||||
var _displayed_floor := -1
|
||||
|
||||
func _update_floor_label(floor_num: int):
|
||||
if _displayed_floor == floor_num:
|
||||
return
|
||||
var new_text = "FL " + str(floor_num)
|
||||
if _displayed_floor == -1:
|
||||
_floor_label.text = new_text
|
||||
_displayed_floor = floor_num
|
||||
return
|
||||
_displayed_floor = floor_num
|
||||
_floor_label.pivot_offset = Vector2(0, _floor_label.size.y)
|
||||
var tween = create_tween()
|
||||
tween.tween_property(_floor_label, "scale:y", 0.0, 0.15).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_IN)
|
||||
tween.tween_callback(func():
|
||||
_floor_label.text = new_text
|
||||
_floor_label.pivot_offset = Vector2.ZERO
|
||||
)
|
||||
tween.tween_property(_floor_label, "scale:y", 1.0, 0.15).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
||||
|
||||
func _update_perfect_zone():
|
||||
var bz = $TargetZone
|
||||
var width = bz.size.x * PERFECT_ZONE_RATIO
|
||||
_perfect_zone.size = Vector2(width, bz.size.y)
|
||||
_perfect_zone.position = Vector2((bz.size.x - width) / 2.0, 0)
|
||||
|
||||
# --- Pulse logic ---
|
||||
|
||||
# Called by elevator_panel when a survivor reaches the door.
|
||||
func launch_pulse():
|
||||
if not active:
|
||||
return
|
||||
|
|
@ -153,6 +175,7 @@ func launch_pulse():
|
|||
ghost.visible = true
|
||||
$AIFace.text = ">:)"
|
||||
_start_ready_pulse()
|
||||
pulse_started.emit(size.x / pulse_speed)
|
||||
|
||||
func get_pulse_gap() -> float:
|
||||
return pulse_gap
|
||||
|
|
@ -182,7 +205,6 @@ func _process(delta):
|
|||
_trail[i].visible = gx >= 0
|
||||
_trail[i].position = Vector2(gx, $SweepLine.position.y)
|
||||
|
||||
# Pulse reached the far side unblocked: AI wins, doors close
|
||||
if pulse_x >= size.x:
|
||||
pulse_active = false
|
||||
_hide_pulse_visuals()
|
||||
|
|
@ -192,17 +214,15 @@ func _process(delta):
|
|||
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
|
||||
return false
|
||||
|
||||
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
|
||||
var perfect_left = bz_left + _perfect_zone.position.x
|
||||
var perfect_right = perfect_left + _perfect_zone.size.x
|
||||
var was_perfect = pulse_x >= perfect_left and pulse_x <= perfect_right
|
||||
|
|
@ -219,7 +239,6 @@ func attempt_block() -> bool:
|
|||
pulse_blocked_perfect.emit()
|
||||
return true
|
||||
else:
|
||||
# Mistimed: same result as letting it through
|
||||
pulse_active = false
|
||||
_hide_pulse_visuals()
|
||||
$AIFace.text = ":D"
|
||||
|
|
@ -229,8 +248,6 @@ func attempt_block() -> bool:
|
|||
doors_closing.emit()
|
||||
return false
|
||||
|
||||
# --- Display helpers ---
|
||||
|
||||
func flash(color: Color):
|
||||
var style = get_theme_stylebox("panel") as StyleBoxFlat
|
||||
if not style:
|
||||
|
|
@ -266,10 +283,12 @@ func show_onboarding(msg: String):
|
|||
$AIFace.add_theme_font_size_override("font_size", 18)
|
||||
$AIFace.size = Vector2(size.x, 60)
|
||||
$AIFace.text = msg
|
||||
$TargetZone.visible = false
|
||||
|
||||
func end_onboarding():
|
||||
$AIFace.add_theme_font_size_override("font_size", 32)
|
||||
$AIFace.size = Vector2(size.x, 30)
|
||||
$TargetZone.visible = true
|
||||
|
||||
func _start_ready_pulse():
|
||||
if _ready_pulse_tween:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ func _ready():
|
|||
func _unhandled_input(event):
|
||||
if event is InputEventKey and event.pressed and not event.echo:
|
||||
if event.keycode == KEY_SPACE or event.keycode == KEY_ENTER:
|
||||
get_viewport().set_input_as_handled()
|
||||
_start()
|
||||
|
||||
func _start():
|
||||
|
|
|
|||
|
|
@ -43,10 +43,11 @@ theme_override_constants/margin_bottom = 48
|
|||
theme_override_constants/separation = 24
|
||||
|
||||
[node name="Title" type="Label" parent="Center/Card/Margin/Column"]
|
||||
text = "ELEVATOR"
|
||||
text = "AGENTIC INCIDENT
|
||||
(A.I.)"
|
||||
horizontal_alignment = 1
|
||||
theme_override_colors/font_color = Color(0.2, 1, 0.2, 1)
|
||||
theme_override_font_sizes/font_size = 72
|
||||
theme_override_font_sizes/font_size = 48
|
||||
|
||||
[node name="Prompt" type="Label" parent="Center/Card/Margin/Column"]
|
||||
text = "PRESS SPACE TO START"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
extends Node
|
||||
|
||||
@warning_ignore_start("unused_signal") # since otherwise Godot will throw a warning that the signal is unused in current scope
|
||||
@warning_ignore_start("unused_signal")
|
||||
|
||||
signal floor_changed(floor_num: int)
|
||||
signal saved_changed(count: int)
|
||||
|
|
@ -11,7 +11,10 @@ signal game_won
|
|||
signal game_lost(reason: String)
|
||||
signal floor_started(survivor_count: int)
|
||||
signal doors_opened
|
||||
signal doors_closed
|
||||
signal doors_closed(fast: bool)
|
||||
signal pulse_started(duration: float)
|
||||
signal pulse_blocked
|
||||
signal robot_stun_requested(duration: float)
|
||||
signal robot_floor_started(delay: float, robot_speed: float)
|
||||
|
||||
@warning_ignore_restore("unused_signal") # put any future signals you add between the two ignore annotations
|
||||
@warning_ignore_restore("unused_signal")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue