|
|
|
@ -13,8 +13,8 @@ class Trans:
|
|
|
|
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 status_change_cache = []
|
|
|
|
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
|
|
|
|
@ -61,7 +61,7 @@ func trans_register() -> void:
|
|
|
|
run("lhit", "idle_loop")
|
|
|
|
run("lhit", "idle_loop")
|
|
|
|
|
|
|
|
|
|
|
|
#地面眩晕受击
|
|
|
|
#地面眩晕受击
|
|
|
|
trigger_with_condition("any", "stunhit", "trigger_stun_hit", "is_on_floor", "=", true)
|
|
|
|
trigger("any", "stunhit", "trigger_stun_hit")
|
|
|
|
run("stunhit", "ground_stun1_loop")
|
|
|
|
run("stunhit", "ground_stun1_loop")
|
|
|
|
|
|
|
|
|
|
|
|
#空中受击
|
|
|
|
#空中受击
|
|
|
|
@ -89,7 +89,17 @@ func trans_register() -> void:
|
|
|
|
trigger("any", "rebound", "trigger_rebound")
|
|
|
|
trigger("any", "rebound", "trigger_rebound")
|
|
|
|
run("rebound", "airhit2_loop")
|
|
|
|
run("rebound", "airhit2_loop")
|
|
|
|
|
|
|
|
|
|
|
|
func _on_character_status_changed(status_name, value) -> void:
|
|
|
|
func _process(_delta) -> void:
|
|
|
|
|
|
|
|
if status.is_be_throw: return
|
|
|
|
|
|
|
|
if status.is_pause: return
|
|
|
|
|
|
|
|
for status_change_cache_single in status_change_cache:
|
|
|
|
|
|
|
|
update_trans(status_change_cache_single)
|
|
|
|
|
|
|
|
status_change_cache.clear()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_character_status_changed(status_name, _value) -> void:
|
|
|
|
|
|
|
|
if status_name in trans_dict:
|
|
|
|
|
|
|
|
status_change_cache.append(status_name)
|
|
|
|
|
|
|
|
return
|
|
|
|
if status_name == "is_right":
|
|
|
|
if status_name == "is_right":
|
|
|
|
scale.x = 1 if status.is_right else -1
|
|
|
|
scale.x = 1 if status.is_right else -1
|
|
|
|
if status.is_be_throw: return
|
|
|
|
if status.is_be_throw: return
|
|
|
|
@ -100,15 +110,13 @@ func _on_character_status_changed(status_name, value) -> void:
|
|
|
|
if status_name == "basic_offset" or status_name == "shake_offset":
|
|
|
|
if status_name == "basic_offset" or status_name == "shake_offset":
|
|
|
|
position = status.basic_offset + status.shake_offset
|
|
|
|
position = status.basic_offset + status.shake_offset
|
|
|
|
# global_position = Util.snap_vector3(global_position)
|
|
|
|
# global_position = Util.snap_vector3(global_position)
|
|
|
|
if status.is_pause:
|
|
|
|
if status.is_pause: return
|
|
|
|
return
|
|
|
|
if status_name in ["deformation_rate", "flash_white_rate"]:
|
|
|
|
if status_name in ["deformation_rate", "is_floating", "flash_white_rate", "deformation_rate"]:
|
|
|
|
|
|
|
|
update_material()
|
|
|
|
update_material()
|
|
|
|
update_trans(status_name, value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_animation_finished():
|
|
|
|
func _on_animation_finished():
|
|
|
|
update_trans("animation_end", null)
|
|
|
|
update_trans("animation_end")
|
|
|
|
|
|
|
|
|
|
|
|
func _on_animation_changed() -> void:
|
|
|
|
func _on_animation_changed() -> void:
|
|
|
|
update_material_tex()
|
|
|
|
update_material_tex()
|
|
|
|
@ -133,10 +141,6 @@ func trigger(from: StringName, to: StringName, trigger_name: StringName):
|
|
|
|
_add_trans(from, to, trigger_name, "", "", "", trigger_name)
|
|
|
|
_add_trans(from, to, trigger_name, "", "", "", trigger_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func trigger_with_condition(from: StringName, to: StringName, trigger_name: StringName, condition, compareType, conditionValue):
|
|
|
|
|
|
|
|
_add_trans(from, to, trigger_name, condition, compareType, conditionValue, trigger_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _add_trans(from: StringName, to: StringName, key: String, 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
|
|
|
|
@ -153,20 +157,19 @@ func _add_trans(from: StringName, to: StringName, key: String, condition, compar
|
|
|
|
trans_dict[key][from].append(new_trans)
|
|
|
|
trans_dict[key][from].append(new_trans)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func update_trans(key: String, value) -> void:
|
|
|
|
func update_trans(key: String) -> void:
|
|
|
|
if not key in trans_dict:
|
|
|
|
if not key in trans_dict:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
if current_animation in trans_dict[key]:
|
|
|
|
if status.current_animation in trans_dict[key]:
|
|
|
|
update_trans_single(trans_dict[key][current_animation], value)
|
|
|
|
update_trans_single(trans_dict[key][status.current_animation])
|
|
|
|
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"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func update_trans_single(trans_list, value) -> void:
|
|
|
|
func update_trans_single(trans_list) -> void:
|
|
|
|
for trans_single in trans_list:
|
|
|
|
for trans_single in trans_list:
|
|
|
|
if trans_single.condition != "":
|
|
|
|
if trans_single.condition != "":
|
|
|
|
if value == null:
|
|
|
|
var value = status.get_status(trans_single.condition)
|
|
|
|
value = status.get_status(trans_single.condition)
|
|
|
|
|
|
|
|
match trans_single.compareType:
|
|
|
|
match trans_single.compareType:
|
|
|
|
">": if value <= trans_single.conditionValue: continue
|
|
|
|
">": if value <= trans_single.conditionValue: continue
|
|
|
|
"<": if value >= trans_single.conditionValue: continue
|
|
|
|
"<": if value >= trans_single.conditionValue: continue
|
|
|
|
@ -225,11 +228,11 @@ func _update_material_tex():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func play_animation(animation_name: String) -> void:
|
|
|
|
func play_animation(animation_name: String) -> void:
|
|
|
|
current_animation = animation_name
|
|
|
|
status.set_status("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):
|
|
|
|
update_trans("animation_end", null)
|
|
|
|
update_trans("animation_end")
|
|
|
|
return
|
|
|
|
return
|
|
|
|
if animation_name == animation:
|
|
|
|
if animation_name == animation:
|
|
|
|
frame = 0
|
|
|
|
frame = 0
|
|
|
|
|