added sideprofile animations
This commit is contained in:
@@ -8,58 +8,8 @@ class_name Drone
|
||||
@export var dodge_duration := 0.18
|
||||
var dodge_duration_timer : Timer
|
||||
|
||||
#region animation dictionaries
|
||||
@export var idle_anim_front : Dictionary
|
||||
@export var idle_anim_back : Dictionary
|
||||
@export var idle_anim_left : Dictionary
|
||||
@export var idle_anim_right : Dictionary
|
||||
|
||||
@export var walking_anim_front : Dictionary
|
||||
@export var walking_anim_back : Dictionary
|
||||
@export var walking_anim_left : Dictionary
|
||||
@export var walking_anim_right : Dictionary
|
||||
|
||||
@export var dashing_anim_front : Dictionary
|
||||
@export var dashing_anim_back : Dictionary
|
||||
@export var dashing_anim_left : Dictionary
|
||||
@export var dashing_anim_right : Dictionary
|
||||
|
||||
@export var interacting_anim_front : Dictionary
|
||||
@export var interacting_anim_back : Dictionary
|
||||
@export var interacting_anim_left : Dictionary
|
||||
@export var interacting_anim_right : Dictionary
|
||||
|
||||
var anim_dictionary_idle : Dictionary
|
||||
var anim_dictionary_walking : Dictionary
|
||||
var anim_dictionary_dashing : Dictionary
|
||||
var anim_dictionary_interacting : Dictionary
|
||||
#endregion
|
||||
|
||||
func _ready() -> void:
|
||||
add_on_slots = 1
|
||||
#region init animation dictionaries
|
||||
anim_dictionary_idle.set(MachineGlobals.look_direction.UP, idle_anim_back)
|
||||
anim_dictionary_idle.set(MachineGlobals.look_direction.DOWN, idle_anim_front)
|
||||
anim_dictionary_idle.set(MachineGlobals.look_direction.LEFT, idle_anim_left)
|
||||
anim_dictionary_idle.set(MachineGlobals.look_direction.RIGHT, idle_anim_right)
|
||||
|
||||
anim_dictionary_walking.set(MachineGlobals.look_direction.UP, walking_anim_back)
|
||||
anim_dictionary_walking.set(MachineGlobals.look_direction.DOWN, walking_anim_front)
|
||||
anim_dictionary_walking.set(MachineGlobals.look_direction.LEFT, walking_anim_left)
|
||||
anim_dictionary_walking.set(MachineGlobals.look_direction.RIGHT, walking_anim_right)
|
||||
|
||||
|
||||
anim_dictionary_interacting.set(MachineGlobals.look_direction.UP, interacting_anim_back)
|
||||
anim_dictionary_interacting.set(MachineGlobals.look_direction.DOWN, interacting_anim_front)
|
||||
anim_dictionary_interacting.set(MachineGlobals.look_direction.LEFT, interacting_anim_left)
|
||||
anim_dictionary_interacting.set(MachineGlobals.look_direction.RIGHT, interacting_anim_right)
|
||||
|
||||
|
||||
anim_dictionary_dashing.set(MachineGlobals.look_direction.UP, dashing_anim_back)
|
||||
anim_dictionary_dashing.set(MachineGlobals.look_direction.DOWN, dashing_anim_front)
|
||||
anim_dictionary_dashing.set(MachineGlobals.look_direction.LEFT, dashing_anim_left)
|
||||
anim_dictionary_dashing.set(MachineGlobals.look_direction.RIGHT, dashing_anim_right)
|
||||
#endregion
|
||||
for a in self.get_children() :
|
||||
if a.name == "DodgeDurationTimer" :
|
||||
dodge_duration_timer = a
|
||||
@@ -74,14 +24,14 @@ func class_ability() -> float:
|
||||
func listen_to_animation_signals(next_anim_state : MachineGlobals.regular_states) -> void:
|
||||
match next_anim_state :
|
||||
MachineGlobals.regular_states.IDLING :
|
||||
for a : AnimatedSprite2D in _get_body_parts() :
|
||||
a.play(anim_dictionary_idle.get(look_dir).get(a.name))
|
||||
for a : BodyPart in _get_body_parts() :
|
||||
_animate(a,"Idle")
|
||||
MachineGlobals.regular_states.WALKING :
|
||||
for a : AnimatedSprite2D in _get_body_parts() :
|
||||
a.play(anim_dictionary_walking.get(look_dir).get(a.name))
|
||||
_animate(a,"Walking")
|
||||
MachineGlobals.regular_states.DASHING :
|
||||
for a : AnimatedSprite2D in _get_body_parts() :
|
||||
a.play(anim_dictionary_dashing.get(look_dir).get(a.name))
|
||||
_animate(a,"Dashing")
|
||||
MachineGlobals.regular_states.INTERACTING :
|
||||
for a : AnimatedSprite2D in _get_body_parts() :
|
||||
a.play(anim_dictionary_interacting.get(look_dir).get(a.name))
|
||||
_animate(a,"Interact")
|
||||
|
||||
@@ -71,6 +71,11 @@ func _ability_process(delta:float) -> void :
|
||||
func _get_body_parts() -> Array :
|
||||
var clist : Array
|
||||
for a in self.get_children() :
|
||||
if a is AnimatedSprite2D :
|
||||
if a is BodyPart :
|
||||
clist.append(a)
|
||||
return clist
|
||||
|
||||
func _animate(b : BodyPart, animation_type : String) -> void :
|
||||
for anim_name : String in b.sprite_frames.get_animation_names() :
|
||||
if anim_name.contains(animation_type) && anim_name.contains(model_name) && anim_name.contains(str(MachineGlobals.look_direction.keys()[look_dir])) :
|
||||
b.play(anim_name)
|
||||
|
||||
Reference in New Issue
Block a user