From b92388cfe097f546056d4f6e2c35af72a0329de0 Mon Sep 17 00:00:00 2001 From: Jennie Robinson Faber Date: Mon, 11 May 2026 17:23:46 +0100 Subject: [PATCH] Add quota dots to screen and color-code people count - And try to remove survivors after doors close with queue_free - And move panel?? Still not right. --- scenes/component_spawn.gd | 5 +++++ scenes/elevator.gd | 1 + scenes/elevator_panel.tscn | 6 +++--- scenes/hud.gd | 5 ++++- scenes/screen.gd | 28 ++++++++++++++++++++++++++++ scenes/survivor.gd | 2 +- scripts/event_bus.gd | 1 + 7 files changed, 43 insertions(+), 5 deletions(-) diff --git a/scenes/component_spawn.gd b/scenes/component_spawn.gd index a71b6bb..60e9f6f 100644 --- a/scenes/component_spawn.gd +++ b/scenes/component_spawn.gd @@ -12,6 +12,8 @@ var _batch_generation: int = 0 func _enter_tree() -> void: EventBus.floor_started.connect(_on_floor_started, CONNECT_DEFERRED) + EventBus.doors_closed.connect(_on_doors_closed) + EventBus.doors_fully_closed.connect(_clear_active_walkers) func _on_floor_started(count: int) -> void: _batch_generation += 1 @@ -20,6 +22,9 @@ func _on_floor_started(count: int) -> void: return _run_batch(count, _batch_generation) +func _on_doors_closed(_fast: bool) -> void: + _batch_generation += 1 + func _clear_active_walkers() -> void: for w in _active_walkers: if is_instance_valid(w): diff --git a/scenes/elevator.gd b/scenes/elevator.gd index 0a113a2..059462b 100644 --- a/scenes/elevator.gd +++ b/scenes/elevator.gd @@ -24,6 +24,7 @@ func _on_doors_opened(): func _on_doors_closed(fast: bool): _set_door_collision(true) _tween_doors(DOOR_CLOSED_X, DOOR_FAST_CLOSE_TIME if fast else DOOR_DEFAULT_TIME) + _tween.chain().tween_callback(func(): EventBus.doors_fully_closed.emit()) func _on_pulse_started(duration: float): _set_door_collision(true) diff --git a/scenes/elevator_panel.tscn b/scenes/elevator_panel.tscn index 08e7f0d..c69c6c5 100644 --- a/scenes/elevator_panel.tscn +++ b/scenes/elevator_panel.tscn @@ -16,10 +16,10 @@ anchor_left = 1.0 anchor_top = 0.5 anchor_right = 1.0 anchor_bottom = 0.5 -offset_left = -200.0 -offset_top = -140.0 +offset_left = -230.0 +offset_top = -160.0 offset_right = -10.0 -offset_bottom = 140.0 +offset_bottom = 160.0 grow_horizontal = 0 grow_vertical = 2 script = ExtResource("1_1gr6t") diff --git a/scenes/hud.gd b/scenes/hud.gd index 479a866..0873715 100644 --- a/scenes/hud.gd +++ b/scenes/hud.gd @@ -29,7 +29,10 @@ func update_saved(count: int): $StatsColumn/SavedLabel.text = "SAVED: " + str(count) func update_people(count: int, threshold: int): - $StatsColumn/PeopleLabel.text = "PEOPLE: " + str(count) + "/" + str(threshold) + var label = $StatsColumn/PeopleLabel + label.text = "PEOPLE: " + str(count) + "/" + str(threshold) + var color = Color(0.4, 1.0, 0.4) if count >= threshold else Color(1.0, 0.4, 0.4) + label.add_theme_color_override("font_color", color) func update_score(new_score: int): $StatsColumn/ScoreLabel.text = "SCORE: " + str(new_score) diff --git a/scenes/screen.gd b/scenes/screen.gd index 59330f2..46587c3 100644 --- a/scenes/screen.gd +++ b/scenes/screen.gd @@ -29,6 +29,11 @@ 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 @@ -42,6 +47,8 @@ var _face_scale_tween: Tween var _face_shake_tween: Tween var _flash_tween: Tween var _floor_label: Label +var _quota_dots: Array[ColorRect] = [] +var _quota_threshold := 0 signal pulse_started(duration: float) signal pulse_blocked @@ -99,6 +106,7 @@ func _ready(): _floor_label.mouse_filter = Control.MOUSE_FILTER_IGNORE add_child(_floor_label) EventBus.floor_changed.connect(_update_floor_label) + EventBus.people_changed.connect(_update_quota_dots) func start(floor_num: int = EventBus.STARTING_FLOOR): active = true @@ -151,6 +159,26 @@ func _update_floor_label(floor_num: int): _displayed_floor = floor_num UIUtils.flip_label_text(_floor_label, new_text) +func _update_quota_dots(count: int, threshold: int): + if threshold != _quota_threshold: + _quota_threshold = threshold + for dot in _quota_dots: + dot.queue_free() + _quota_dots.clear() + var total_w = threshold * QUOTA_DOT_SIZE + max(0, threshold - 1) * QUOTA_DOT_SPACING + var start_x = (size.x - total_w) / 2.0 + var y = size.y - QUOTA_DOT_Y_FROM_BOTTOM + for i in threshold: + var dot = ColorRect.new() + dot.size = Vector2(QUOTA_DOT_SIZE, QUOTA_DOT_SIZE) + dot.position = Vector2(start_x + i * (QUOTA_DOT_SIZE + QUOTA_DOT_SPACING), y) + dot.color = QUOTA_EMPTY_COLOR + dot.mouse_filter = Control.MOUSE_FILTER_IGNORE + add_child(dot) + _quota_dots.append(dot) + for i in _quota_dots.size(): + _quota_dots[i].color = QUOTA_FILLED_COLOR if i < count else QUOTA_EMPTY_COLOR + func _update_perfect_zone(): var bz = $TargetZone var width = bz.size.x * PERFECT_ZONE_RATIO diff --git a/scenes/survivor.gd b/scenes/survivor.gd index 5906960..ca17d05 100644 --- a/scenes/survivor.gd +++ b/scenes/survivor.gd @@ -11,7 +11,7 @@ var speed: int = 3 var clumsiness: int = 0 var _saved: bool = false -@onready var safety_zone = get_node("/root/Game/World/ElevatorSafeZone") +@onready var safety_zone: Node = get_node_or_null("/root/Game/World/ElevatorSafeZone") #func start(xform): diff --git a/scripts/event_bus.gd b/scripts/event_bus.gd index c726fc2..768236d 100644 --- a/scripts/event_bus.gd +++ b/scripts/event_bus.gd @@ -14,6 +14,7 @@ signal game_lost(reason: String) signal floor_started(survivor_count: int) signal doors_opened signal doors_closed(fast: bool) +signal doors_fully_closed signal pulse_started(duration: float) signal pulse_blocked signal robot_stun_requested(duration: float)