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"]
|
[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="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"]
|
[sub_resource type="Animation" id="Animation_8o2wm"]
|
||||||
length = 0.001
|
length = 0.001
|
||||||
|
|
@ -93,6 +94,7 @@ _data = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Elevator" type="Node3D" unique_id=242258467]
|
[node name="Elevator" type="Node3D" unique_id=242258467]
|
||||||
|
script = ExtResource("2_elev")
|
||||||
|
|
||||||
[node name="ElevatorDoorLeft" parent="." unique_id=1751198646 instance=ExtResource("1_uuuf0")]
|
[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)
|
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
|
extends PanelContainer
|
||||||
|
|
||||||
# Floor state
|
|
||||||
var current_floor := 10
|
var current_floor := 10
|
||||||
var saved_count := 0
|
var saved_count := 0
|
||||||
var doors_closing_flag := false
|
var doors_closing_flag := false
|
||||||
var _onboarded := false
|
var _onboarded := false
|
||||||
|
|
||||||
# Survivors per floor: more at top, fewer as you descend
|
|
||||||
var base_survivors := 2
|
var base_survivors := 2
|
||||||
var survivors_per_floor_increase := 1 # per floor above ground
|
var survivors_per_floor_increase := 1
|
||||||
var survivors_remaining := 0
|
var survivors_remaining := 0
|
||||||
|
|
||||||
# Flat threshold: must save at least this many per floor
|
|
||||||
var threshold := 2
|
var threshold := 2
|
||||||
|
|
||||||
# Scoring
|
|
||||||
var score := 0
|
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_START_FLOOR := 7
|
||||||
const MOVING_ZONE_BASE_SPEED := 40.0
|
const MOVING_ZONE_BASE_SPEED := 40.0
|
||||||
const MOVING_ZONE_SPEED_PER_FLOOR := 12.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
|
var people_in_elevator := 0
|
||||||
|
|
||||||
const PERFECT_STUN_DURATION := 0.25
|
const PERFECT_STUN_DURATION := 0.25
|
||||||
|
const PRE_PULSE_DELAY := 3.5
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var button = $PanelMargin/PanelColumn/CloseButton
|
var button = $PanelMargin/PanelColumn/CloseButton
|
||||||
button.text = "BLOCK"
|
button.text = "CLOSE"
|
||||||
button.pressed.connect(_on_block_pressed)
|
button.pressed.connect(_on_block_pressed)
|
||||||
|
|
||||||
var screen = $PanelMargin/PanelColumn/Screen
|
var screen = $PanelMargin/PanelColumn/Screen
|
||||||
|
screen.pulse_started.connect(_on_pulse_started)
|
||||||
screen.pulse_blocked.connect(_on_pulse_blocked)
|
screen.pulse_blocked.connect(_on_pulse_blocked)
|
||||||
screen.pulse_blocked_perfect.connect(_on_pulse_blocked_perfect)
|
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)
|
EventBus.game_started.connect(_start_floor)
|
||||||
|
|
||||||
|
|
@ -46,15 +49,14 @@ func _unhandled_input(event):
|
||||||
elif event.keycode == KEY_R:
|
elif event.keycode == KEY_R:
|
||||||
get_tree().reload_current_scene()
|
get_tree().reload_current_scene()
|
||||||
|
|
||||||
# --- Floor lifecycle ---
|
|
||||||
|
|
||||||
func _start_floor():
|
func _start_floor():
|
||||||
$SfxOpen.play()
|
$SfxOpen.play()
|
||||||
|
$SfxBell.play()
|
||||||
doors_closing_flag = false
|
doors_closing_flag = false
|
||||||
people_in_elevator = 0
|
people_in_elevator = 0
|
||||||
|
$PanelMargin/PanelColumn/CloseButton.text = "CLOSE"
|
||||||
EventBus.doors_opened.emit()
|
EventBus.doors_opened.emit()
|
||||||
|
|
||||||
# More survivors on higher floors, fewer near the ground
|
|
||||||
var floors_remaining = current_floor - 1
|
var floors_remaining = current_floor - 1
|
||||||
survivors_remaining = base_survivors + (floors_remaining * survivors_per_floor_increase)
|
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_changed.emit(current_floor)
|
||||||
EventBus.floor_started.emit(survivors_remaining)
|
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
|
var screen = $PanelMargin/PanelColumn/Screen
|
||||||
screen.start()
|
screen.start(current_floor)
|
||||||
|
|
||||||
if current_floor <= MOVING_ZONE_START_FLOOR:
|
if current_floor <= MOVING_ZONE_START_FLOOR:
|
||||||
var floors_below = MOVING_ZONE_START_FLOOR - current_floor
|
var floors_below = MOVING_ZONE_START_FLOOR - current_floor
|
||||||
|
|
@ -74,39 +81,49 @@ func _start_floor():
|
||||||
screen.show_onboarding("BLOCK\nIN GREEN ZONE")
|
screen.show_onboarding("BLOCK\nIN GREEN ZONE")
|
||||||
get_tree().create_timer(3.0).timeout.connect(
|
get_tree().create_timer(3.0).timeout.connect(
|
||||||
func():
|
func():
|
||||||
|
if not is_instance_valid(screen):
|
||||||
|
return
|
||||||
screen.end_onboarding()
|
screen.end_onboarding()
|
||||||
screen.launch_pulse(),
|
screen.launch_pulse(),
|
||||||
CONNECT_ONE_SHOT
|
CONNECT_ONE_SHOT
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
screen.launch_pulse() # first survivor arrives
|
get_tree().create_timer(PRE_PULSE_DELAY).timeout.connect(
|
||||||
|
func():
|
||||||
# --- Input ---
|
if not is_instance_valid(self) or doors_closing_flag:
|
||||||
|
return
|
||||||
|
screen.launch_pulse(),
|
||||||
|
CONNECT_ONE_SHOT
|
||||||
|
)
|
||||||
|
|
||||||
func _on_block_pressed():
|
func _on_block_pressed():
|
||||||
if doors_closing_flag:
|
if doors_closing_flag:
|
||||||
return
|
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():
|
func _on_pulse_blocked_perfect():
|
||||||
EventBus.robot_stun_requested.emit(PERFECT_STUN_DURATION)
|
EventBus.robot_stun_requested.emit(PERFECT_STUN_DURATION)
|
||||||
|
|
||||||
func _on_pulse_blocked():
|
func _on_pulse_blocked():
|
||||||
# This survivor made it in
|
$PanelMargin/PanelColumn/CloseButton.text = "CLOSE"
|
||||||
|
EventBus.pulse_blocked.emit()
|
||||||
survivors_remaining -= 1
|
survivors_remaining -= 1
|
||||||
people_in_elevator += 1
|
people_in_elevator += 1
|
||||||
$SfxDing.play()
|
$SfxDing.play()
|
||||||
EventBus.people_changed.emit(people_in_elevator, threshold)
|
EventBus.people_changed.emit(people_in_elevator, threshold)
|
||||||
|
|
||||||
if survivors_remaining <= 0:
|
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)
|
get_tree().create_timer(0.25).timeout.connect(_on_doors_closing, CONNECT_ONE_SHOT)
|
||||||
return
|
return
|
||||||
|
|
||||||
# More survivors approaching: launch next pulse after gap
|
|
||||||
var screen = $PanelMargin/PanelColumn/Screen
|
var screen = $PanelMargin/PanelColumn/Screen
|
||||||
var gap = screen.get_pulse_gap()
|
var gap = screen.get_pulse_gap()
|
||||||
get_tree().create_timer(gap).timeout.connect(
|
get_tree().create_timer(gap).timeout.connect(
|
||||||
|
|
@ -116,21 +133,19 @@ func _on_pulse_blocked():
|
||||||
CONNECT_ONE_SHOT
|
CONNECT_ONE_SHOT
|
||||||
)
|
)
|
||||||
|
|
||||||
func _on_doors_closing():
|
func _on_doors_closing(fast: bool = false):
|
||||||
if doors_closing_flag:
|
if doors_closing_flag:
|
||||||
return
|
return
|
||||||
doors_closing_flag = true
|
doors_closing_flag = true
|
||||||
EventBus.doors_closed.emit()
|
EventBus.doors_closed.emit(fast)
|
||||||
|
|
||||||
var screen = $PanelMargin/PanelColumn/Screen
|
var screen = $PanelMargin/PanelColumn/Screen
|
||||||
|
|
||||||
# Lose: not enough people
|
|
||||||
if people_in_elevator < threshold:
|
if people_in_elevator < threshold:
|
||||||
screen.show_loss("TOO FEW")
|
screen.show_loss("TOO FEW")
|
||||||
EventBus.game_lost.emit("TOO FEW")
|
EventBus.game_lost.emit("TOO FEW")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Score this floor
|
|
||||||
var base_points = people_in_elevator * points_per_person
|
var base_points = people_in_elevator * points_per_person
|
||||||
var bonus = max(0, people_in_elevator - threshold) * points_per_person
|
var bonus = max(0, people_in_elevator - threshold) * points_per_person
|
||||||
score += base_points + bonus
|
score += base_points + bonus
|
||||||
|
|
@ -141,18 +156,16 @@ func _on_doors_closing():
|
||||||
|
|
||||||
current_floor -= 1
|
current_floor -= 1
|
||||||
|
|
||||||
# Win: reached ground floor
|
|
||||||
if current_floor <= 1:
|
if current_floor <= 1:
|
||||||
screen.show_win()
|
screen.show_win()
|
||||||
EventBus.floor_changed.emit(current_floor)
|
EventBus.floor_changed.emit(current_floor)
|
||||||
EventBus.game_won.emit()
|
EventBus.game_won.emit()
|
||||||
return
|
return
|
||||||
|
|
||||||
# Next floor after countdown
|
|
||||||
$SfxClose.play()
|
$SfxClose.play()
|
||||||
screen.show_countdown()
|
screen.show_countdown()
|
||||||
screen.shrink_block_zone()
|
screen.shrink_block_zone()
|
||||||
|
|
||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
tween.tween_interval(2.0)
|
tween.tween_interval(3.0)
|
||||||
tween.tween_callback(_start_floor)
|
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://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://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://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/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/end_screen.tscn" id="10_endsc"]
|
||||||
[ext_resource type="PackedScene" path="res://scenes/title_screen.tscn" id="11_title"]
|
[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]
|
[node name="SfxClose" type="AudioStreamPlayer3D" parent="CanvasPanel/ElevatorPanel" unique_id=380307389]
|
||||||
stream = ExtResource("6_gee14")
|
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="SfxChase" type="AudioStreamPlayer3D" parent="CanvasPanel/ElevatorPanel" unique_id=812445001]
|
||||||
|
|
||||||
[node name="ComponentSpawn" parent="." unique_id=649225939 instance=ExtResource("9_0tnpc")]
|
[node name="ComponentSpawn" parent="." unique_id=649225939 instance=ExtResource("9_0tnpc")]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
extends MarginContainer
|
extends MarginContainer
|
||||||
|
|
||||||
|
var _displayed_floor := -1
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
$StatsColumn/FloorLabel.text = "FLOOR: 10"
|
$StatsColumn/FloorLabel.text = "FLOOR: 10"
|
||||||
$StatsColumn/SavedLabel.text = "SAVED: 0"
|
$StatsColumn/SavedLabel.text = "SAVED: 0"
|
||||||
|
|
@ -12,7 +14,23 @@ func _ready():
|
||||||
EventBus.score_changed.connect(update_score)
|
EventBus.score_changed.connect(update_score)
|
||||||
|
|
||||||
func update_floor(floor_num: int):
|
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):
|
func update_saved(count: int):
|
||||||
$StatsColumn/SavedLabel.text = "SAVED: " + str(count)
|
$StatsColumn/SavedLabel.text = "SAVED: " + str(count)
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,54 @@
|
||||||
extends CharacterBody3D
|
extends CharacterBody3D
|
||||||
|
|
||||||
var robot_delay = randf_range(3.5,7)
|
|
||||||
var robot_ready: bool = false
|
var robot_ready: bool = false
|
||||||
var robot_win: bool = false
|
var robot_win: bool = false
|
||||||
var speed: int = 3.5
|
var speed: float = 1.0
|
||||||
var doors_open: bool = false
|
var doors_open: bool = false
|
||||||
var stun_remaining: float = 0.0
|
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")
|
@onready var safety_zone = get_node("/root/Game/World/ElevatorSafeZone")
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
_spawn_transform = transform
|
||||||
EventBus.doors_opened.connect(func(): doors_open = true)
|
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)
|
EventBus.robot_stun_requested.connect(func(d: float): stun_remaining += d)
|
||||||
await get_tree().create_timer(robot_delay).timeout
|
EventBus.robot_floor_started.connect(_on_floor_started)
|
||||||
robot_ready = true
|
|
||||||
|
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):
|
func _physics_process(delta):
|
||||||
|
if robot_win:
|
||||||
|
return
|
||||||
|
|
||||||
if robot_win == true: return
|
if not robot_ready:
|
||||||
if robot_ready == false: return
|
if _delay_remaining > 0.0:
|
||||||
|
_delay_remaining -= delta
|
||||||
|
if _delay_remaining <= 0.0:
|
||||||
|
robot_ready = true
|
||||||
|
return
|
||||||
|
|
||||||
if stun_remaining > 0.0:
|
if stun_remaining > 0.0:
|
||||||
stun_remaining -= delta
|
stun_remaining -= delta
|
||||||
|
velocity = Vector3.ZERO
|
||||||
|
move_and_slide()
|
||||||
return
|
return
|
||||||
|
|
||||||
if robot_ready == true:
|
velocity = Vector3(0, 0, -speed)
|
||||||
velocity.z -= speed * delta
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
if robot_win == true: return
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_area_3d_area_entered(area: Area3D) -> void:
|
func _on_area_3d_area_entered(area: Area3D) -> void:
|
||||||
var safety = safety_zone
|
var safety = safety_zone
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
extends Panel
|
extends Panel
|
||||||
|
|
||||||
# Pulse movement
|
|
||||||
var pulse_speed := 120.0
|
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_speed_increase := 15.0
|
||||||
var pulse_x := 0.0
|
var pulse_x := 0.0
|
||||||
var pulse_active := false
|
var pulse_active := false
|
||||||
|
|
@ -9,17 +10,17 @@ var pulse_gap := 1.0
|
||||||
var pulse_gap_decrease := 0.05
|
var pulse_gap_decrease := 0.05
|
||||||
var pulse_gap_min := 0.3
|
var pulse_gap_min := 0.3
|
||||||
|
|
||||||
# Block zone (shrinks per floor, not per block)
|
|
||||||
var block_zone_shrink := 3.0
|
var block_zone_shrink := 3.0
|
||||||
var block_zone_min := 12.0
|
var block_zone_min := 12.0
|
||||||
|
|
||||||
# Block zone movement (enabled per-floor by elevator_panel)
|
|
||||||
var block_zone_moving := false
|
var block_zone_moving := false
|
||||||
var block_zone_speed := 0.0
|
var block_zone_speed := 0.0
|
||||||
var block_zone_direction := -1
|
var block_zone_direction := -1
|
||||||
var block_zone_min_x := 0.0
|
var block_zone_min_x := 0.0
|
||||||
var block_zone_max_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_GHOSTS := 8
|
||||||
const TRAIL_SPACING := 3.0
|
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_RATIO := 0.3
|
||||||
const PERFECT_ZONE_COLOR := Color(1.0, 0.95, 0.4, 0.85)
|
const PERFECT_ZONE_COLOR := Color(1.0, 0.95, 0.4, 0.85)
|
||||||
|
|
||||||
# Visual
|
|
||||||
var base_color: Color
|
var base_color: Color
|
||||||
|
|
||||||
# State
|
|
||||||
var active := false
|
var active := false
|
||||||
var pulses_blocked := 0
|
var pulses_blocked := 0
|
||||||
var _ready_pulse_tween: Tween = null
|
var _ready_pulse_tween: Tween = null
|
||||||
|
|
@ -41,16 +40,17 @@ var _glow: ColorRect
|
||||||
var _perfect_zone: ColorRect
|
var _perfect_zone: ColorRect
|
||||||
var _face_scale_tween: Tween
|
var _face_scale_tween: Tween
|
||||||
var _face_shake_tween: Tween
|
var _face_shake_tween: Tween
|
||||||
|
var _floor_label: Label
|
||||||
|
|
||||||
|
signal pulse_started(duration: float)
|
||||||
signal pulse_blocked
|
signal pulse_blocked
|
||||||
signal pulse_blocked_perfect
|
signal pulse_blocked_perfect
|
||||||
signal doors_closing
|
signal doors_closing
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
# Block zone on right side of screen
|
|
||||||
var bz = $TargetZone
|
var bz = $TargetZone
|
||||||
bz.size = Vector2(50, size.y - 40)
|
bz.size = Vector2(50, size.y - PULSE_TOP_MARGIN - PULSE_BOTTOM_MARGIN)
|
||||||
bz.position = Vector2(size.x - bz.size.x - 10, 20)
|
bz.position = Vector2((size.x - bz.size.x) / 2, PULSE_TOP_MARGIN)
|
||||||
|
|
||||||
_perfect_zone = ColorRect.new()
|
_perfect_zone = ColorRect.new()
|
||||||
_perfect_zone.color = PERFECT_ZONE_COLOR
|
_perfect_zone.color = PERFECT_ZONE_COLOR
|
||||||
|
|
@ -58,13 +58,11 @@ func _ready():
|
||||||
bz.add_child(_perfect_zone)
|
bz.add_child(_perfect_zone)
|
||||||
_update_perfect_zone()
|
_update_perfect_zone()
|
||||||
|
|
||||||
# Pulse line (hidden until first pulse)
|
|
||||||
var sl = $SweepLine
|
var sl = $SweepLine
|
||||||
sl.size = Vector2(4, size.y - 40)
|
sl.size = Vector2(4, size.y - PULSE_TOP_MARGIN - PULSE_BOTTOM_MARGIN)
|
||||||
sl.position = Vector2(0, 20)
|
sl.position = Vector2(0, PULSE_TOP_MARGIN)
|
||||||
sl.visible = false
|
sl.visible = false
|
||||||
|
|
||||||
# AI face
|
|
||||||
var face = $AIFace
|
var face = $AIFace
|
||||||
face.position = Vector2(0, 0)
|
face.position = Vector2(0, 0)
|
||||||
face.size = Vector2(size.x, 30)
|
face.size = Vector2(size.x, 30)
|
||||||
|
|
@ -88,32 +86,39 @@ func _ready():
|
||||||
move_child(ghost, 0)
|
move_child(ghost, 0)
|
||||||
_trail.append(ghost)
|
_trail.append(ghost)
|
||||||
|
|
||||||
# Duplicate the StyleBoxFlat so flash tweens don't bleed into other panels
|
|
||||||
var style = get_theme_stylebox("panel") as StyleBoxFlat
|
var style = get_theme_stylebox("panel") as StyleBoxFlat
|
||||||
if style:
|
if style:
|
||||||
style = style.duplicate()
|
style = style.duplicate()
|
||||||
add_theme_stylebox_override("panel", style)
|
add_theme_stylebox_override("panel", style)
|
||||||
base_color = style.bg_color
|
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
|
active = true
|
||||||
pulses_blocked = 0
|
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
|
pulse_gap = 1.0
|
||||||
$AIFace.text = ">:)"
|
$AIFace.text = ">:)"
|
||||||
$TargetZone.visible = true
|
$TargetZone.visible = true
|
||||||
block_zone_moving = false
|
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):
|
func set_block_zone_movement(speed: float):
|
||||||
block_zone_speed = speed
|
block_zone_speed = speed
|
||||||
block_zone_moving = speed > 0.0
|
block_zone_moving = speed > 0.0
|
||||||
var bz = $TargetZone
|
var bz = $TargetZone
|
||||||
block_zone_max_x = size.x - bz.size.x - 10
|
var range_half = size.x * MOVING_RANGE_RATIO / 2
|
||||||
block_zone_min_x = size.x * BLOCK_ZONE_RANGE_LEFT_RATIO
|
var center_x = size.x / 2
|
||||||
bz.position.x = block_zone_max_x
|
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
|
block_zone_direction = -1
|
||||||
|
|
||||||
func stop():
|
func stop():
|
||||||
|
|
@ -125,22 +130,39 @@ func stop():
|
||||||
func shrink_block_zone():
|
func shrink_block_zone():
|
||||||
var bz = $TargetZone
|
var bz = $TargetZone
|
||||||
var new_width = max(bz.size.x - block_zone_shrink, block_zone_min)
|
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()
|
var tween = create_tween()
|
||||||
tween.set_parallel(true)
|
tween.set_parallel(true)
|
||||||
tween.tween_property(bz, "size:x", new_width, 0.3)
|
tween.tween_property(bz, "size:x", new_width, 0.3)
|
||||||
tween.tween_property(bz, "position:x", new_x, 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)
|
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():
|
func _update_perfect_zone():
|
||||||
var bz = $TargetZone
|
var bz = $TargetZone
|
||||||
var width = bz.size.x * PERFECT_ZONE_RATIO
|
var width = bz.size.x * PERFECT_ZONE_RATIO
|
||||||
_perfect_zone.size = Vector2(width, bz.size.y)
|
_perfect_zone.size = Vector2(width, bz.size.y)
|
||||||
_perfect_zone.position = Vector2((bz.size.x - width) / 2.0, 0)
|
_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():
|
func launch_pulse():
|
||||||
if not active:
|
if not active:
|
||||||
return
|
return
|
||||||
|
|
@ -153,6 +175,7 @@ func launch_pulse():
|
||||||
ghost.visible = true
|
ghost.visible = true
|
||||||
$AIFace.text = ">:)"
|
$AIFace.text = ">:)"
|
||||||
_start_ready_pulse()
|
_start_ready_pulse()
|
||||||
|
pulse_started.emit(size.x / pulse_speed)
|
||||||
|
|
||||||
func get_pulse_gap() -> float:
|
func get_pulse_gap() -> float:
|
||||||
return pulse_gap
|
return pulse_gap
|
||||||
|
|
@ -182,7 +205,6 @@ func _process(delta):
|
||||||
_trail[i].visible = gx >= 0
|
_trail[i].visible = gx >= 0
|
||||||
_trail[i].position = Vector2(gx, $SweepLine.position.y)
|
_trail[i].position = Vector2(gx, $SweepLine.position.y)
|
||||||
|
|
||||||
# Pulse reached the far side unblocked: AI wins, doors close
|
|
||||||
if pulse_x >= size.x:
|
if pulse_x >= size.x:
|
||||||
pulse_active = false
|
pulse_active = false
|
||||||
_hide_pulse_visuals()
|
_hide_pulse_visuals()
|
||||||
|
|
@ -192,17 +214,15 @@ func _process(delta):
|
||||||
active = false
|
active = false
|
||||||
doors_closing.emit()
|
doors_closing.emit()
|
||||||
|
|
||||||
# Called by elevator_panel when player presses BLOCK.
|
|
||||||
func attempt_block() -> bool:
|
func attempt_block() -> bool:
|
||||||
if not pulse_active:
|
if not pulse_active:
|
||||||
return false # no pulse on screen, button does nothing
|
return false
|
||||||
|
|
||||||
var bz = $TargetZone
|
var bz = $TargetZone
|
||||||
var bz_left = bz.position.x
|
var bz_left = bz.position.x
|
||||||
var bz_right = bz.position.x + bz.size.x
|
var bz_right = bz.position.x + bz.size.x
|
||||||
|
|
||||||
if pulse_x >= bz_left and pulse_x <= bz_right:
|
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_left = bz_left + _perfect_zone.position.x
|
||||||
var perfect_right = perfect_left + _perfect_zone.size.x
|
var perfect_right = perfect_left + _perfect_zone.size.x
|
||||||
var was_perfect = pulse_x >= perfect_left and pulse_x <= perfect_right
|
var was_perfect = pulse_x >= perfect_left and pulse_x <= perfect_right
|
||||||
|
|
@ -219,7 +239,6 @@ func attempt_block() -> bool:
|
||||||
pulse_blocked_perfect.emit()
|
pulse_blocked_perfect.emit()
|
||||||
return true
|
return true
|
||||||
else:
|
else:
|
||||||
# Mistimed: same result as letting it through
|
|
||||||
pulse_active = false
|
pulse_active = false
|
||||||
_hide_pulse_visuals()
|
_hide_pulse_visuals()
|
||||||
$AIFace.text = ":D"
|
$AIFace.text = ":D"
|
||||||
|
|
@ -229,8 +248,6 @@ func attempt_block() -> bool:
|
||||||
doors_closing.emit()
|
doors_closing.emit()
|
||||||
return false
|
return false
|
||||||
|
|
||||||
# --- Display helpers ---
|
|
||||||
|
|
||||||
func flash(color: Color):
|
func flash(color: Color):
|
||||||
var style = get_theme_stylebox("panel") as StyleBoxFlat
|
var style = get_theme_stylebox("panel") as StyleBoxFlat
|
||||||
if not style:
|
if not style:
|
||||||
|
|
@ -266,10 +283,12 @@ func show_onboarding(msg: String):
|
||||||
$AIFace.add_theme_font_size_override("font_size", 18)
|
$AIFace.add_theme_font_size_override("font_size", 18)
|
||||||
$AIFace.size = Vector2(size.x, 60)
|
$AIFace.size = Vector2(size.x, 60)
|
||||||
$AIFace.text = msg
|
$AIFace.text = msg
|
||||||
|
$TargetZone.visible = false
|
||||||
|
|
||||||
func end_onboarding():
|
func end_onboarding():
|
||||||
$AIFace.add_theme_font_size_override("font_size", 32)
|
$AIFace.add_theme_font_size_override("font_size", 32)
|
||||||
$AIFace.size = Vector2(size.x, 30)
|
$AIFace.size = Vector2(size.x, 30)
|
||||||
|
$TargetZone.visible = true
|
||||||
|
|
||||||
func _start_ready_pulse():
|
func _start_ready_pulse():
|
||||||
if _ready_pulse_tween:
|
if _ready_pulse_tween:
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ func _ready():
|
||||||
func _unhandled_input(event):
|
func _unhandled_input(event):
|
||||||
if event is InputEventKey and event.pressed and not event.echo:
|
if event is InputEventKey and event.pressed and not event.echo:
|
||||||
if event.keycode == KEY_SPACE or event.keycode == KEY_ENTER:
|
if event.keycode == KEY_SPACE or event.keycode == KEY_ENTER:
|
||||||
|
get_viewport().set_input_as_handled()
|
||||||
_start()
|
_start()
|
||||||
|
|
||||||
func _start():
|
func _start():
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,11 @@ theme_override_constants/margin_bottom = 48
|
||||||
theme_override_constants/separation = 24
|
theme_override_constants/separation = 24
|
||||||
|
|
||||||
[node name="Title" type="Label" parent="Center/Card/Margin/Column"]
|
[node name="Title" type="Label" parent="Center/Card/Margin/Column"]
|
||||||
text = "ELEVATOR"
|
text = "AGENTIC INCIDENT
|
||||||
|
(A.I.)"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
theme_override_colors/font_color = Color(0.2, 1, 0.2, 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"]
|
[node name="Prompt" type="Label" parent="Center/Card/Margin/Column"]
|
||||||
text = "PRESS SPACE TO START"
|
text = "PRESS SPACE TO START"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
extends Node
|
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 floor_changed(floor_num: int)
|
||||||
signal saved_changed(count: int)
|
signal saved_changed(count: int)
|
||||||
|
|
@ -11,7 +11,10 @@ signal game_won
|
||||||
signal game_lost(reason: String)
|
signal game_lost(reason: String)
|
||||||
signal floor_started(survivor_count: int)
|
signal floor_started(survivor_count: int)
|
||||||
signal doors_opened
|
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_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