master
chendian 8 months ago
parent 88a35fd5c2
commit 973ac74455

@ -1,6 +1,6 @@
[gd_resource type="Resource" script_class="StunCfg" load_steps=2 format=3 uid="uid://cac6mk6g078vn"] [gd_resource type="Resource" script_class="StunCfg" load_steps=2 format=3 uid="uid://cac6mk6g078vn"]
[ext_resource type="Script" path="res://script/config/stun_cfg.gd" id="1_2kfjh"] [ext_resource type="Script" uid="uid://cgkbmwusqtrme" path="res://script/config/stun_cfg.gd" id="1_2kfjh"]
[resource] [resource]
script = ExtResource("1_2kfjh") script = ExtResource("1_2kfjh")

@ -492,7 +492,7 @@ func on_skill_trigger(skill_name: String, trigger_name: String) -> void:
#====skill_trigger==== #====skill_trigger====
func on_hero01_long_stab01_cast(): func on_hero01_long_stab01_cast():
if status.skill_repeat_count >= 5: if status.skill_repeat_count >= 4:
skill.cast_skill_by_name("hero01_long_stab02", status.move_dir) skill.cast_skill_by_name("hero01_long_stab02", status.move_dir)

@ -28,7 +28,7 @@ func _process(delta):
return return
tick(delta_cache) tick(delta_cache)
buff_tick_frame = 0 buff_tick_frame = 0
buff_tick_frame = 0 delta_cache = 0
func tick(delta) -> void: func tick(delta) -> void:
for buff_name in buff_map: for buff_name in buff_map:
@ -203,16 +203,20 @@ func on_end_weapon_index_change(_rate) -> void:
#表现 #表现
func on_start_freeze(_rate) -> void: status.set_status("is_pause", true) func on_start_freeze(_rate) -> void:
status.set_status("is_pause", true)
func on_end_freeze(_rate) -> void: status.set_status("is_pause", false) func on_end_freeze(_rate) -> void:
status.set_status("is_pause", false)
func on_second_pause(_rate) -> void: status.set_status("is_pause", true) func on_second_pause(_rate) -> void:
status.set_status("is_pause", true)
func on_end_pause(_rate) -> void: status.set_status("is_pause", false) func on_end_pause(_rate) -> void:
status.set_status("is_pause", false)
func on_start_flash_white(_rate) -> void: status.set_status("flash_white_rate", 1) func on_start_flash_white(_rate) -> void: status.set_status("flash_white_rate", 1)

@ -131,6 +131,7 @@ func set_pos(pos_new: Vector3):
func emit_pos_changed(): func emit_pos_changed():
SignalManager.character_pos_changed.emit(id(), pos()) SignalManager.character_pos_changed.emit(id(), pos())
SignalManager.character_ui_pos_changed.emit(id(), ui_pos())
func move_to(dir: Vector2): func move_to(dir: Vector2):
set_status("move_dir", dir.normalized()) set_status("move_dir", dir.normalized())

@ -143,7 +143,7 @@ func cast_skill(cfg: SkillCfg, cast_dir: Vector2, action_key: String = "") -> vo
#技能重复次数 #技能重复次数
if status.skill_cfg and status.skill_cfg == cfg: if status.skill_cfg and status.skill_cfg == cfg:
status.set_status("skill_repeat_count", 1) status.set_status("skill_repeat_count", status.skill_repeat_count + 1)
else: else:
status.set_status("skill_repeat_count", 0) status.set_status("skill_repeat_count", 0)

@ -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

Loading…
Cancel
Save