Scale difficulty per floor and reset robot each floor
This commit is contained in:
parent
082027088a
commit
db9b6df51f
4 changed files with 62 additions and 60 deletions
|
|
@ -1,37 +1,53 @@
|
|||
extends CharacterBody3D
|
||||
|
||||
var robot_delay = randf_range(3.5,7)
|
||||
var robot_ready: bool = false
|
||||
var robot_win: bool = false
|
||||
var speed: int = 3.5
|
||||
var speed: float = 1.0
|
||||
var doors_open: bool = false
|
||||
var stun_remaining: float = 0.0
|
||||
|
||||
var _delay_remaining: float = 0.0
|
||||
var _spawn_transform: Transform3D
|
||||
|
||||
@onready var safety_zone = get_node("/root/Game/World/ElevatorDoors/ElevatorSafeZone")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_spawn_transform = transform
|
||||
EventBus.doors_opened.connect(func(): doors_open = true)
|
||||
EventBus.doors_closed.connect(func(): doors_open = false)
|
||||
EventBus.robot_stun_requested.connect(func(d: float): stun_remaining += d)
|
||||
await get_tree().create_timer(robot_delay).timeout
|
||||
robot_ready = true
|
||||
EventBus.robot_floor_started.connect(_on_floor_started)
|
||||
|
||||
func _on_floor_started(delay: float, new_speed: float) -> void:
|
||||
if robot_win:
|
||||
return
|
||||
transform = _spawn_transform
|
||||
velocity = Vector3.ZERO
|
||||
stun_remaining = 0.0
|
||||
speed = new_speed
|
||||
_delay_remaining = delay
|
||||
robot_ready = false
|
||||
|
||||
func _physics_process(delta):
|
||||
if robot_win:
|
||||
return
|
||||
|
||||
if robot_win == true: return
|
||||
if robot_ready == false: return
|
||||
if not robot_ready:
|
||||
if _delay_remaining > 0.0:
|
||||
_delay_remaining -= delta
|
||||
if _delay_remaining <= 0.0:
|
||||
robot_ready = true
|
||||
return
|
||||
|
||||
if stun_remaining > 0.0:
|
||||
stun_remaining -= delta
|
||||
velocity = Vector3.ZERO
|
||||
move_and_slide()
|
||||
return
|
||||
|
||||
if robot_ready == true:
|
||||
velocity.z -= speed * delta
|
||||
move_and_slide()
|
||||
|
||||
if robot_win == true: return
|
||||
|
||||
velocity = Vector3(0, 0, -speed)
|
||||
move_and_slide()
|
||||
|
||||
|
||||
func _on_area_3d_area_entered(area: Area3D) -> void:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue