Scoring, floor timer, and hud updates
- Move elevator panel logic out of HUD; HUD now listens for signals to update floor, saved, people, and score labels - Add scaling rescue threshold that grows as you descend, with bonus points for exceeding it - Add per-floor timer that triggers a losing when expired - Add show_loss state on the screen for too-few-people and timeout failures
This commit is contained in:
parent
7939e77dff
commit
feb467c832
6 changed files with 97 additions and 48 deletions
|
|
@ -1,42 +1,98 @@
|
|||
extends Control
|
||||
# now we're cookin with bacon!
|
||||
|
||||
# I HAVE NO IDEA WHAT I'M DOIN!!!
|
||||
# Original version
|
||||
var current_floor := 10
|
||||
var saved_count := 0
|
||||
|
||||
var doors_closing := false
|
||||
|
||||
# threshold increases as you descend!
|
||||
var base_threshold := 2
|
||||
var threshold_increase_interval := 2 # +1 required every x floors
|
||||
|
||||
# scoring
|
||||
var score := 0
|
||||
var points_per_person := 100
|
||||
|
||||
# placeholder until henry's system provides real count
|
||||
var people_in_elevator := 3
|
||||
|
||||
# placeholder until hnry's collision signal is ready
|
||||
var floor_time_limit := 10.0
|
||||
var floor_timer: Timer
|
||||
|
||||
signal floor_changed(floor_num: int)
|
||||
signal saved_changed(count: int)
|
||||
signal score_changed(new_score: int)
|
||||
signal people_changed(count: int, threshold: int)
|
||||
signal game_won
|
||||
signal game_lost
|
||||
|
||||
func get_threshold() -> int:
|
||||
var floors_cleared := 10 - current_floor
|
||||
return base_threshold + floors_cleared / threshold_increase_interval
|
||||
|
||||
func _ready():
|
||||
$PanelMargin/PanelColumn/CloseButton.pressed.connect(_on_close_pressed)
|
||||
# 10 floors is probably a lot but will make testing easier.
|
||||
#$StatsMargin/StatsColumn/FloorLabel.text = "FLOOR: 10"
|
||||
|
||||
floor_timer = Timer.new()
|
||||
floor_timer.one_shot = true
|
||||
floor_timer.wait_time = floor_time_limit
|
||||
floor_timer.timeout.connect(_on_timer_expired)
|
||||
add_child(floor_timer)
|
||||
floor_timer.start()
|
||||
|
||||
floor_changed.emit(current_floor)
|
||||
people_changed.emit(people_in_elevator, get_threshold())
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event is InputEventKey and event.pressed and event.keycode == KEY_SPACE:
|
||||
_on_close_pressed()
|
||||
|
||||
func _on_close_pressed():
|
||||
# don't let 'em spam the button
|
||||
func _on_timer_expired():
|
||||
if doors_closing:
|
||||
return
|
||||
var screen = $ElevatorPanel/PanelMargin/PanelColumn/Screen
|
||||
doors_closing = true
|
||||
var screen = $PanelMargin/PanelColumn/Screen
|
||||
screen.show_loss("TOO LATE :[")
|
||||
game_lost.emit()
|
||||
|
||||
func _on_close_pressed():
|
||||
if doors_closing:
|
||||
return
|
||||
|
||||
var screen = $PanelMargin/PanelColumn/Screen
|
||||
var success = screen.attempt_hack()
|
||||
if success:
|
||||
doors_closing = true
|
||||
saved_count += 1
|
||||
floor_timer.stop()
|
||||
|
||||
if people_in_elevator < get_threshold():
|
||||
screen.show_loss("TOO FEW :[[")
|
||||
game_lost.emit()
|
||||
return
|
||||
|
||||
# base points per person, bonus for each person above threshold??
|
||||
var bonus: int = max(0, people_in_elevator - get_threshold()) * points_per_person
|
||||
score += people_in_elevator * points_per_person + bonus
|
||||
score_changed.emit(score)
|
||||
|
||||
saved_count += people_in_elevator
|
||||
current_floor -= 1
|
||||
$StatsMargin/StatsColumn/SavedLabel.text = "SAVED: " + str(saved_count)
|
||||
$StatsMargin/StatsColumn/FloorLabel.text = "FLOOR: " + str(current_floor)
|
||||
saved_changed.emit(saved_count)
|
||||
floor_changed.emit(current_floor)
|
||||
|
||||
if current_floor <= 1:
|
||||
screen.show_win()
|
||||
game_won.emit()
|
||||
else:
|
||||
screen.show_countdown()
|
||||
var tween = create_tween()
|
||||
tween.tween_callback(func():
|
||||
screen.reset_hack()
|
||||
doors_closing = false
|
||||
people_in_elevator = 3 # placeholder
|
||||
people_changed.emit(people_in_elevator, get_threshold())
|
||||
floor_timer.start()
|
||||
).set_delay(2.0)
|
||||
else:
|
||||
print("MISSED! AI is faster now!")
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
[ext_resource type="PackedScene" uid="uid://bnv1xxgceqbrc" path="res://scenes/world.tscn" id="1_uwrxv"]
|
||||
[ext_resource type="PackedScene" uid="uid://cbvi51vvpt7mu" path="res://scenes/hud.tscn" id="2_yqjtg"]
|
||||
[ext_resource type="PackedScene" uid="uid://nca1hcujxru0" path="res://scenes/elevator_panel.tscn" id="3_lnu2h"]
|
||||
|
||||
[node name="Game" type="Node3D" unique_id=1456297160]
|
||||
|
||||
|
|
@ -12,3 +13,5 @@
|
|||
[node name="HUD" parent="CanvasHud" unique_id=769131693 instance=ExtResource("2_yqjtg")]
|
||||
|
||||
[node name="CanvasPanel" type="CanvasLayer" parent="." unique_id=667193210]
|
||||
|
||||
[node name="ElevatorPanel" parent="CanvasPanel" unique_id=574176994 instance=ExtResource("3_lnu2h")]
|
||||
|
|
|
|||
|
|
@ -1,41 +1,19 @@
|
|||
extends MarginContainer
|
||||
|
||||
# I HAVE NO IDEA WHAT I'M DOIN!!!
|
||||
var current_floor := 10
|
||||
var saved_count := 0
|
||||
|
||||
var doors_closing := false
|
||||
|
||||
|
||||
func _ready():
|
||||
#$ElevatorPanel/PanelMargin/PanelColumn/CloseButton.pressed.connect(_on_close_pressed)
|
||||
# 10 floors is probably a lot but will make testing easier.
|
||||
$StatsColumn/FloorLabel.text = "FLOOR: 10"
|
||||
$StatsColumn/SavedLabel.text = "SAVED: 0"
|
||||
$StatsColumn/PeopleLabel.text = "PEOPLE: 0/2"
|
||||
$StatsColumn/ScoreLabel.text = "SCORE: 0"
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event is InputEventKey and event.pressed and event.keycode == KEY_SPACE:
|
||||
_on_close_pressed()
|
||||
func update_floor(floor_num: int):
|
||||
$StatsColumn/FloorLabel.text = "FLOOR: " + str(floor_num)
|
||||
|
||||
func _on_close_pressed():
|
||||
# don't let 'em spam the button
|
||||
if doors_closing:
|
||||
return
|
||||
var screen = $ElevatorPanel/PanelMargin/PanelColumn/Screen
|
||||
var success = screen.attempt_hack()
|
||||
if success:
|
||||
doors_closing = true
|
||||
saved_count += 1
|
||||
current_floor -= 1
|
||||
$StatsMargin/StatsColumn/SavedLabel.text = "SAVED: " + str(saved_count)
|
||||
$StatsMargin/StatsColumn/FloorLabel.text = "FLOOR: " + str(current_floor)
|
||||
if current_floor <= 1:
|
||||
screen.show_win()
|
||||
else:
|
||||
screen.show_countdown()
|
||||
var tween = create_tween()
|
||||
tween.tween_callback(func():
|
||||
screen.reset_hack()
|
||||
doors_closing = false
|
||||
).set_delay(2.0)
|
||||
else:
|
||||
print("MISSED! AI is faster now!")
|
||||
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)
|
||||
|
||||
func update_score(new_score: int):
|
||||
$StatsColumn/ScoreLabel.text = "SCORE: " + str(new_score)
|
||||
|
|
|
|||
|
|
@ -26,3 +26,7 @@ text = "SAVED: 0"
|
|||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "FLOOR: 0"
|
||||
|
||||
[node name="ScoreLabel" type="Label" parent="StatsColumn" unique_id=1595653166]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 24
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
extends Panel
|
||||
|
||||
# my beautiful screen
|
||||
var sweep_speed := 150.0
|
||||
var sweep_direction := 1
|
||||
var sweep_x := 0.0
|
||||
|
|
@ -76,7 +76,14 @@ func show_win():
|
|||
$SweepLine.visible = false
|
||||
$TargetZone.visible = false
|
||||
$AIFace.text = "ESCAPED"
|
||||
flash(Color.GREEN)
|
||||
flash(Color.GREEN)
|
||||
|
||||
func show_loss(message := "TOO FEW"):
|
||||
is_hacked = false
|
||||
$SweepLine.visible = false
|
||||
$TargetZone.visible = false
|
||||
$AIFace.text = message
|
||||
flash(Color.RED)
|
||||
|
||||
# target zones
|
||||
func attempt_hack() -> bool:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue