forked from AlyssonDaPaz/Mega-Man-X8-16-bit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWalk.gd
66 lines (51 loc) · 1.78 KB
/
Walk.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
extends Movement
class_name Walk
var minimum_time := 0.02
var starting_from_stop := false
export var shot_pos_adjust := Vector2 (6,-2)
func get_shot_adust_position() -> Vector2:
return shot_pos_adjust
func _ready() -> void:
# warning-ignore:return_value_discarded
character.get_node("animatedSprite").connect("animation_finished", self, "_on_animatedSprite_animation_finished")
func _StartCondition() -> bool:
if not character.is_on_floor():
return false
if character.is_colliding_with_wall() != 0:
if character.is_colliding_with_wall_except_feet() == get_pressed_direction():
return false
if get_pressed_direction() == 0:
return false
return true
func _Setup() -> void:
Event.emit_signal("walk", get_pressed_direction())
starting_from_stop = character.get_last_used_ability() == "Idle"
deactivate_low_jumpcasts()
func _Interrupt() -> void:
character.set_vertical_speed(0)
func _Update(_delta: float) -> void:
if timer < 0.08 and starting_from_stop:
set_movement_and_direction(horizontal_velocity/4)
else:
set_movement_and_direction(horizontal_velocity)
update_bonus_horizontal_only_conveyor()
func _EndCondition() -> bool:
if not character.is_on_floor():
return true
if character.is_colliding_with_wall() != 0:
if character.is_colliding_with_wall_except_feet() == get_pressed_direction():
return true
if timer > minimum_time and get_pressed_direction() == 0:
return true
return false
func _on_animatedSprite_animation_finished() -> void:
if executing:
if (character.get_animation() == "walk_start"):
character.play_animation("walk")
func play_animation_on_initialize():
if character.get_last_used_ability() == "Idle":
character.play_animation("walk_start")
else:
character.play_animation(animation)
func should_execute_on_hold() -> bool:
return true