feat: animations working
This commit is contained in:
parent
2a9e824a9e
commit
2445a71f0c
63 changed files with 3023 additions and 1408 deletions
|
@ -35,7 +35,7 @@ var current_state: State = State.WALKING_IDLE
|
|||
func _ready() -> void:
|
||||
draggable.on_drag.connect(_on_drag)
|
||||
draggable.on_drop.connect(_on_drop)
|
||||
current_state = State.FALLING
|
||||
_change_state(State.FALLING)
|
||||
|
||||
|
||||
func on_place_back() -> void:
|
||||
|
@ -50,12 +50,6 @@ func _process(delta: float) -> void:
|
|||
State.DRAGGING:
|
||||
_thinking_path = false
|
||||
_actual_position = position
|
||||
State.WALKING_IDLE:
|
||||
if not _thinking_path:
|
||||
_think_path()
|
||||
State.FLYING_IDLE:
|
||||
if not _thinking_path:
|
||||
_think_path()
|
||||
State.WALKING:
|
||||
_move_to_target(delta)
|
||||
State.FALLING:
|
||||
|
@ -66,12 +60,30 @@ func _process(delta: float) -> void:
|
|||
properties.position = position
|
||||
|
||||
|
||||
func _change_state(new_state):
|
||||
match new_state:
|
||||
State.DRAGGING:
|
||||
dragon.play_idle()
|
||||
State.WALKING_IDLE:
|
||||
dragon.play_idle()
|
||||
_think_path()
|
||||
State.FLYING_IDLE:
|
||||
_think_path()
|
||||
State.WALKING:
|
||||
dragon.play_walk()
|
||||
State.FALLING:
|
||||
dragon.play_idle()
|
||||
State.FLYING:
|
||||
dragon.play_fly()
|
||||
|
||||
current_state = new_state
|
||||
|
||||
|
||||
func dress():
|
||||
dragon.dress(properties)
|
||||
|
||||
|
||||
func _think_path():
|
||||
_thinking_path = true
|
||||
await get_tree().create_timer(rng.randf_range(2, 7)).timeout
|
||||
dragon_speed = rng.randf_range(dragon_speed_min, dragon_speed_max)
|
||||
|
||||
|
@ -86,7 +98,7 @@ func _think_path():
|
|||
var decision: int = rng.randi_range(0, 99)
|
||||
if decision < 30:
|
||||
_fall_speed = 0
|
||||
current_state = State.FALLING
|
||||
_change_state(State.FALLING)
|
||||
else:
|
||||
_pick_random_screen_fly_position()
|
||||
|
||||
|
@ -98,7 +110,7 @@ func _fall(delta: float) -> void:
|
|||
|
||||
var ground_height: int = _ground_height()
|
||||
if position.y >= ground_height:
|
||||
current_state = State.WALKING_IDLE
|
||||
_change_state(State.WALKING_IDLE)
|
||||
position.y = ground_height
|
||||
_actual_position.y = ground_height
|
||||
|
||||
|
@ -117,24 +129,24 @@ func _move_to_target(delta: float):
|
|||
|
||||
match current_state:
|
||||
State.FLYING:
|
||||
current_state = State.FLYING_IDLE
|
||||
_change_state(State.FLYING_IDLE)
|
||||
State.WALKING:
|
||||
current_state = State.WALKING_IDLE
|
||||
_change_state(State.WALKING_IDLE)
|
||||
|
||||
|
||||
func _on_drag():
|
||||
current_state = State.DRAGGING
|
||||
_change_state(State.DRAGGING)
|
||||
|
||||
|
||||
func _on_drop():
|
||||
var ground_height: int = _ground_height()
|
||||
if position.y >= ground_height:
|
||||
current_state = State.WALKING_IDLE
|
||||
_change_state(State.WALKING_IDLE)
|
||||
position.y = ground_height
|
||||
_actual_position.y = ground_height
|
||||
else:
|
||||
_fall_speed = 0
|
||||
current_state = State.FALLING
|
||||
_change_state(State.FALLING)
|
||||
|
||||
|
||||
func _get_display_limits() -> Rect2i:
|
||||
|
@ -151,7 +163,7 @@ func _ground_height() -> int:
|
|||
|
||||
|
||||
func _pick_random_screen_fly_position() -> void:
|
||||
current_state = State.FLYING
|
||||
_change_state(State.FLYING)
|
||||
_thinking_path = false
|
||||
|
||||
var limits: Rect2i = _get_display_limits()
|
||||
|
@ -165,7 +177,7 @@ func _pick_random_screen_fly_position() -> void:
|
|||
|
||||
|
||||
func _pick_random_screen_walk_position() -> void:
|
||||
current_state = State.WALKING
|
||||
_change_state(State.WALKING)
|
||||
_thinking_path = false
|
||||
|
||||
var limits: Rect2i = _get_display_limits()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue