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!")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue