|
|
|
@ -12,8 +12,9 @@ class Trans:
|
|
|
|
var to: StringName
|
|
|
|
var to: StringName
|
|
|
|
var trigger_name: StringName
|
|
|
|
var trigger_name: StringName
|
|
|
|
|
|
|
|
|
|
|
|
var trans_dict: Dictionary = {} # {condition/trigger:{from:Trans}}
|
|
|
|
var trans_dict: Dictionary = {} # {condition/trigger:{from:Trans[]}}
|
|
|
|
var move_sprite_frames: SpriteFrames
|
|
|
|
var move_sprite_frames: SpriteFrames
|
|
|
|
|
|
|
|
var current_animation: String
|
|
|
|
|
|
|
|
|
|
|
|
func init(default: SpriteFrames):
|
|
|
|
func init(default: SpriteFrames):
|
|
|
|
sprite_frames = default
|
|
|
|
sprite_frames = default
|
|
|
|
@ -59,26 +60,30 @@ func trans_register() -> void:
|
|
|
|
run("mhit", "idle_loop")
|
|
|
|
run("mhit", "idle_loop")
|
|
|
|
run("lhit", "idle_loop")
|
|
|
|
run("lhit", "idle_loop")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#地面眩晕受击
|
|
|
|
|
|
|
|
trigger_with_condition("any", "stunhit", "trigger_stun_hit", "is_on_floor", "=", true)
|
|
|
|
|
|
|
|
run("stunhit", "ground_stun1_loop")
|
|
|
|
|
|
|
|
|
|
|
|
#空中受击
|
|
|
|
#空中受击
|
|
|
|
trigger("any", "airhit1", "trigger_air_hit_up")
|
|
|
|
trigger("any", "airhit1", "trigger_air_hit_up")
|
|
|
|
trigger("any", "airhit4_loop", "trigger_air_hit_down")
|
|
|
|
trigger("any", "airhit4_loop", "trigger_air_hit_down")
|
|
|
|
run("airhit1", "airhit2_loop")
|
|
|
|
run("airhit1", "airhit2_loop")
|
|
|
|
trans("airhit2_loop", "airhit3", "speed_y", "<=", 0)
|
|
|
|
trans("airhit2_loop", "airhit3", "speed_y", "<=", 0)
|
|
|
|
run("airhit3", "airhit4_loop")
|
|
|
|
run("airhit3", "airhit4_loop")
|
|
|
|
trans("airhit4_loop", "airhit5", "is_on_floor", "=", true)
|
|
|
|
trans("airhit4_loop", "airhit5_select", "is_on_floor", "=", true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#空中受击落地
|
|
|
|
|
|
|
|
run_with_condition("airhit5_select", "airhit5_stun", "is_stun", "=", true)
|
|
|
|
|
|
|
|
run_with_condition("airhit5_select", "airhit5", "is_stun", "=", false)
|
|
|
|
|
|
|
|
run("airhit5_stun", "ground_stun1_loop")
|
|
|
|
run("airhit5", "ground1_loop")
|
|
|
|
run("airhit5", "ground1_loop")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#起身
|
|
|
|
trans("ground1_loop", "ground2", "is_stagger", "=", false)
|
|
|
|
trans("ground1_loop", "ground2", "is_stagger", "=", false)
|
|
|
|
run("ground2", "idle_loop")
|
|
|
|
run("ground2", "idle_loop")
|
|
|
|
|
|
|
|
|
|
|
|
#眩晕受击
|
|
|
|
|
|
|
|
trigger_with_condition("any", "stunhit", "trigger_stun_hit", "is_on_floor", "=", true)
|
|
|
|
|
|
|
|
run("stunhit", "ground_stun1_loop")
|
|
|
|
|
|
|
|
trans("ground_stun1_loop", "ground_stun2", "is_stun", "=", false)
|
|
|
|
trans("ground_stun1_loop", "ground_stun2", "is_stun", "=", false)
|
|
|
|
run("ground_stun2", "idle_loop")
|
|
|
|
run("ground_stun2", "idle_loop")
|
|
|
|
|
|
|
|
|
|
|
|
#空中眩晕受击
|
|
|
|
|
|
|
|
trans("airhit5", "airhit5_stun", "is_stun", "=", true)
|
|
|
|
|
|
|
|
run("airhit5_stun", "ground_stun1_loop")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#落地反弹
|
|
|
|
#落地反弹
|
|
|
|
trigger("any", "rebound", "trigger_rebound")
|
|
|
|
trigger("any", "rebound", "trigger_rebound")
|
|
|
|
@ -112,24 +117,27 @@ func _on_frame_changed() -> void:
|
|
|
|
update_material_tex()
|
|
|
|
update_material_tex()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func run(from: StringName, to: StringName):
|
|
|
|
func run(from: StringName, to: StringName):
|
|
|
|
_add_trans(from, to, "animation_end", "", "", "")
|
|
|
|
_add_trans(from, to, "animation_end", "", "", "", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func run_with_condition(from: StringName, to: StringName, condition, compareType, conditionValue):
|
|
|
|
|
|
|
|
_add_trans(from, to, "animation_end", condition, compareType, conditionValue, "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func trans(from: StringName, to: StringName, condition, compareType, conditionValue):
|
|
|
|
func trans(from: StringName, to: StringName, condition, compareType, conditionValue):
|
|
|
|
_add_trans(from, to, condition, compareType, conditionValue, "")
|
|
|
|
_add_trans(from, to, condition, condition, compareType, conditionValue, "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func trigger(from: StringName, to: StringName, trigger_name: StringName):
|
|
|
|
func trigger(from: StringName, to: StringName, trigger_name: StringName):
|
|
|
|
_add_trans(from, to, "", "", "", trigger_name)
|
|
|
|
_add_trans(from, to, trigger_name, "", "", "", trigger_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func trigger_with_condition(from: StringName, to: StringName, trigger_name: StringName, condition, compareType, conditionValue):
|
|
|
|
func trigger_with_condition(from: StringName, to: StringName, trigger_name: StringName, condition, compareType, conditionValue):
|
|
|
|
_add_trans(from, to, condition, compareType, conditionValue, trigger_name)
|
|
|
|
_add_trans(from, to, trigger_name, condition, compareType, conditionValue, trigger_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _add_trans(from: StringName, to: StringName, condition, compareType, conditionValue, trigger_name: StringName):
|
|
|
|
func _add_trans(from: StringName, to: StringName, key: String, condition, compareType, conditionValue, trigger_name: StringName):
|
|
|
|
var new_trans = Trans.new()
|
|
|
|
var new_trans = Trans.new()
|
|
|
|
new_trans.condition = condition
|
|
|
|
new_trans.condition = condition
|
|
|
|
new_trans.compareType = compareType
|
|
|
|
new_trans.compareType = compareType
|
|
|
|
@ -138,38 +146,39 @@ func _add_trans(from: StringName, to: StringName, condition, compareType, condit
|
|
|
|
new_trans.to = to
|
|
|
|
new_trans.to = to
|
|
|
|
new_trans.trigger_name = trigger_name
|
|
|
|
new_trans.trigger_name = trigger_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not key in trans_dict:
|
|
|
|
if trigger_name != "":
|
|
|
|
trans_dict[key] = {}
|
|
|
|
if not trigger_name in trans_dict:
|
|
|
|
if not from in trans_dict[key]:
|
|
|
|
trans_dict[trigger_name] = {}
|
|
|
|
trans_dict[key][from] = []
|
|
|
|
trans_dict[trigger_name][from] = new_trans
|
|
|
|
trans_dict[key][from].append(new_trans)
|
|
|
|
else:
|
|
|
|
|
|
|
|
if not condition in trans_dict:
|
|
|
|
|
|
|
|
trans_dict[condition] = {}
|
|
|
|
|
|
|
|
trans_dict[condition][from] = new_trans
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func update_trans(key: String, value) -> void:
|
|
|
|
func update_trans(key: String, value) -> void:
|
|
|
|
if not key in trans_dict:
|
|
|
|
if not key in trans_dict:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
if animation in trans_dict[key]:
|
|
|
|
if current_animation in trans_dict[key]:
|
|
|
|
update_trans_single(trans_dict[key][animation], value)
|
|
|
|
update_trans_single(trans_dict[key][current_animation], value)
|
|
|
|
if "any" in trans_dict[key]:
|
|
|
|
if "any" in trans_dict[key]:
|
|
|
|
update_trans_single(trans_dict[key]["any"], value)
|
|
|
|
update_trans_single(trans_dict[key]["any"], value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func update_trans_single(trans_single: Trans, value) -> void:
|
|
|
|
func update_trans_single(trans_list, value) -> void:
|
|
|
|
if trans_single.condition != "":
|
|
|
|
for trans_single in trans_list:
|
|
|
|
match trans_single.compareType:
|
|
|
|
if trans_single.condition != "":
|
|
|
|
">": if value <= trans_single.conditionValue: return
|
|
|
|
if value == null:
|
|
|
|
"<": if value >= trans_single.conditionValue: return
|
|
|
|
value = status.get_status(trans_single.condition)
|
|
|
|
">=": if value < trans_single.conditionValue: return
|
|
|
|
match trans_single.compareType:
|
|
|
|
"<=": if value > trans_single.conditionValue: return
|
|
|
|
">": if value <= trans_single.conditionValue: continue
|
|
|
|
"=": if value != trans_single.conditionValue: return
|
|
|
|
"<": if value >= trans_single.conditionValue: continue
|
|
|
|
if trans_single.trigger_name != "":
|
|
|
|
">=": if value < trans_single.conditionValue: continue
|
|
|
|
if status.get(trans_single.trigger_name):
|
|
|
|
"<=": if value > trans_single.conditionValue: continue
|
|
|
|
status.set(trans_single.trigger_name, false)
|
|
|
|
"=": if value != trans_single.conditionValue: continue
|
|
|
|
play_animation(trans_single.to)
|
|
|
|
if trans_single.trigger_name != "":
|
|
|
|
|
|
|
|
if status.get_status(trans_single.trigger_name):
|
|
|
|
|
|
|
|
status.set_status(trans_single.trigger_name, false)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
play_animation(trans_single.to)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func update_view():
|
|
|
|
func update_view():
|
|
|
|
@ -216,10 +225,11 @@ func _update_material_tex():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func play_animation(animation_name: String) -> void:
|
|
|
|
func play_animation(animation_name: String) -> void:
|
|
|
|
|
|
|
|
current_animation = animation_name
|
|
|
|
if not sprite_frames:
|
|
|
|
if not sprite_frames:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
if not sprite_frames.has_animation(animation_name):
|
|
|
|
if not sprite_frames.has_animation(animation_name):
|
|
|
|
print("无效动画:", animation_name)
|
|
|
|
update_trans("animation_end", null)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
if animation_name == animation:
|
|
|
|
if animation_name == animation:
|
|
|
|
frame = 0
|
|
|
|
frame = 0
|
|
|
|
|