pulse node, shaft strip, constantify, etc.
This commit is contained in:
parent
d4c609e1af
commit
0b6d121986
24 changed files with 645 additions and 245 deletions
|
|
@ -19,6 +19,14 @@ config/icon="res://icon.svg"
|
||||||
|
|
||||||
EventBus="*uid://hxpxcxvxcisu"
|
EventBus="*uid://hxpxcxvxcisu"
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
pause={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194305,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
3d/physics_engine="Jolt Physics"
|
3d/physics_engine="Jolt Physics"
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,7 @@ var _active_walkers: Array[Node] = []
|
||||||
var _batch_generation: int = 0
|
var _batch_generation: int = 0
|
||||||
|
|
||||||
@onready var survivor = preload("res://scenes/survivor.tscn")
|
@onready var survivor = preload("res://scenes/survivor.tscn")
|
||||||
@onready var survivor_spawn = get_node("/root/Game/World/SurvivorSpawn")
|
@export var survivor_spawn: Node3D
|
||||||
@onready var start_pos: Vector3 = survivor_spawn.global_position
|
|
||||||
|
|
||||||
func _enter_tree() -> void:
|
func _enter_tree() -> void:
|
||||||
EventBus.floor_started.connect(_on_floor_started, CONNECT_DEFERRED)
|
EventBus.floor_started.connect(_on_floor_started, CONNECT_DEFERRED)
|
||||||
|
|
@ -38,11 +37,11 @@ func _run_batch(count: int, generation: int) -> void:
|
||||||
return
|
return
|
||||||
_spawn_one()
|
_spawn_one()
|
||||||
var jitter: float = randf_range(-gap * 0.25, gap * 0.25)
|
var jitter: float = randf_range(-gap * 0.25, gap * 0.25)
|
||||||
await get_tree().create_timer(max(0.05, gap + jitter)).timeout
|
await get_tree().create_timer(max(0.05, gap + jitter), false).timeout
|
||||||
|
|
||||||
func _spawn_one() -> void:
|
func _spawn_one() -> void:
|
||||||
var s = survivor.instantiate()
|
var s = survivor.instantiate()
|
||||||
var offset := Vector3(randf_range(-lateral_variance, lateral_variance), 0, 0)
|
var offset := Vector3(randf_range(-lateral_variance, lateral_variance), 0, 0)
|
||||||
add_child.call_deferred(s)
|
add_child.call_deferred(s)
|
||||||
s.position = start_pos + offset
|
s.position = survivor_spawn.global_position + offset
|
||||||
_active_walkers.append(s)
|
_active_walkers.append(s)
|
||||||
|
|
|
||||||
|
|
@ -8,24 +8,24 @@ var saved_count := 0
|
||||||
var doors_closing_flag := false
|
var doors_closing_flag := false
|
||||||
var _onboarded := false
|
var _onboarded := false
|
||||||
|
|
||||||
var base_survivors := 2
|
const BASE_SURVIVORS := 2
|
||||||
var survivors_per_floor_increase := 1
|
const SURVIVORS_PER_FLOOR_INCREASE := 1
|
||||||
var survivors_remaining := 0
|
var survivors_remaining := 0
|
||||||
|
|
||||||
var threshold := 2
|
const THRESHOLD := 2
|
||||||
|
|
||||||
var score := 0
|
var score := 0
|
||||||
var points_per_person := 100
|
const POINTS_PER_PERSON := 100
|
||||||
|
|
||||||
const MOVING_ZONE_START_FLOOR := 7
|
const MOVING_ZONE_SPEED_MIN := 20.0
|
||||||
const MOVING_ZONE_BASE_SPEED := 40.0
|
const MOVING_ZONE_SPEED_MAX := 130.0
|
||||||
const MOVING_ZONE_SPEED_PER_FLOOR := 12.0
|
const DIFFICULTY_EXPONENT := 1.4
|
||||||
|
|
||||||
var robot_speed_top := 1.0
|
const ROBOT_SPEED_TOP := 2.0
|
||||||
var robot_speed_per_floor := 0.15
|
const ROBOT_SPEED_PER_FLOOR := 0.15
|
||||||
var robot_delay_top := 8.0
|
const ROBOT_DELAY_TOP := 3.0
|
||||||
var robot_delay_per_floor := 0.6
|
const ROBOT_DELAY_PER_FLOOR := 0.6
|
||||||
var robot_delay_min := 1.0
|
const ROBOT_DELAY_MIN := 1.0
|
||||||
|
|
||||||
var people_in_elevator := 0
|
var people_in_elevator := 0
|
||||||
|
|
||||||
|
|
@ -49,37 +49,51 @@ func _unhandled_input(event):
|
||||||
_on_block_pressed()
|
_on_block_pressed()
|
||||||
elif event.keycode == KEY_R:
|
elif event.keycode == KEY_R:
|
||||||
get_tree().reload_current_scene()
|
get_tree().reload_current_scene()
|
||||||
|
elif event.keycode >= KEY_1 and event.keycode <= KEY_9:
|
||||||
|
EventBus.debug_starting_floor = event.keycode - KEY_0
|
||||||
|
get_tree().reload_current_scene()
|
||||||
|
elif event.keycode == KEY_0:
|
||||||
|
EventBus.debug_starting_floor = EventBus.STARTING_FLOOR
|
||||||
|
get_tree().reload_current_scene()
|
||||||
|
|
||||||
func _start_floor():
|
func _reset_floor_state():
|
||||||
$SfxOpen.play()
|
|
||||||
$SfxBell.play()
|
|
||||||
doors_closing_flag = false
|
doors_closing_flag = false
|
||||||
people_in_elevator = 0
|
people_in_elevator = 0
|
||||||
_close_button.text = "CLOSE"
|
_close_button.text = "CLOSE"
|
||||||
|
var floors_remaining = current_floor - 1
|
||||||
|
survivors_remaining = BASE_SURVIVORS + (floors_remaining * SURVIVORS_PER_FLOOR_INCREASE)
|
||||||
|
|
||||||
|
func _start_floor():
|
||||||
|
if EventBus.debug_starting_floor > 0:
|
||||||
|
current_floor = EventBus.debug_starting_floor
|
||||||
|
_onboarded = true
|
||||||
|
EventBus.debug_starting_floor = 0
|
||||||
|
|
||||||
|
$SfxOpen.play()
|
||||||
|
$SfxBell.play()
|
||||||
|
_reset_floor_state()
|
||||||
EventBus.doors_opened.emit()
|
EventBus.doors_opened.emit()
|
||||||
|
|
||||||
var floors_remaining = current_floor - 1
|
EventBus.people_changed.emit(people_in_elevator, THRESHOLD)
|
||||||
survivors_remaining = base_survivors + (floors_remaining * survivors_per_floor_increase)
|
|
||||||
|
|
||||||
EventBus.people_changed.emit(people_in_elevator, threshold)
|
|
||||||
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 = EventBus.STARTING_FLOOR - current_floor
|
var floors_descended = EventBus.STARTING_FLOOR - current_floor
|
||||||
var robot_speed = robot_speed_top + floors_descended * robot_speed_per_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)
|
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)
|
EventBus.robot_floor_started.emit(robot_delay, robot_speed)
|
||||||
|
|
||||||
_screen.start(current_floor)
|
_screen.start(current_floor)
|
||||||
|
|
||||||
if current_floor <= MOVING_ZONE_START_FLOOR:
|
var t_raw = float(floors_descended) / float(EventBus.STARTING_FLOOR - 1)
|
||||||
var floors_below = MOVING_ZONE_START_FLOOR - current_floor
|
var t_difficulty = pow(t_raw, DIFFICULTY_EXPONENT)
|
||||||
_screen.set_block_zone_movement(MOVING_ZONE_BASE_SPEED + floors_below * MOVING_ZONE_SPEED_PER_FLOOR)
|
var zone_speed = lerp(MOVING_ZONE_SPEED_MIN, MOVING_ZONE_SPEED_MAX, t_difficulty)
|
||||||
|
_screen.set_block_zone_movement(zone_speed)
|
||||||
|
|
||||||
if not _onboarded:
|
if not _onboarded:
|
||||||
_onboarded = true
|
_onboarded = true
|
||||||
_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, false).timeout.connect(
|
||||||
func():
|
func():
|
||||||
if not is_instance_valid(_screen):
|
if not is_instance_valid(_screen):
|
||||||
return
|
return
|
||||||
|
|
@ -88,7 +102,7 @@ func _start_floor():
|
||||||
CONNECT_ONE_SHOT
|
CONNECT_ONE_SHOT
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
get_tree().create_timer(PRE_PULSE_DELAY).timeout.connect(
|
get_tree().create_timer(PRE_PULSE_DELAY, false).timeout.connect(
|
||||||
func():
|
func():
|
||||||
if not is_instance_valid(self) or doors_closing_flag:
|
if not is_instance_valid(self) or doors_closing_flag:
|
||||||
return
|
return
|
||||||
|
|
@ -117,14 +131,14 @@ func _on_pulse_blocked():
|
||||||
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:
|
||||||
get_tree().create_timer(0.25).timeout.connect(_on_doors_closing, CONNECT_ONE_SHOT)
|
get_tree().create_timer(0.25, false).timeout.connect(_on_doors_closing, CONNECT_ONE_SHOT)
|
||||||
return
|
return
|
||||||
|
|
||||||
var gap = _screen.get_pulse_gap()
|
var gap = _screen.get_pulse_gap()
|
||||||
get_tree().create_timer(gap).timeout.connect(
|
get_tree().create_timer(gap, false).timeout.connect(
|
||||||
func():
|
func():
|
||||||
if not doors_closing_flag:
|
if not doors_closing_flag:
|
||||||
_screen.launch_pulse(),
|
_screen.launch_pulse(),
|
||||||
|
|
@ -137,13 +151,13 @@ func _on_doors_closing(fast: bool = false):
|
||||||
doors_closing_flag = true
|
doors_closing_flag = true
|
||||||
EventBus.doors_closed.emit(fast)
|
EventBus.doors_closed.emit(fast)
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
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
|
||||||
saved_count += people_in_elevator
|
saved_count += people_in_elevator
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://k1n4iyxp4iww" path="res://scenes/elevator_panel.gd" id="1_1gr6t"]
|
[ext_resource type="Script" uid="uid://k1n4iyxp4iww" path="res://scenes/elevator_panel.gd" id="1_1gr6t"]
|
||||||
[ext_resource type="Script" uid="uid://kltqwef8yx3r" path="res://scenes/screen.gd" id="1_3gei6"]
|
[ext_resource type="Script" uid="uid://kltqwef8yx3r" path="res://scenes/screen.gd" id="1_3gei6"]
|
||||||
|
[ext_resource type="Script" path="res://scenes/pulse.gd" id="2_pulse"]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_n2snw"]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_n2snw"]
|
||||||
bg_color = Color(0.039215688, 0.16470589, 0.039215688, 1)
|
bg_color = Color(0.039215688, 0.16470589, 0.039215688, 1)
|
||||||
|
|
@ -64,6 +65,9 @@ theme_override_colors/font_color = Color(0.2, 1, 0.2, 1)
|
||||||
theme_override_font_sizes/font_size = 32
|
theme_override_font_sizes/font_size = 32
|
||||||
text = ">:)"
|
text = ">:)"
|
||||||
|
|
||||||
|
[node name="Pulse" type="Node" parent="PanelMargin/PanelColumn/Screen"]
|
||||||
|
script = ExtResource("2_pulse")
|
||||||
|
|
||||||
[node name="CloseButton" type="Button" parent="PanelMargin/PanelColumn" unique_id=554485629]
|
[node name="CloseButton" type="Button" parent="PanelMargin/PanelColumn" unique_id=554485629]
|
||||||
custom_minimum_size = Vector2(0, 60)
|
custom_minimum_size = Vector2(0, 60)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ extends CanvasLayer
|
||||||
|
|
||||||
var _score := 0
|
var _score := 0
|
||||||
var _saved := 0
|
var _saved := 0
|
||||||
|
var _lost := false
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
visible = false
|
visible = false
|
||||||
|
|
@ -11,12 +12,21 @@ func _ready():
|
||||||
EventBus.saved_changed.connect(func(s): _saved = s)
|
EventBus.saved_changed.connect(func(s): _saved = s)
|
||||||
$Center/Card/Margin/Column/RestartButton.pressed.connect(_on_restart_pressed)
|
$Center/Card/Margin/Column/RestartButton.pressed.connect(_on_restart_pressed)
|
||||||
|
|
||||||
|
func _unhandled_input(event):
|
||||||
|
if visible and _lost and event is InputEventKey and event.pressed and not event.echo and event.keycode == KEY_SPACE:
|
||||||
|
get_viewport().set_input_as_handled()
|
||||||
|
_on_restart_pressed()
|
||||||
|
|
||||||
func _on_game_won():
|
func _on_game_won():
|
||||||
$Center/Card/Margin/Column/Headline.text = "YOU ESCAPED"
|
$Center/Card/Margin/Column/Headline.text = "YOU ESCAPED"
|
||||||
|
_lost = false
|
||||||
|
$Center/Card/Margin/Column/SpaceHint.visible = false
|
||||||
_show()
|
_show()
|
||||||
|
|
||||||
func _on_game_lost(reason: String):
|
func _on_game_lost(reason: String):
|
||||||
$Center/Card/Margin/Column/Headline.text = reason
|
$Center/Card/Margin/Column/Headline.text = reason
|
||||||
|
_lost = true
|
||||||
|
$Center/Card/Margin/Column/SpaceHint.visible = true
|
||||||
_apply_loss_palette()
|
_apply_loss_palette()
|
||||||
_show()
|
_show()
|
||||||
|
|
||||||
|
|
@ -24,11 +34,7 @@ func _apply_loss_palette():
|
||||||
var border := Color(1, 0.3, 0.3, 1)
|
var border := Color(1, 0.3, 0.3, 1)
|
||||||
var subtle := Color(0.95, 0.7, 0.7, 1)
|
var subtle := Color(0.95, 0.7, 0.7, 1)
|
||||||
|
|
||||||
var card_style := ($Center/Card.get_theme_stylebox("panel") as StyleBoxFlat).duplicate() as StyleBoxFlat
|
$Dim.color = Color(0.18, 0.05, 0.05, 1)
|
||||||
if card_style:
|
|
||||||
card_style.border_color = border
|
|
||||||
card_style.bg_color = Color(0.18, 0.05, 0.05, 1)
|
|
||||||
$Center/Card.add_theme_stylebox_override("panel", card_style)
|
|
||||||
|
|
||||||
var button = $Center/Card/Margin/Column/RestartButton
|
var button = $Center/Card/Margin/Column/RestartButton
|
||||||
var button_style := (button.get_theme_stylebox("normal") as StyleBoxFlat).duplicate() as StyleBoxFlat
|
var button_style := (button.get_theme_stylebox("normal") as StyleBoxFlat).duplicate() as StyleBoxFlat
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,7 @@
|
||||||
[gd_scene load_steps=4 format=3]
|
[gd_scene load_steps=3 format=3]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scenes/end_screen.gd" id="1"]
|
[ext_resource type="Script" path="res://scenes/end_screen.gd" id="1"]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="CardStyle"]
|
|
||||||
bg_color = Color(0.05, 0.18, 0.05, 1)
|
|
||||||
border_width_left = 3
|
|
||||||
border_width_top = 3
|
|
||||||
border_width_right = 3
|
|
||||||
border_width_bottom = 3
|
|
||||||
border_color = Color(0.2, 1, 0.2, 1)
|
|
||||||
corner_radius_top_left = 6
|
|
||||||
corner_radius_top_right = 6
|
|
||||||
corner_radius_bottom_right = 6
|
|
||||||
corner_radius_bottom_left = 6
|
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="ButtonStyle"]
|
[sub_resource type="StyleBoxFlat" id="ButtonStyle"]
|
||||||
bg_color = Color(0.1, 0.3, 0.1, 1)
|
bg_color = Color(0.1, 0.3, 0.1, 1)
|
||||||
border_width_left = 2
|
border_width_left = 2
|
||||||
|
|
@ -35,18 +23,19 @@ layer = 10
|
||||||
script = ExtResource("1")
|
script = ExtResource("1")
|
||||||
|
|
||||||
[node name="Dim" type="ColorRect" parent="."]
|
[node name="Dim" type="ColorRect" parent="."]
|
||||||
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
color = Color(0, 0, 0, 0.85)
|
color = Color(0.05, 0.18, 0.05, 1)
|
||||||
|
|
||||||
[node name="Center" type="CenterContainer" parent="."]
|
[node name="Center" type="CenterContainer" parent="."]
|
||||||
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
mouse_filter = 1
|
mouse_filter = 1
|
||||||
|
|
||||||
[node name="Card" type="PanelContainer" parent="Center"]
|
[node name="Card" type="PanelContainer" parent="Center"]
|
||||||
theme_override_styles/panel = SubResource("CardStyle")
|
|
||||||
|
|
||||||
[node name="Margin" type="MarginContainer" parent="Center/Card"]
|
[node name="Margin" type="MarginContainer" parent="Center/Card"]
|
||||||
theme_override_constants/margin_left = 56
|
theme_override_constants/margin_left = 56
|
||||||
|
|
@ -84,3 +73,10 @@ theme_override_styles/normal = SubResource("ButtonStyle")
|
||||||
theme_override_styles/hover = SubResource("ButtonStyle")
|
theme_override_styles/hover = SubResource("ButtonStyle")
|
||||||
theme_override_styles/pressed = SubResource("ButtonStyle")
|
theme_override_styles/pressed = SubResource("ButtonStyle")
|
||||||
theme_override_styles/focus = SubResource("ButtonStyle")
|
theme_override_styles/focus = SubResource("ButtonStyle")
|
||||||
|
|
||||||
|
[node name="SpaceHint" type="Label" parent="Center/Card/Margin/Column"]
|
||||||
|
visible = false
|
||||||
|
text = "Space to Restart"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
theme_override_colors/font_color = Color(0.95, 0.7, 0.7, 1)
|
||||||
|
theme_override_font_sizes/font_size = 20
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
extends Node3D
|
extends Node3D
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
pass
|
$ComponentSpawn.survivor_spawn = $World/SurvivorSpawn
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
[gd_scene format=3 uid="uid://cbvi51vvpt7mu"]
|
[gd_scene load_steps=3 format=3 uid="uid://cbvi51vvpt7mu"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://fpaw3u5yjtbk" path="res://scenes/hud.gd" id="1_64ctp"]
|
[ext_resource type="Script" uid="uid://fpaw3u5yjtbk" path="res://scenes/hud.gd" id="1_64ctp"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dshaftstrip01" path="res://scenes/shaft_strip.tscn" id="2_shaft"]
|
||||||
|
|
||||||
[node name="HUD" type="MarginContainer" unique_id=769131693]
|
[node name="HUD" type="MarginContainer" unique_id=769131693]
|
||||||
offset_right = 40.0
|
offset_right = 40.0
|
||||||
offset_bottom = 40.0
|
offset_bottom = 40.0
|
||||||
theme_override_constants/margin_left = 20
|
theme_override_constants/margin_left = 72
|
||||||
theme_override_constants/margin_top = 20
|
theme_override_constants/margin_top = 20
|
||||||
script = ExtResource("1_64ctp")
|
script = ExtResource("1_64ctp")
|
||||||
|
|
||||||
|
|
@ -30,3 +31,13 @@ text = "FLOOR: 0"
|
||||||
[node name="ScoreLabel" type="Label" parent="StatsColumn" unique_id=1595653166]
|
[node name="ScoreLabel" type="Label" parent="StatsColumn" unique_id=1595653166]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_font_sizes/font_size = 24
|
theme_override_font_sizes/font_size = 24
|
||||||
|
|
||||||
|
[node name="ShaftStrip" parent="." instance=ExtResource("2_shaft")]
|
||||||
|
top_level = true
|
||||||
|
anchors_preset = 9
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = 12.0
|
||||||
|
offset_top = 12.0
|
||||||
|
offset_right = 60.0
|
||||||
|
offset_bottom = -12.0
|
||||||
|
grow_vertical = 2
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,41 @@
|
||||||
extends CanvasLayer
|
extends CanvasLayer
|
||||||
|
|
||||||
var _enabled := false
|
var _in_play := false
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
process_mode = Node.PROCESS_MODE_ALWAYS
|
||||||
visible = false
|
visible = false
|
||||||
EventBus.game_started.connect(func(): _enabled = true)
|
EventBus.game_started.connect(func(): _in_play = true)
|
||||||
EventBus.game_won.connect(func(): _enabled = false)
|
EventBus.game_won.connect(func(): _in_play = false)
|
||||||
EventBus.game_lost.connect(func(_reason: String): _enabled = false)
|
EventBus.game_lost.connect(func(_reason: String): _in_play = false)
|
||||||
|
$Center/Card/Margin/Column/ResumeButton.pressed.connect(_on_resume_pressed)
|
||||||
|
$Center/Card/Margin/Column/RestartButton.pressed.connect(_on_restart_pressed)
|
||||||
|
$Center/Card/Margin/Column/QuitButton.pressed.connect(_on_quit_pressed)
|
||||||
|
|
||||||
func _unhandled_input(event):
|
func _unhandled_input(event):
|
||||||
if not _enabled:
|
if not _in_play:
|
||||||
return
|
return
|
||||||
if event is InputEventKey and event.pressed and not event.echo and event.keycode == KEY_ESCAPE:
|
if event is InputEventKey and event.pressed and not event.echo and event.keycode == KEY_ESCAPE:
|
||||||
_toggle()
|
_toggle()
|
||||||
get_viewport().set_input_as_handled()
|
get_viewport().set_input_as_handled()
|
||||||
|
return
|
||||||
|
if get_tree().paused and event is InputEventKey and event.pressed and not event.echo and event.keycode == KEY_SPACE:
|
||||||
|
_on_resume_pressed()
|
||||||
|
get_viewport().set_input_as_handled()
|
||||||
|
|
||||||
func _toggle():
|
func _toggle():
|
||||||
var paused := not get_tree().paused
|
var paused := not get_tree().paused
|
||||||
get_tree().paused = paused
|
get_tree().paused = paused
|
||||||
visible = paused
|
visible = paused
|
||||||
|
|
||||||
|
func _on_resume_pressed():
|
||||||
|
get_tree().paused = false
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
func _on_restart_pressed():
|
||||||
|
get_tree().paused = false
|
||||||
|
get_tree().reload_current_scene()
|
||||||
|
|
||||||
|
func _on_quit_pressed():
|
||||||
|
get_tree().paused = false
|
||||||
|
get_tree().reload_current_scene()
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,90 @@
|
||||||
[gd_scene load_steps=2 format=3]
|
[gd_scene load_steps=3 format=3]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scenes/pause_menu.gd" id="1"]
|
[ext_resource type="Script" path="res://scenes/pause_menu.gd" id="1"]
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="ButtonStyle"]
|
||||||
|
bg_color = Color(0.1, 0.3, 0.1, 1)
|
||||||
|
border_width_left = 2
|
||||||
|
border_width_top = 2
|
||||||
|
border_width_right = 2
|
||||||
|
border_width_bottom = 2
|
||||||
|
border_color = Color(0.2, 1, 0.2, 1)
|
||||||
|
corner_radius_top_left = 4
|
||||||
|
corner_radius_top_right = 4
|
||||||
|
corner_radius_bottom_right = 4
|
||||||
|
corner_radius_bottom_left = 4
|
||||||
|
content_margin_left = 24
|
||||||
|
content_margin_right = 24
|
||||||
|
content_margin_top = 12
|
||||||
|
content_margin_bottom = 12
|
||||||
|
|
||||||
[node name="PauseMenu" type="CanvasLayer"]
|
[node name="PauseMenu" type="CanvasLayer"]
|
||||||
layer = 25
|
layer = 25
|
||||||
process_mode = 3
|
process_mode = 3
|
||||||
script = ExtResource("1")
|
script = ExtResource("1")
|
||||||
|
|
||||||
[node name="Dim" type="ColorRect" parent="."]
|
[node name="Dim" type="ColorRect" parent="."]
|
||||||
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
color = Color(0, 0, 0, 0.7)
|
color = Color(0.05, 0.18, 0.05, 1)
|
||||||
|
|
||||||
[node name="Center" type="CenterContainer" parent="."]
|
[node name="Center" type="CenterContainer" parent="."]
|
||||||
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
mouse_filter = 1
|
mouse_filter = 1
|
||||||
|
|
||||||
[node name="Column" type="VBoxContainer" parent="Center"]
|
[node name="Card" type="PanelContainer" parent="Center"]
|
||||||
theme_override_constants/separation = 16
|
|
||||||
|
|
||||||
[node name="Title" type="Label" parent="Center/Column"]
|
[node name="Margin" type="MarginContainer" parent="Center/Card"]
|
||||||
|
theme_override_constants/margin_left = 56
|
||||||
|
theme_override_constants/margin_right = 56
|
||||||
|
theme_override_constants/margin_top = 40
|
||||||
|
theme_override_constants/margin_bottom = 40
|
||||||
|
|
||||||
|
[node name="Column" type="VBoxContainer" parent="Center/Card/Margin"]
|
||||||
|
theme_override_constants/separation = 24
|
||||||
|
|
||||||
|
[node name="Title" type="Label" parent="Center/Card/Margin/Column"]
|
||||||
text = "PAUSED"
|
text = "PAUSED"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
theme_override_colors/font_color = Color(1, 1, 1, 1)
|
theme_override_colors/font_color = Color(0.2, 1, 0.2, 1)
|
||||||
theme_override_font_sizes/font_size = 64
|
theme_override_font_sizes/font_size = 56
|
||||||
|
|
||||||
[node name="Prompt" type="Label" parent="Center/Column"]
|
[node name="ResumeButton" type="Button" parent="Center/Card/Margin/Column"]
|
||||||
text = "ESC TO RESUME"
|
text = "RESUME"
|
||||||
horizontal_alignment = 1
|
theme_override_colors/font_color = Color(0.2, 1, 0.2, 1)
|
||||||
theme_override_colors/font_color = Color(0.7, 0.7, 0.7, 1)
|
theme_override_colors/font_hover_color = Color(0.5, 1, 0.5, 1)
|
||||||
theme_override_font_sizes/font_size = 24
|
theme_override_font_sizes/font_size = 24
|
||||||
|
theme_override_styles/normal = SubResource("ButtonStyle")
|
||||||
|
theme_override_styles/hover = SubResource("ButtonStyle")
|
||||||
|
theme_override_styles/pressed = SubResource("ButtonStyle")
|
||||||
|
theme_override_styles/focus = SubResource("ButtonStyle")
|
||||||
|
|
||||||
|
[node name="RestartButton" type="Button" parent="Center/Card/Margin/Column"]
|
||||||
|
text = "RESTART"
|
||||||
|
theme_override_colors/font_color = Color(0.2, 1, 0.2, 1)
|
||||||
|
theme_override_colors/font_hover_color = Color(0.5, 1, 0.5, 1)
|
||||||
|
theme_override_font_sizes/font_size = 24
|
||||||
|
theme_override_styles/normal = SubResource("ButtonStyle")
|
||||||
|
theme_override_styles/hover = SubResource("ButtonStyle")
|
||||||
|
theme_override_styles/pressed = SubResource("ButtonStyle")
|
||||||
|
theme_override_styles/focus = SubResource("ButtonStyle")
|
||||||
|
|
||||||
|
[node name="QuitButton" type="Button" parent="Center/Card/Margin/Column"]
|
||||||
|
text = "QUIT"
|
||||||
|
theme_override_colors/font_color = Color(0.2, 1, 0.2, 1)
|
||||||
|
theme_override_colors/font_hover_color = Color(0.5, 1, 0.5, 1)
|
||||||
|
theme_override_font_sizes/font_size = 24
|
||||||
|
theme_override_styles/normal = SubResource("ButtonStyle")
|
||||||
|
theme_override_styles/hover = SubResource("ButtonStyle")
|
||||||
|
theme_override_styles/pressed = SubResource("ButtonStyle")
|
||||||
|
theme_override_styles/focus = SubResource("ButtonStyle")
|
||||||
|
|
||||||
|
[node name="SpaceHint" type="Label" parent="Center/Card/Margin/Column"]
|
||||||
|
text = "Space to Resume"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
theme_override_colors/font_color = Color(0.7, 0.95, 0.7, 1)
|
||||||
|
theme_override_font_sizes/font_size = 20
|
||||||
|
|
|
||||||
126
scenes/pulse.gd
Normal file
126
scenes/pulse.gd
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
const TRAIL_GHOSTS := 8
|
||||||
|
const TRAIL_SPACING := 3.0
|
||||||
|
const TRAIL_ALPHAS := [0.5, 0.42, 0.34, 0.27, 0.2, 0.14, 0.09, 0.05]
|
||||||
|
const GLOW_PADDING := Vector2(6, 6)
|
||||||
|
const GLOW_COLOR := Color(1, 0.3, 0.3, 0.35)
|
||||||
|
|
||||||
|
var pulse_speed := 80.0
|
||||||
|
var pulse_speed_initial := 80.0
|
||||||
|
var pulse_speed_per_floor := 8.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
|
||||||
|
var pulses_blocked := 0
|
||||||
|
|
||||||
|
var _sweep_line: ColorRect
|
||||||
|
var _target_zone: ColorRect
|
||||||
|
var _perfect_zone: ColorRect
|
||||||
|
var _screen_width: float
|
||||||
|
var _glow: ColorRect
|
||||||
|
var _trail: Array[ColorRect] = []
|
||||||
|
|
||||||
|
signal pulse_started(duration: float)
|
||||||
|
signal pulse_blocked
|
||||||
|
signal pulse_blocked_perfect
|
||||||
|
signal pulse_escaped
|
||||||
|
|
||||||
|
func configure(sweep_line: ColorRect, target_zone: ColorRect, perfect_zone: ColorRect, screen_width: float):
|
||||||
|
_sweep_line = sweep_line
|
||||||
|
_target_zone = target_zone
|
||||||
|
_perfect_zone = perfect_zone
|
||||||
|
_screen_width = screen_width
|
||||||
|
_build_visuals()
|
||||||
|
|
||||||
|
func _build_visuals():
|
||||||
|
var host: Control = _sweep_line.get_parent() as Control
|
||||||
|
_glow = ColorRect.new()
|
||||||
|
_glow.color = GLOW_COLOR
|
||||||
|
_glow.size = Vector2(_sweep_line.size.x + GLOW_PADDING.x * 2, _sweep_line.size.y + GLOW_PADDING.y * 2)
|
||||||
|
_glow.visible = false
|
||||||
|
host.add_child(_glow)
|
||||||
|
host.move_child(_glow, 0)
|
||||||
|
|
||||||
|
for i in TRAIL_GHOSTS:
|
||||||
|
var ghost := ColorRect.new()
|
||||||
|
ghost.color = Color(_sweep_line.color.r, _sweep_line.color.g, _sweep_line.color.b, TRAIL_ALPHAS[i])
|
||||||
|
ghost.size = _sweep_line.size
|
||||||
|
ghost.visible = false
|
||||||
|
host.add_child(ghost)
|
||||||
|
host.move_child(ghost, 0)
|
||||||
|
_trail.append(ghost)
|
||||||
|
|
||||||
|
func start_floor(floor_num: int):
|
||||||
|
pulses_blocked = 0
|
||||||
|
var floors_descended = EventBus.STARTING_FLOOR - floor_num
|
||||||
|
pulse_speed = pulse_speed_initial + floors_descended * pulse_speed_per_floor
|
||||||
|
pulse_gap = 1.0
|
||||||
|
pulse_active = false
|
||||||
|
|
||||||
|
func launch():
|
||||||
|
pulse_x = 0.0
|
||||||
|
pulse_active = true
|
||||||
|
_sweep_line.visible = true
|
||||||
|
_sweep_line.position.x = 0
|
||||||
|
_glow.visible = true
|
||||||
|
for ghost in _trail:
|
||||||
|
ghost.visible = true
|
||||||
|
pulse_started.emit(_screen_width / pulse_speed)
|
||||||
|
|
||||||
|
func attempt_block() -> bool:
|
||||||
|
if not pulse_active:
|
||||||
|
return false
|
||||||
|
var bz_left = _target_zone.position.x
|
||||||
|
var bz_right = _target_zone.position.x + _target_zone.size.x
|
||||||
|
if pulse_x >= bz_left and pulse_x <= bz_right:
|
||||||
|
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
|
||||||
|
pulse_active = false
|
||||||
|
pulses_blocked += 1
|
||||||
|
pulse_speed += pulse_speed_increase
|
||||||
|
pulse_gap = max(pulse_gap - pulse_gap_decrease, pulse_gap_min)
|
||||||
|
_hide_visuals()
|
||||||
|
pulse_blocked.emit()
|
||||||
|
if was_perfect:
|
||||||
|
pulse_blocked_perfect.emit()
|
||||||
|
return true
|
||||||
|
else:
|
||||||
|
pulse_active = false
|
||||||
|
_hide_visuals()
|
||||||
|
pulse_escaped.emit()
|
||||||
|
return false
|
||||||
|
|
||||||
|
func get_pulse_gap() -> float:
|
||||||
|
return pulse_gap
|
||||||
|
|
||||||
|
func stop():
|
||||||
|
pulse_active = false
|
||||||
|
_hide_visuals()
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
if not pulse_active:
|
||||||
|
return
|
||||||
|
pulse_x += pulse_speed * delta
|
||||||
|
_sweep_line.position.x = pulse_x
|
||||||
|
_glow.position = Vector2(pulse_x - GLOW_PADDING.x, _sweep_line.position.y - GLOW_PADDING.y)
|
||||||
|
for i in _trail.size():
|
||||||
|
var gx = pulse_x - (i + 1) * TRAIL_SPACING
|
||||||
|
_trail[i].visible = gx >= 0
|
||||||
|
_trail[i].position = Vector2(gx, _sweep_line.position.y)
|
||||||
|
if pulse_x >= _screen_width:
|
||||||
|
pulse_active = false
|
||||||
|
_hide_visuals()
|
||||||
|
pulse_escaped.emit()
|
||||||
|
|
||||||
|
func _hide_visuals():
|
||||||
|
if _sweep_line:
|
||||||
|
_sweep_line.visible = false
|
||||||
|
if _glow:
|
||||||
|
_glow.visible = false
|
||||||
|
for ghost in _trail:
|
||||||
|
ghost.visible = false
|
||||||
1
scenes/pulse.gd.uid
Normal file
1
scenes/pulse.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://36alg5uedb02
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
extends CharacterBody3D
|
extends CharacterBody3D
|
||||||
|
|
||||||
|
const STALK_DARK_DISTANCE := 19.0
|
||||||
|
const STALK_ILLUMINATE_DISTANCE := 15.0
|
||||||
|
|
||||||
var robot_ready: bool = false
|
var robot_ready: bool = false
|
||||||
var robot_win: bool = false
|
var robot_win: bool = false
|
||||||
var speed: float = 1.0
|
var speed: float = 1.0
|
||||||
|
|
@ -9,9 +12,7 @@ var stun_remaining: float = 0.0
|
||||||
var _delay_remaining: float = 0.0
|
var _delay_remaining: float = 0.0
|
||||||
var _spawn_transform: Transform3D
|
var _spawn_transform: Transform3D
|
||||||
|
|
||||||
var stalking: bool = true
|
var safety_zone: Area3D
|
||||||
|
|
||||||
@onready var safety_zone = get_node("/root/Game/World/ElevatorSafeZone")
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
|
@ -67,13 +68,11 @@ func stalking_check():
|
||||||
var elevator = safety_zone.global_transform.origin
|
var elevator = safety_zone.global_transform.origin
|
||||||
var distance = robot_position.distance_to(elevator)
|
var distance = robot_position.distance_to(elevator)
|
||||||
var current_modulation = $Sprite3D.modulate
|
var current_modulation = $Sprite3D.modulate
|
||||||
print(distance)
|
|
||||||
|
|
||||||
if distance >= 19:
|
if distance >= STALK_DARK_DISTANCE:
|
||||||
$Sprite3D.modulate = Color(0.0, 0.0, 0.0)
|
$Sprite3D.modulate = Color(0.0, 0.0, 0.0)
|
||||||
|
|
||||||
if distance <= 15: #and stalking == true:
|
if distance <= STALK_ILLUMINATE_DISTANCE:
|
||||||
stalking == false
|
|
||||||
illuminate()
|
illuminate()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
230
scenes/screen.gd
230
scenes/screen.gd
|
|
@ -1,14 +1,17 @@
|
||||||
extends Panel
|
extends Panel
|
||||||
|
|
||||||
var pulse_speed := 120.0
|
const PULSE_TOP_MARGIN := 0.0
|
||||||
var pulse_speed_initial := 120.0
|
const PULSE_BOTTOM_MARGIN := 0.0
|
||||||
var pulse_speed_per_floor := 8.0
|
const BLOCK_ZONE_RIGHT_MARGIN := 4.0
|
||||||
var pulse_speed_increase := 15.0
|
const PERFECT_ZONE_RATIO := 0.3
|
||||||
var pulse_x := 0.0
|
const PERFECT_ZONE_COLOR := Color(1.0, 0.95, 0.4, 0.85)
|
||||||
var pulse_active := false
|
const QUOTA_DOT_SIZE := 7.0
|
||||||
var pulse_gap := 1.0
|
const QUOTA_DOT_SPACING := 3.0
|
||||||
var pulse_gap_decrease := 0.05
|
const QUOTA_DOT_Y := 6.0
|
||||||
var pulse_gap_min := 0.3
|
const QUOTA_DOT_RIGHT_MARGIN := 8.0
|
||||||
|
const QUOTA_EMPTY_COLOR := Color(0.07, 0.14, 0.09, 1.0)
|
||||||
|
const QUOTA_EMPTY_BORDER := Color(0.18, 0.35, 0.2, 1.0)
|
||||||
|
const QUOTA_FILLED_COLOR := Color(0.2, 1.0, 0.2, 1.0)
|
||||||
|
|
||||||
var block_zone_shrink := 3.0
|
var block_zone_shrink := 3.0
|
||||||
var block_zone_min := 12.0
|
var block_zone_min := 12.0
|
||||||
|
|
@ -18,47 +21,36 @@ 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 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
|
|
||||||
const TRAIL_ALPHAS := [0.5, 0.42, 0.34, 0.27, 0.2, 0.14, 0.09, 0.05]
|
|
||||||
const GLOW_PADDING := Vector2(6, 6)
|
|
||||||
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)
|
|
||||||
const QUOTA_DOT_SIZE := 12.0
|
|
||||||
const QUOTA_DOT_SPACING := 8.0
|
|
||||||
const QUOTA_DOT_Y_FROM_BOTTOM := 14.0
|
|
||||||
const QUOTA_EMPTY_COLOR := Color(0.6, 0.1, 0.1, 0.95)
|
|
||||||
const QUOTA_FILLED_COLOR := Color(0.2, 1.0, 0.2, 1.0)
|
|
||||||
|
|
||||||
var base_color: Color
|
var base_color: Color
|
||||||
|
|
||||||
var active := false
|
var active := false
|
||||||
var pulses_blocked := 0
|
|
||||||
var _ready_pulse_tween: Tween = null
|
var _ready_pulse_tween: Tween = null
|
||||||
var _trail: Array[ColorRect] = []
|
|
||||||
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 _flash_tween: Tween
|
var _flash_tween: Tween
|
||||||
var _floor_label: Label
|
var _floor_label: Label
|
||||||
var _quota_dots: Array[ColorRect] = []
|
var _quota_dots: Array[Panel] = []
|
||||||
var _quota_threshold := 0
|
var _quota_threshold := 0
|
||||||
|
var _quota_filled_style: StyleBoxFlat
|
||||||
|
var _quota_empty_style: StyleBoxFlat
|
||||||
|
|
||||||
|
@onready var _pulse = $Pulse
|
||||||
|
|
||||||
signal pulse_started(duration: float)
|
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
|
||||||
|
|
||||||
|
var pulse_active: bool:
|
||||||
|
get:
|
||||||
|
return _pulse.pulse_active if _pulse else false
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var bz = $TargetZone
|
var bz = $TargetZone
|
||||||
bz.size = Vector2(50, size.y - PULSE_TOP_MARGIN - PULSE_BOTTOM_MARGIN)
|
bz.size = Vector2(50, size.y - PULSE_TOP_MARGIN - PULSE_BOTTOM_MARGIN)
|
||||||
bz.position = Vector2((size.x - bz.size.x) / 2, PULSE_TOP_MARGIN)
|
bz.position = Vector2(size.x - bz.size.x - BLOCK_ZONE_RIGHT_MARGIN, PULSE_TOP_MARGIN)
|
||||||
|
|
||||||
_perfect_zone = ColorRect.new()
|
_perfect_zone = ColorRect.new()
|
||||||
_perfect_zone.color = PERFECT_ZONE_COLOR
|
_perfect_zone.color = PERFECT_ZONE_COLOR
|
||||||
|
|
@ -78,21 +70,11 @@ func _ready():
|
||||||
face.text = ">:)"
|
face.text = ">:)"
|
||||||
face.pivot_offset = face.size / 2
|
face.pivot_offset = face.size / 2
|
||||||
|
|
||||||
_glow = ColorRect.new()
|
_pulse.configure(sl, bz, _perfect_zone, size.x)
|
||||||
_glow.color = GLOW_COLOR
|
_pulse.pulse_started.connect(_on_pulse_started)
|
||||||
_glow.size = Vector2($SweepLine.size.x + GLOW_PADDING.x * 2, $SweepLine.size.y + GLOW_PADDING.y * 2)
|
_pulse.pulse_blocked.connect(_on_pulse_blocked)
|
||||||
_glow.visible = false
|
_pulse.pulse_blocked_perfect.connect(_on_pulse_blocked_perfect)
|
||||||
add_child(_glow)
|
_pulse.pulse_escaped.connect(_on_pulse_escaped)
|
||||||
move_child(_glow, 0)
|
|
||||||
|
|
||||||
for i in TRAIL_GHOSTS:
|
|
||||||
var ghost := ColorRect.new()
|
|
||||||
ghost.color = Color($SweepLine.color.r, $SweepLine.color.g, $SweepLine.color.b, TRAIL_ALPHAS[i])
|
|
||||||
ghost.size = $SweepLine.size
|
|
||||||
ghost.visible = false
|
|
||||||
add_child(ghost)
|
|
||||||
move_child(ghost, 0)
|
|
||||||
_trail.append(ghost)
|
|
||||||
|
|
||||||
var style = get_theme_stylebox("panel") as StyleBoxFlat
|
var style = get_theme_stylebox("panel") as StyleBoxFlat
|
||||||
if style:
|
if style:
|
||||||
|
|
@ -110,36 +92,40 @@ func _ready():
|
||||||
|
|
||||||
func start(floor_num: int = EventBus.STARTING_FLOOR):
|
func start(floor_num: int = EventBus.STARTING_FLOOR):
|
||||||
active = true
|
active = true
|
||||||
pulses_blocked = 0
|
|
||||||
var floors_descended = EventBus.STARTING_FLOOR - floor_num
|
|
||||||
pulse_speed = pulse_speed_initial + floors_descended * pulse_speed_per_floor
|
|
||||||
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) / 2
|
_pulse.start_floor(floor_num)
|
||||||
|
|
||||||
func set_block_zone_movement(speed: float):
|
func set_block_zone_movement(speed: float):
|
||||||
|
var bz = $TargetZone
|
||||||
block_zone_speed = speed
|
block_zone_speed = speed
|
||||||
block_zone_moving = speed > 0.0
|
block_zone_moving = speed > 0.0
|
||||||
var bz = $TargetZone
|
block_zone_min_x = (size.x - bz.size.x) / 2.0
|
||||||
var range_half = size.x * MOVING_RANGE_RATIO / 2
|
block_zone_max_x = size.x - bz.size.x - BLOCK_ZONE_RIGHT_MARGIN
|
||||||
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():
|
func stop():
|
||||||
active = false
|
active = false
|
||||||
pulse_active = false
|
_pulse.stop()
|
||||||
_hide_pulse_visuals()
|
|
||||||
_stop_ready_pulse()
|
_stop_ready_pulse()
|
||||||
|
|
||||||
|
func launch_pulse():
|
||||||
|
if not active:
|
||||||
|
return
|
||||||
|
$AIFace.text = ">:)"
|
||||||
|
_start_ready_pulse()
|
||||||
|
_pulse.launch()
|
||||||
|
|
||||||
|
func get_pulse_gap() -> float:
|
||||||
|
return _pulse.get_pulse_gap()
|
||||||
|
|
||||||
|
func attempt_block() -> bool:
|
||||||
|
return _pulse.attempt_block()
|
||||||
|
|
||||||
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) / 2
|
var new_x = bz.position.x + (bz.size.x - new_width) / 2.0
|
||||||
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)
|
||||||
|
|
@ -159,25 +145,46 @@ func _update_floor_label(floor_num: int):
|
||||||
_displayed_floor = floor_num
|
_displayed_floor = floor_num
|
||||||
UIUtils.flip_label_text(_floor_label, new_text)
|
UIUtils.flip_label_text(_floor_label, new_text)
|
||||||
|
|
||||||
|
func _build_quota_styles():
|
||||||
|
var r := int(QUOTA_DOT_SIZE / 2.0)
|
||||||
|
_quota_filled_style = StyleBoxFlat.new()
|
||||||
|
_quota_filled_style.corner_radius_top_left = r
|
||||||
|
_quota_filled_style.corner_radius_top_right = r
|
||||||
|
_quota_filled_style.corner_radius_bottom_left = r
|
||||||
|
_quota_filled_style.corner_radius_bottom_right = r
|
||||||
|
_quota_filled_style.bg_color = QUOTA_FILLED_COLOR
|
||||||
|
_quota_empty_style = StyleBoxFlat.new()
|
||||||
|
_quota_empty_style.corner_radius_top_left = r
|
||||||
|
_quota_empty_style.corner_radius_top_right = r
|
||||||
|
_quota_empty_style.corner_radius_bottom_left = r
|
||||||
|
_quota_empty_style.corner_radius_bottom_right = r
|
||||||
|
_quota_empty_style.bg_color = QUOTA_EMPTY_COLOR
|
||||||
|
_quota_empty_style.border_width_top = 1
|
||||||
|
_quota_empty_style.border_width_bottom = 1
|
||||||
|
_quota_empty_style.border_width_left = 1
|
||||||
|
_quota_empty_style.border_width_right = 1
|
||||||
|
_quota_empty_style.border_color = QUOTA_EMPTY_BORDER
|
||||||
|
|
||||||
func _update_quota_dots(count: int, threshold: int):
|
func _update_quota_dots(count: int, threshold: int):
|
||||||
|
if _quota_filled_style == null:
|
||||||
|
_build_quota_styles()
|
||||||
if threshold != _quota_threshold:
|
if threshold != _quota_threshold:
|
||||||
_quota_threshold = threshold
|
_quota_threshold = threshold
|
||||||
for dot in _quota_dots:
|
for dot in _quota_dots:
|
||||||
dot.queue_free()
|
dot.queue_free()
|
||||||
_quota_dots.clear()
|
_quota_dots.clear()
|
||||||
var total_w = threshold * QUOTA_DOT_SIZE + max(0, threshold - 1) * QUOTA_DOT_SPACING
|
var total_w = threshold * QUOTA_DOT_SIZE + max(0, threshold - 1) * QUOTA_DOT_SPACING
|
||||||
var start_x = (size.x - total_w) / 2.0
|
var start_x = size.x - total_w - QUOTA_DOT_RIGHT_MARGIN
|
||||||
var y = size.y - QUOTA_DOT_Y_FROM_BOTTOM
|
|
||||||
for i in threshold:
|
for i in threshold:
|
||||||
var dot = ColorRect.new()
|
var dot = Panel.new()
|
||||||
dot.size = Vector2(QUOTA_DOT_SIZE, QUOTA_DOT_SIZE)
|
dot.size = Vector2(QUOTA_DOT_SIZE, QUOTA_DOT_SIZE)
|
||||||
dot.position = Vector2(start_x + i * (QUOTA_DOT_SIZE + QUOTA_DOT_SPACING), y)
|
dot.position = Vector2(start_x + i * (QUOTA_DOT_SIZE + QUOTA_DOT_SPACING), QUOTA_DOT_Y)
|
||||||
dot.color = QUOTA_EMPTY_COLOR
|
|
||||||
dot.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
dot.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
add_child(dot)
|
add_child(dot)
|
||||||
_quota_dots.append(dot)
|
_quota_dots.append(dot)
|
||||||
for i in _quota_dots.size():
|
for i in _quota_dots.size():
|
||||||
_quota_dots[i].color = QUOTA_FILLED_COLOR if i < count else QUOTA_EMPTY_COLOR
|
var style = _quota_filled_style if i < count else _quota_empty_style
|
||||||
|
_quota_dots[i].add_theme_stylebox_override("panel", style)
|
||||||
|
|
||||||
func _update_perfect_zone():
|
func _update_perfect_zone():
|
||||||
var bz = $TargetZone
|
var bz = $TargetZone
|
||||||
|
|
@ -185,28 +192,10 @@ func _update_perfect_zone():
|
||||||
_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)
|
||||||
|
|
||||||
func launch_pulse():
|
|
||||||
if not active:
|
|
||||||
return
|
|
||||||
pulse_x = 0.0
|
|
||||||
pulse_active = true
|
|
||||||
$SweepLine.visible = true
|
|
||||||
$SweepLine.position.x = 0
|
|
||||||
_glow.visible = true
|
|
||||||
for ghost in _trail:
|
|
||||||
ghost.visible = true
|
|
||||||
$AIFace.text = ">:)"
|
|
||||||
_start_ready_pulse()
|
|
||||||
pulse_started.emit(size.x / pulse_speed)
|
|
||||||
|
|
||||||
func get_pulse_gap() -> float:
|
|
||||||
return pulse_gap
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if not active:
|
if not active:
|
||||||
return
|
return
|
||||||
|
if block_zone_moving and $TargetZone.visible:
|
||||||
if block_zone_moving:
|
|
||||||
var bz = $TargetZone
|
var bz = $TargetZone
|
||||||
bz.position.x += block_zone_speed * block_zone_direction * delta
|
bz.position.x += block_zone_speed * block_zone_direction * delta
|
||||||
if bz.position.x >= block_zone_max_x:
|
if bz.position.x >= block_zone_max_x:
|
||||||
|
|
@ -216,59 +205,24 @@ func _process(delta):
|
||||||
bz.position.x = block_zone_min_x
|
bz.position.x = block_zone_min_x
|
||||||
block_zone_direction = 1
|
block_zone_direction = 1
|
||||||
|
|
||||||
if not pulse_active:
|
func _on_pulse_started(duration: float):
|
||||||
return
|
pulse_started.emit(duration)
|
||||||
|
|
||||||
pulse_x += pulse_speed * delta
|
func _on_pulse_blocked():
|
||||||
$SweepLine.position.x = pulse_x
|
$AIFace.text = ">:("
|
||||||
_glow.position = Vector2(pulse_x - GLOW_PADDING.x, $SweepLine.position.y - GLOW_PADDING.y)
|
_punch_face(1.4, 4.0)
|
||||||
for i in _trail.size():
|
flash(Color.GREEN)
|
||||||
var gx = pulse_x - (i + 1) * TRAIL_SPACING
|
pulse_blocked.emit()
|
||||||
_trail[i].visible = gx >= 0
|
|
||||||
_trail[i].position = Vector2(gx, $SweepLine.position.y)
|
|
||||||
|
|
||||||
if pulse_x >= size.x:
|
func _on_pulse_blocked_perfect():
|
||||||
pulse_active = false
|
pulse_blocked_perfect.emit()
|
||||||
_hide_pulse_visuals()
|
|
||||||
$AIFace.text = ":D"
|
|
||||||
_punch_face(1.5, 0.0)
|
|
||||||
flash(Color.RED)
|
|
||||||
active = false
|
|
||||||
doors_closing.emit()
|
|
||||||
|
|
||||||
func attempt_block() -> bool:
|
func _on_pulse_escaped():
|
||||||
if not pulse_active:
|
$AIFace.text = ":D"
|
||||||
return false
|
_punch_face(1.5, 0.0)
|
||||||
|
flash(Color.RED)
|
||||||
var bz = $TargetZone
|
active = false
|
||||||
var bz_left = bz.position.x
|
doors_closing.emit()
|
||||||
var bz_right = bz.position.x + bz.size.x
|
|
||||||
|
|
||||||
if pulse_x >= bz_left and pulse_x <= bz_right:
|
|
||||||
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
|
|
||||||
pulse_active = false
|
|
||||||
pulses_blocked += 1
|
|
||||||
pulse_speed += pulse_speed_increase
|
|
||||||
pulse_gap = max(pulse_gap - pulse_gap_decrease, pulse_gap_min)
|
|
||||||
_hide_pulse_visuals()
|
|
||||||
$AIFace.text = ">:("
|
|
||||||
_punch_face(1.4, 4.0)
|
|
||||||
flash(Color.GREEN)
|
|
||||||
pulse_blocked.emit()
|
|
||||||
if was_perfect:
|
|
||||||
pulse_blocked_perfect.emit()
|
|
||||||
return true
|
|
||||||
else:
|
|
||||||
pulse_active = false
|
|
||||||
_hide_pulse_visuals()
|
|
||||||
$AIFace.text = ":D"
|
|
||||||
_punch_face(1.5, 0.0)
|
|
||||||
flash(Color.RED)
|
|
||||||
active = false
|
|
||||||
doors_closing.emit()
|
|
||||||
return false
|
|
||||||
|
|
||||||
func flash(color: Color):
|
func flash(color: Color):
|
||||||
var style = get_theme_stylebox("panel") as StyleBoxFlat
|
var style = get_theme_stylebox("panel") as StyleBoxFlat
|
||||||
|
|
@ -329,12 +283,6 @@ func _stop_ready_pulse():
|
||||||
_ready_pulse_tween = null
|
_ready_pulse_tween = null
|
||||||
$TargetZone.modulate.a = 1.0
|
$TargetZone.modulate.a = 1.0
|
||||||
|
|
||||||
func _hide_pulse_visuals():
|
|
||||||
$SweepLine.visible = false
|
|
||||||
_glow.visible = false
|
|
||||||
for ghost in _trail:
|
|
||||||
ghost.visible = false
|
|
||||||
|
|
||||||
func _punch_face(scale_amount: float, shake_amount: float):
|
func _punch_face(scale_amount: float, shake_amount: float):
|
||||||
if _face_scale_tween:
|
if _face_scale_tween:
|
||||||
_face_scale_tween.kill()
|
_face_scale_tween.kill()
|
||||||
|
|
|
||||||
104
scenes/shaft_strip.gd
Normal file
104
scenes/shaft_strip.gd
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
extends VBoxContainer
|
||||||
|
|
||||||
|
const COLOR_CURRENT_BG := Color(0.83, 0.63, 0.09, 1)
|
||||||
|
const COLOR_CURRENT_FONT := Color(0.05, 0.05, 0.05, 1)
|
||||||
|
const COLOR_FUTURE_BG := Color(0.05, 0.18, 0.05, 1)
|
||||||
|
const COLOR_FUTURE_FONT := Color(0.2, 1, 0.2, 1)
|
||||||
|
const COLOR_CLEARED_BG := Color(0.05, 0.12, 0.05, 1)
|
||||||
|
const COLOR_CLEARED_FONT := Color(0.2, 0.55, 0.2, 1)
|
||||||
|
const COLOR_GROUND_BG := Color(0.08, 0.25, 0.08, 1)
|
||||||
|
const COLOR_GROUND_FONT := Color(0.5, 1, 0.5, 1)
|
||||||
|
const COLOR_BORDER := Color(0.2, 1, 0.2, 1)
|
||||||
|
|
||||||
|
const STATE_CURRENT := 0
|
||||||
|
const STATE_CLEARED := 1
|
||||||
|
const STATE_FUTURE := 2
|
||||||
|
const STATE_GROUND := 3
|
||||||
|
|
||||||
|
var _cells: Array = []
|
||||||
|
var _current_floor: int = EventBus.STARTING_FLOOR
|
||||||
|
var _styles: Array[StyleBoxFlat] = []
|
||||||
|
var _font_colors: Array[Color] = []
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
add_theme_constant_override("separation", 2)
|
||||||
|
_build_styles()
|
||||||
|
_build_cells()
|
||||||
|
_refresh()
|
||||||
|
EventBus.floor_changed.connect(_on_floor_changed)
|
||||||
|
|
||||||
|
func _build_styles():
|
||||||
|
_styles = [
|
||||||
|
_make_style(COLOR_CURRENT_BG, 2),
|
||||||
|
_make_style(COLOR_CLEARED_BG, 1),
|
||||||
|
_make_style(COLOR_FUTURE_BG, 1),
|
||||||
|
_make_style(COLOR_GROUND_BG, 2),
|
||||||
|
]
|
||||||
|
_font_colors = [
|
||||||
|
COLOR_CURRENT_FONT,
|
||||||
|
COLOR_CLEARED_FONT,
|
||||||
|
COLOR_FUTURE_FONT,
|
||||||
|
COLOR_GROUND_FONT,
|
||||||
|
]
|
||||||
|
|
||||||
|
func _make_style(bg: Color, border_width: int) -> StyleBoxFlat:
|
||||||
|
var style := StyleBoxFlat.new()
|
||||||
|
style.bg_color = bg
|
||||||
|
style.border_color = COLOR_BORDER
|
||||||
|
style.border_width_left = border_width
|
||||||
|
style.border_width_right = border_width
|
||||||
|
style.border_width_top = border_width
|
||||||
|
style.border_width_bottom = border_width
|
||||||
|
style.content_margin_left = 4
|
||||||
|
style.content_margin_right = 4
|
||||||
|
style.content_margin_top = 4
|
||||||
|
style.content_margin_bottom = 4
|
||||||
|
return style
|
||||||
|
|
||||||
|
func _build_cells():
|
||||||
|
var total := EventBus.STARTING_FLOOR
|
||||||
|
for i in range(total):
|
||||||
|
var floor_num := total - i
|
||||||
|
var cell := PanelContainer.new()
|
||||||
|
cell.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
|
cell.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||||
|
|
||||||
|
var label := Label.new()
|
||||||
|
label.text = "G" if floor_num == 1 else str(floor_num)
|
||||||
|
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||||
|
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||||
|
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
|
label.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||||
|
label.add_theme_font_size_override("font_size", 20)
|
||||||
|
cell.add_child(label)
|
||||||
|
|
||||||
|
add_child(cell)
|
||||||
|
_cells.append({ "panel": cell, "label": label, "floor": floor_num })
|
||||||
|
|
||||||
|
func _on_floor_changed(floor_num: int):
|
||||||
|
if floor_num == _current_floor:
|
||||||
|
return
|
||||||
|
_current_floor = floor_num
|
||||||
|
_refresh()
|
||||||
|
|
||||||
|
func _refresh():
|
||||||
|
for entry in _cells:
|
||||||
|
_style_cell(entry)
|
||||||
|
|
||||||
|
func _style_cell(entry: Dictionary):
|
||||||
|
var floor_num: int = entry["floor"]
|
||||||
|
var panel: PanelContainer = entry["panel"]
|
||||||
|
var label: Label = entry["label"]
|
||||||
|
|
||||||
|
var state: int
|
||||||
|
if floor_num == _current_floor:
|
||||||
|
state = STATE_CURRENT
|
||||||
|
elif floor_num > _current_floor:
|
||||||
|
state = STATE_CLEARED
|
||||||
|
elif floor_num == 1:
|
||||||
|
state = STATE_GROUND
|
||||||
|
else:
|
||||||
|
state = STATE_FUTURE
|
||||||
|
|
||||||
|
panel.add_theme_stylebox_override("panel", _styles[state])
|
||||||
|
label.add_theme_color_override("font_color", _font_colors[state])
|
||||||
1
scenes/shaft_strip.gd.uid
Normal file
1
scenes/shaft_strip.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dy2oned2f8ppy
|
||||||
13
scenes/shaft_strip.tscn
Normal file
13
scenes/shaft_strip.tscn
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
[gd_scene format=3 uid="uid://dshaftstrip01"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scenes/shaft_strip.gd" id="1_shaftstrip"]
|
||||||
|
|
||||||
|
[node name="ShaftStrip" type="VBoxContainer"]
|
||||||
|
anchors_preset = 9
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = 12.0
|
||||||
|
offset_top = 12.0
|
||||||
|
offset_right = 60.0
|
||||||
|
offset_bottom = -12.0
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_shaftstrip")
|
||||||
|
|
@ -24,7 +24,7 @@ func _ready():
|
||||||
_last_chase = stream
|
_last_chase = stream
|
||||||
$ScreamPlayer.stream = stream
|
$ScreamPlayer.stream = stream
|
||||||
var delay := randf_range(0.0, 0.5)
|
var delay := randf_range(0.0, 0.5)
|
||||||
get_tree().create_timer(delay).timeout.connect(
|
get_tree().create_timer(delay, false).timeout.connect(
|
||||||
func(): $ScreamPlayer.play(),
|
func(): $ScreamPlayer.play(),
|
||||||
CONNECT_ONE_SHOT
|
CONNECT_ONE_SHOT
|
||||||
)
|
)
|
||||||
|
|
@ -36,7 +36,7 @@ func _physics_process(_delta):
|
||||||
func _on_area_3d_area_entered(area: Area3D) -> void:
|
func _on_area_3d_area_entered(area: Area3D) -> void:
|
||||||
if area == safety_zone and not _saved:
|
if area == safety_zone and not _saved:
|
||||||
_saved = true
|
_saved = true
|
||||||
get_tree().create_timer(0.5).timeout.connect(
|
get_tree().create_timer(0.5, false).timeout.connect(
|
||||||
func(): queue_free(),
|
func(): queue_free(),
|
||||||
CONNECT_ONE_SHOT
|
CONNECT_ONE_SHOT
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
extends CanvasLayer
|
extends CanvasLayer
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
if EventBus.debug_starting_floor > 0:
|
||||||
|
call_deferred("_start")
|
||||||
|
return
|
||||||
get_tree().paused = true
|
get_tree().paused = true
|
||||||
|
|
||||||
func _unhandled_input(event):
|
func _unhandled_input(event):
|
||||||
|
|
@ -8,6 +11,14 @@ func _unhandled_input(event):
|
||||||
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()
|
get_viewport().set_input_as_handled()
|
||||||
_start()
|
_start()
|
||||||
|
elif event.keycode >= KEY_1 and event.keycode <= KEY_9:
|
||||||
|
EventBus.debug_starting_floor = event.keycode - KEY_0
|
||||||
|
get_viewport().set_input_as_handled()
|
||||||
|
_start()
|
||||||
|
elif event.keycode == KEY_0:
|
||||||
|
EventBus.debug_starting_floor = EventBus.STARTING_FLOOR
|
||||||
|
get_viewport().set_input_as_handled()
|
||||||
|
_start()
|
||||||
|
|
||||||
func _start():
|
func _start():
|
||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,6 @@
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://ba3of2ykdjqcl" path="res://scenes/title_screen.gd" id="1"]
|
[ext_resource type="Script" uid="uid://ba3of2ykdjqcl" path="res://scenes/title_screen.gd" id="1"]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="CardStyle"]
|
|
||||||
bg_color = Color(0.05, 0.18, 0.05, 1)
|
|
||||||
border_width_left = 3
|
|
||||||
border_width_top = 3
|
|
||||||
border_width_right = 3
|
|
||||||
border_width_bottom = 3
|
|
||||||
border_color = Color(0.2, 1, 0.2, 1)
|
|
||||||
corner_radius_top_left = 6
|
|
||||||
corner_radius_top_right = 6
|
|
||||||
corner_radius_bottom_right = 6
|
|
||||||
corner_radius_bottom_left = 6
|
|
||||||
|
|
||||||
[node name="TitleScreen" type="CanvasLayer" unique_id=1795090261]
|
[node name="TitleScreen" type="CanvasLayer" unique_id=1795090261]
|
||||||
process_mode = 3
|
process_mode = 3
|
||||||
layer = 20
|
layer = 20
|
||||||
|
|
@ -24,7 +12,7 @@ anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
color = Color(0, 0, 0, 0.85)
|
color = Color(0.05, 0.18, 0.05, 1)
|
||||||
|
|
||||||
[node name="Center" type="CenterContainer" parent="." unique_id=9544562]
|
[node name="Center" type="CenterContainer" parent="." unique_id=9544562]
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
|
|
@ -33,7 +21,6 @@ anchor_bottom = 1.0
|
||||||
|
|
||||||
[node name="Card" type="PanelContainer" parent="Center" unique_id=1305454967]
|
[node name="Card" type="PanelContainer" parent="Center" unique_id=1305454967]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_styles/panel = SubResource("CardStyle")
|
|
||||||
|
|
||||||
[node name="Margin" type="MarginContainer" parent="Center/Card" unique_id=1871871714]
|
[node name="Margin" type="MarginContainer" parent="Center/Card" unique_id=1871871714]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
|
||||||
78
scenes/world.gd
Normal file
78
scenes/world.gd
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
extends Node3D
|
||||||
|
|
||||||
|
const DIM_FACTOR := 0.5
|
||||||
|
const DIM_DURATION := 0.5
|
||||||
|
const WALL_DISPLAY_COLOR := Color(0.83, 0.63, 0.09)
|
||||||
|
const RobotScene := preload("res://scenes/robot.tscn")
|
||||||
|
|
||||||
|
@onready var _wall_display: Label3D = $ElevatorSafeZone/Elevator/WallDisplay
|
||||||
|
@onready var _hum: AudioStreamPlayer3D = $ElevatorSafeZone/Elevator/ElevatorHum
|
||||||
|
@onready var _robot_spawn: Marker3D = %RobotSpawn
|
||||||
|
|
||||||
|
var _dim_targets: Array = []
|
||||||
|
var _original_modulates: Array[Color] = []
|
||||||
|
var _modulate_tween: Tween = null
|
||||||
|
var _current_floor: int = EventBus.STARTING_FLOOR
|
||||||
|
var _robot: Node3D = null
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
_collect_dim_targets()
|
||||||
|
_wall_display.modulate = WALL_DISPLAY_COLOR
|
||||||
|
_wall_display.text = str(_current_floor)
|
||||||
|
EventBus.doors_closed.connect(_on_doors_closed)
|
||||||
|
EventBus.doors_opened.connect(_on_doors_opened)
|
||||||
|
EventBus.floor_changed.connect(_on_floor_changed)
|
||||||
|
EventBus.game_lost.connect(func(_reason: String): _free_robot())
|
||||||
|
EventBus.game_won.connect(_free_robot)
|
||||||
|
|
||||||
|
func _collect_dim_targets() -> void:
|
||||||
|
for path in [
|
||||||
|
"ElevatorSafeZone/Elevator/ElevatorWallLeft/Wall",
|
||||||
|
"ElevatorSafeZone/Elevator/ElevatorWallRight/Wall",
|
||||||
|
"ElevatorSafeZone/Elevator/ElevatorDoorLeft/Panel",
|
||||||
|
"ElevatorSafeZone/Elevator/ElevatorDoorRight/Panel",
|
||||||
|
]:
|
||||||
|
var node := get_node_or_null(path)
|
||||||
|
if node and node is GeometryInstance3D:
|
||||||
|
_dim_targets.append(node)
|
||||||
|
_original_modulates.append(node.modulate)
|
||||||
|
|
||||||
|
func _on_doors_closed(_fast: bool) -> void:
|
||||||
|
_tween_dim(DIM_FACTOR)
|
||||||
|
if _hum.stream:
|
||||||
|
_hum.play()
|
||||||
|
var next_floor: int = max(1, _current_floor - 1)
|
||||||
|
_wall_display.text = str(next_floor)
|
||||||
|
_free_robot()
|
||||||
|
|
||||||
|
func _on_doors_opened() -> void:
|
||||||
|
_tween_dim(1.0)
|
||||||
|
_hum.stop()
|
||||||
|
_spawn_robot()
|
||||||
|
|
||||||
|
func _spawn_robot() -> void:
|
||||||
|
_free_robot()
|
||||||
|
_robot = RobotScene.instantiate()
|
||||||
|
_robot.position = _robot_spawn.position
|
||||||
|
_robot.safety_zone = $ElevatorSafeZone
|
||||||
|
add_child(_robot)
|
||||||
|
|
||||||
|
func _free_robot() -> void:
|
||||||
|
if is_instance_valid(_robot):
|
||||||
|
_robot.queue_free()
|
||||||
|
_robot = null
|
||||||
|
|
||||||
|
func _on_floor_changed(new_floor: int) -> void:
|
||||||
|
_current_floor = new_floor
|
||||||
|
_wall_display.text = str(new_floor)
|
||||||
|
|
||||||
|
func _tween_dim(factor: float) -> void:
|
||||||
|
if _modulate_tween:
|
||||||
|
_modulate_tween.kill()
|
||||||
|
_modulate_tween = create_tween()
|
||||||
|
_modulate_tween.set_parallel(true)
|
||||||
|
for i in _dim_targets.size():
|
||||||
|
var node: GeometryInstance3D = _dim_targets[i]
|
||||||
|
var base: Color = _original_modulates[i]
|
||||||
|
var target := Color(base.r * factor, base.g * factor, base.b * factor, base.a)
|
||||||
|
_modulate_tween.tween_property(node, "modulate", target, DIM_DURATION)
|
||||||
1
scenes/world.gd.uid
Normal file
1
scenes/world.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://c6v2lhrkeup5i
|
||||||
|
|
@ -4,11 +4,13 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://cxnocjdotkl5e" path="res://scenes/hall_block.tscn" id="1_tlwt5"]
|
[ext_resource type="PackedScene" uid="uid://cxnocjdotkl5e" path="res://scenes/hall_block.tscn" id="1_tlwt5"]
|
||||||
[ext_resource type="PackedScene" uid="uid://v07x1vbept3i" path="res://scenes/robot.tscn" id="3_71j4m"]
|
[ext_resource type="PackedScene" uid="uid://v07x1vbept3i" path="res://scenes/robot.tscn" id="3_71j4m"]
|
||||||
[ext_resource type="PackedScene" uid="uid://brd3iponame0e" path="res://scenes/elevator.tscn" id="4_k0juu"]
|
[ext_resource type="PackedScene" uid="uid://brd3iponame0e" path="res://scenes/elevator.tscn" id="4_k0juu"]
|
||||||
|
[ext_resource type="Script" path="res://scenes/world.gd" id="5_world"]
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_k0juu"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_k0juu"]
|
||||||
size = Vector3(3.8, 6.6328125, 0.8612671)
|
size = Vector3(3.8, 6.6328125, 0.8612671)
|
||||||
|
|
||||||
[node name="World" type="Node3D" unique_id=831374579]
|
[node name="World" type="Node3D" unique_id=831374579]
|
||||||
|
script = ExtResource("5_world")
|
||||||
|
|
||||||
[node name="Camera3D" parent="." unique_id=691202574 instance=ExtResource("1_f3sb7")]
|
[node name="Camera3D" parent="." unique_id=691202574 instance=ExtResource("1_f3sb7")]
|
||||||
transform = Transform3D(-0.9999863, 0.005235964, 8.742278e-08, 0.005235964, 0.9999863, 0, -8.7421576e-08, 4.577425e-10, -1, 0.003270626, 2.9093587, -10.424748)
|
transform = Transform3D(-0.9999863, 0.005235964, 8.742278e-08, 0.005235964, 0.9999863, 0, -8.7421576e-08, 4.577425e-10, -1, 0.003270626, 2.9093587, -10.424748)
|
||||||
|
|
@ -29,9 +31,6 @@ transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0
|
||||||
[node name="HallBlock0" parent="Hall" unique_id=1901572100 instance=ExtResource("1_tlwt5")]
|
[node name="HallBlock0" parent="Hall" unique_id=1901572100 instance=ExtResource("1_tlwt5")]
|
||||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, -5.4)
|
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, -5.4)
|
||||||
|
|
||||||
[node name="Robot" parent="." unique_id=985954885 instance=ExtResource("3_71j4m")]
|
|
||||||
transform = Transform3D(3.5, 0, 0, 0, 3.5, 0, 0, 0, 3.5, 0, 2.5, 11.461113)
|
|
||||||
|
|
||||||
[node name="ElevatorSafeZone" type="Area3D" parent="." unique_id=1186678129]
|
[node name="ElevatorSafeZone" type="Area3D" parent="." unique_id=1186678129]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -8.351522)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -8.351522)
|
||||||
|
|
@ -39,6 +38,22 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -8.351522)
|
||||||
[node name="Elevator" parent="ElevatorSafeZone" unique_id=242258467 instance=ExtResource("4_k0juu")]
|
[node name="Elevator" parent="ElevatorSafeZone" unique_id=242258467 instance=ExtResource("4_k0juu")]
|
||||||
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 3, -0.061756134)
|
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 3, -0.061756134)
|
||||||
|
|
||||||
|
[node name="WallDisplay" type="Label3D" parent="ElevatorSafeZone/Elevator"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.95, 0.05)
|
||||||
|
pixel_size = 0.005
|
||||||
|
text = "10"
|
||||||
|
font_size = 96
|
||||||
|
outline_size = 0
|
||||||
|
modulate = Color(0.83, 0.63, 0.09, 1)
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="ElevatorHum" type="AudioStreamPlayer3D" parent="ElevatorSafeZone/Elevator"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||||
|
autoplay = false
|
||||||
|
unit_size = 4.0
|
||||||
|
max_distance = 30.0
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="ElevatorSafeZone" unique_id=264489586]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="ElevatorSafeZone" unique_id=264489586]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.24584353, 2.8164063, -0.56969166)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.24584353, 2.8164063, -0.56969166)
|
||||||
shape = SubResource("BoxShape3D_k0juu")
|
shape = SubResource("BoxShape3D_k0juu")
|
||||||
|
|
@ -50,5 +65,5 @@ gizmo_extents = 1.46
|
||||||
|
|
||||||
[node name="RobotSpawn" type="Marker3D" parent="." unique_id=1467272276]
|
[node name="RobotSpawn" type="Marker3D" parent="." unique_id=1467272276]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, 16.264744)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, 11.5)
|
||||||
gizmo_extents = 1.46
|
gizmo_extents = 1.46
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ extends Node
|
||||||
|
|
||||||
const STARTING_FLOOR := 10
|
const STARTING_FLOOR := 10
|
||||||
|
|
||||||
|
var debug_starting_floor: int = 0
|
||||||
|
|
||||||
@warning_ignore_start("unused_signal")
|
@warning_ignore_start("unused_signal")
|
||||||
|
|
||||||
signal floor_changed(floor_num: int)
|
signal floor_changed(floor_num: int)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue