Animate doors!
This commit is contained in:
parent
e4ebd6bf83
commit
7ce2863cfd
13 changed files with 160 additions and 23 deletions
|
|
@ -18,7 +18,9 @@ var block_zone_speed := 0.0
|
|||
var block_zone_direction := -1
|
||||
var block_zone_min_x := 0.0
|
||||
var block_zone_max_x := 0.0
|
||||
const BLOCK_ZONE_RANGE_LEFT_RATIO := 0.5
|
||||
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
|
||||
|
|
@ -40,14 +42,15 @@ var _face_scale_tween: Tween
|
|||
var _face_shake_tween: Tween
|
||||
var _floor_label: Label
|
||||
|
||||
signal pulse_started(duration: float)
|
||||
signal pulse_blocked
|
||||
signal pulse_blocked_perfect
|
||||
signal doors_closing
|
||||
|
||||
func _ready():
|
||||
var bz = $TargetZone
|
||||
bz.size = Vector2(50, size.y - 40)
|
||||
bz.position = Vector2(size.x - bz.size.x - 10, 20)
|
||||
bz.size = Vector2(50, size.y - PULSE_TOP_MARGIN - PULSE_BOTTOM_MARGIN)
|
||||
bz.position = Vector2((size.x - bz.size.x) / 2, PULSE_TOP_MARGIN)
|
||||
|
||||
_perfect_zone = ColorRect.new()
|
||||
_perfect_zone.color = PERFECT_ZONE_COLOR
|
||||
|
|
@ -56,8 +59,8 @@ func _ready():
|
|||
_update_perfect_zone()
|
||||
|
||||
var sl = $SweepLine
|
||||
sl.size = Vector2(4, size.y - 40)
|
||||
sl.position = Vector2(0, 20)
|
||||
sl.size = Vector2(4, size.y - PULSE_TOP_MARGIN - PULSE_BOTTOM_MARGIN)
|
||||
sl.position = Vector2(0, PULSE_TOP_MARGIN)
|
||||
sl.visible = false
|
||||
|
||||
var face = $AIFace
|
||||
|
|
@ -105,15 +108,17 @@ func start(floor_num: int = 10):
|
|||
$AIFace.text = ">:)"
|
||||
$TargetZone.visible = true
|
||||
block_zone_moving = false
|
||||
$TargetZone.position.x = size.x - $TargetZone.size.x - 10
|
||||
$TargetZone.position.x = (size.x - $TargetZone.size.x) / 2
|
||||
|
||||
func set_block_zone_movement(speed: float):
|
||||
block_zone_speed = speed
|
||||
block_zone_moving = speed > 0.0
|
||||
var bz = $TargetZone
|
||||
block_zone_max_x = size.x - bz.size.x - 10
|
||||
block_zone_min_x = size.x * BLOCK_ZONE_RANGE_LEFT_RATIO
|
||||
bz.position.x = block_zone_max_x
|
||||
var range_half = size.x * MOVING_RANGE_RATIO / 2
|
||||
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():
|
||||
|
|
@ -125,15 +130,32 @@ func stop():
|
|||
func shrink_block_zone():
|
||||
var bz = $TargetZone
|
||||
var new_width = max(bz.size.x - block_zone_shrink, block_zone_min)
|
||||
var new_x = size.x - new_width - 10
|
||||
var new_x = (size.x - new_width) / 2
|
||||
var tween = create_tween()
|
||||
tween.set_parallel(true)
|
||||
tween.tween_property(bz, "size:x", new_width, 0.3)
|
||||
tween.tween_property(bz, "position:x", new_x, 0.3)
|
||||
tween.tween_method(func(_v): _update_perfect_zone(), 0.0, 1.0, 0.3)
|
||||
|
||||
var _displayed_floor := -1
|
||||
|
||||
func _update_floor_label(floor_num: int):
|
||||
_floor_label.text = "FL " + str(floor_num)
|
||||
if _displayed_floor == floor_num:
|
||||
return
|
||||
var new_text = "FL " + str(floor_num)
|
||||
if _displayed_floor == -1:
|
||||
_floor_label.text = new_text
|
||||
_displayed_floor = floor_num
|
||||
return
|
||||
_displayed_floor = floor_num
|
||||
_floor_label.pivot_offset = Vector2(0, _floor_label.size.y)
|
||||
var tween = create_tween()
|
||||
tween.tween_property(_floor_label, "scale:y", 0.0, 0.15).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_IN)
|
||||
tween.tween_callback(func():
|
||||
_floor_label.text = new_text
|
||||
_floor_label.pivot_offset = Vector2.ZERO
|
||||
)
|
||||
tween.tween_property(_floor_label, "scale:y", 1.0, 0.15).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
||||
|
||||
func _update_perfect_zone():
|
||||
var bz = $TargetZone
|
||||
|
|
@ -153,6 +175,7 @@ func launch_pulse():
|
|||
ghost.visible = true
|
||||
$AIFace.text = ">:)"
|
||||
_start_ready_pulse()
|
||||
pulse_started.emit(size.x / pulse_speed)
|
||||
|
||||
func get_pulse_gap() -> float:
|
||||
return pulse_gap
|
||||
|
|
@ -260,10 +283,12 @@ func show_onboarding(msg: String):
|
|||
$AIFace.add_theme_font_size_override("font_size", 18)
|
||||
$AIFace.size = Vector2(size.x, 60)
|
||||
$AIFace.text = msg
|
||||
$TargetZone.visible = false
|
||||
|
||||
func end_onboarding():
|
||||
$AIFace.add_theme_font_size_override("font_size", 32)
|
||||
$AIFace.size = Vector2(size.x, 30)
|
||||
$TargetZone.visible = true
|
||||
|
||||
func _start_ready_pulse():
|
||||
if _ready_pulse_tween:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue