Animate doors!
This commit is contained in:
parent
e4ebd6bf83
commit
7ce2863cfd
13 changed files with 160 additions and 23 deletions
|
|
@ -27,16 +27,18 @@ var robot_delay_min := 1.0
|
|||
var people_in_elevator := 0
|
||||
|
||||
const PERFECT_STUN_DURATION := 0.25
|
||||
const PRE_PULSE_DELAY := 3.5
|
||||
|
||||
func _ready():
|
||||
var button = $PanelMargin/PanelColumn/CloseButton
|
||||
button.text = "BLOCK"
|
||||
button.text = "CLOSE"
|
||||
button.pressed.connect(_on_block_pressed)
|
||||
|
||||
var screen = $PanelMargin/PanelColumn/Screen
|
||||
screen.pulse_started.connect(_on_pulse_started)
|
||||
screen.pulse_blocked.connect(_on_pulse_blocked)
|
||||
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)
|
||||
|
||||
|
|
@ -49,8 +51,10 @@ func _unhandled_input(event):
|
|||
|
||||
func _start_floor():
|
||||
$SfxOpen.play()
|
||||
$SfxBell.play()
|
||||
doors_closing_flag = false
|
||||
people_in_elevator = 0
|
||||
$PanelMargin/PanelColumn/CloseButton.text = "CLOSE"
|
||||
EventBus.doors_opened.emit()
|
||||
|
||||
var floors_remaining = current_floor - 1
|
||||
|
|
@ -77,22 +81,40 @@ func _start_floor():
|
|||
screen.show_onboarding("BLOCK\nIN GREEN ZONE")
|
||||
get_tree().create_timer(3.0).timeout.connect(
|
||||
func():
|
||||
if not is_instance_valid(screen):
|
||||
return
|
||||
screen.end_onboarding()
|
||||
screen.launch_pulse(),
|
||||
CONNECT_ONE_SHOT
|
||||
)
|
||||
else:
|
||||
screen.launch_pulse()
|
||||
get_tree().create_timer(PRE_PULSE_DELAY).timeout.connect(
|
||||
func():
|
||||
if not is_instance_valid(self) or doors_closing_flag:
|
||||
return
|
||||
screen.launch_pulse(),
|
||||
CONNECT_ONE_SHOT
|
||||
)
|
||||
|
||||
func _on_block_pressed():
|
||||
if doors_closing_flag:
|
||||
return
|
||||
$PanelMargin/PanelColumn/Screen.attempt_block()
|
||||
var screen = $PanelMargin/PanelColumn/Screen
|
||||
if screen.pulse_active:
|
||||
screen.attempt_block()
|
||||
else:
|
||||
_on_doors_closing(false)
|
||||
|
||||
func _on_pulse_started(duration: float):
|
||||
$PanelMargin/PanelColumn/CloseButton.text = "BLOCK"
|
||||
EventBus.pulse_started.emit(duration)
|
||||
|
||||
func _on_pulse_blocked_perfect():
|
||||
EventBus.robot_stun_requested.emit(PERFECT_STUN_DURATION)
|
||||
|
||||
func _on_pulse_blocked():
|
||||
$PanelMargin/PanelColumn/CloseButton.text = "CLOSE"
|
||||
EventBus.pulse_blocked.emit()
|
||||
survivors_remaining -= 1
|
||||
people_in_elevator += 1
|
||||
$SfxDing.play()
|
||||
|
|
@ -111,11 +133,11 @@ func _on_pulse_blocked():
|
|||
CONNECT_ONE_SHOT
|
||||
)
|
||||
|
||||
func _on_doors_closing():
|
||||
func _on_doors_closing(fast: bool = false):
|
||||
if doors_closing_flag:
|
||||
return
|
||||
doors_closing_flag = true
|
||||
EventBus.doors_closed.emit()
|
||||
EventBus.doors_closed.emit(fast)
|
||||
|
||||
var screen = $PanelMargin/PanelColumn/Screen
|
||||
|
||||
|
|
@ -145,5 +167,5 @@ func _on_doors_closing():
|
|||
screen.shrink_block_zone()
|
||||
|
||||
var tween = create_tween()
|
||||
tween.tween_interval(2.0)
|
||||
tween.tween_interval(3.0)
|
||||
tween.tween_callback(_start_floor)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue