fix 动画trigger bug、优化极端情况下pt掉落

master
chendian 8 months ago
parent 973ac74455
commit 047f4eb9b3

@ -4,7 +4,7 @@
[ext_resource type="Script" uid="uid://cms637d0jt6sk" path="res://script/character/hitbox.gd" id="2_6xf87"] [ext_resource type="Script" uid="uid://cms637d0jt6sk" path="res://script/character/hitbox.gd" id="2_6xf87"]
[ext_resource type="Script" uid="uid://bfi4gneebe3oq" path="res://script/character/status.gd" id="2_txdip"] [ext_resource type="Script" uid="uid://bfi4gneebe3oq" path="res://script/character/status.gd" id="2_txdip"]
[ext_resource type="Script" uid="uid://cnaqs44siwa45" path="res://script/character/move.gd" id="4_66r53"] [ext_resource type="Script" uid="uid://cnaqs44siwa45" path="res://script/character/move.gd" id="4_66r53"]
[ext_resource type="SpriteFrames" uid="uid://ce83cuqwgwwi4" path="res://resource/animation/character/hero01_long_attack.aseprite" id="4_sox5o"] [ext_resource type="SpriteFrames" uid="uid://cajgs8smbkjan" path="res://resource/animation/character/hero01_fist_skill01.aseprite" id="4_sox5o"]
[ext_resource type="Script" uid="uid://c247mf44qb3uf" path="res://script/character/view.gd" id="4_vijjv"] [ext_resource type="Script" uid="uid://c247mf44qb3uf" path="res://script/character/view.gd" id="4_vijjv"]
[ext_resource type="Script" uid="uid://c24is3uqqcmcn" path="res://script/character/skill.gd" id="6_h4xqy"] [ext_resource type="Script" uid="uid://c24is3uqqcmcn" path="res://script/character/skill.gd" id="6_h4xqy"]
[ext_resource type="AnimationLibrary" uid="uid://croik07a1qko5" path="res://resource/skill_animation_library/animation_library.tres" id="6_pakq5"] [ext_resource type="AnimationLibrary" uid="uid://croik07a1qko5" path="res://resource/skill_animation_library/animation_library.tres" id="6_pakq5"]
@ -143,7 +143,7 @@ gi_mode = 0
pixel_size = 0.02 pixel_size = 0.02
alpha_cut = 1 alpha_cut = 1
sprite_frames = ExtResource("4_sox5o") sprite_frames = ExtResource("4_sox5o")
animation = &"long_attack02" animation = &"fist_skill01_add"
script = ExtResource("4_vijjv") script = ExtResource("4_vijjv")
[node name="Move" type="Node3D" parent="."] [node name="Move" type="Node3D" parent="."]
@ -193,7 +193,7 @@ script = ExtResource("14_gua01")
[node name="Throw" type="AnimatedSprite3D" parent="."] [node name="Throw" type="AnimatedSprite3D" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
transform = Transform3D(-1, 0, 0, 0, -1, 1.50996e-07, 0, -1.50996e-07, -1, 0.75, 0.4, 0) transform = Transform3D(-1, 0, 0, 0, 1, -1.50996e-07, 0, 1.50996e-07, 1, 0.75, 0.4, 0)
visible = false visible = false
pixel_size = 0.02 pixel_size = 0.02
sprite_frames = ExtResource("15_70jx1") sprite_frames = ExtResource("15_70jx1")

@ -1,6 +1,6 @@
[gd_scene load_steps=8 format=3 uid="uid://dy0u26ba7dle"] [gd_scene load_steps=8 format=3 uid="uid://dy0u26ba7dle"]
[ext_resource type="Script" path="res://script/ui/hud/headbar.gd" id="1_k0rtd"] [ext_resource type="Script" uid="uid://d01gac1vyca5t" path="res://script/ui/hud/headbar.gd" id="1_k0rtd"]
[ext_resource type="Texture2D" uid="uid://cwhu1ec03t3c8" path="res://resource/ui/hud/headbar_hp_empty.png" id="2_g5t31"] [ext_resource type="Texture2D" uid="uid://cwhu1ec03t3c8" path="res://resource/ui/hud/headbar_hp_empty.png" id="2_g5t31"]
[ext_resource type="Texture2D" uid="uid://b4ly1exl0owck" path="res://resource/ui/hud/headbar_hp.png" id="3_vh1p5"] [ext_resource type="Texture2D" uid="uid://b4ly1exl0owck" path="res://resource/ui/hud/headbar_hp.png" id="3_vh1p5"]
[ext_resource type="Texture2D" uid="uid://c5xgdirnx5gq8" path="res://resource/ui/hud/headbar_shield.png" id="4_5g4h6"] [ext_resource type="Texture2D" uid="uid://c5xgdirnx5gq8" path="res://resource/ui/hud/headbar_shield.png" id="4_5g4h6"]
@ -185,3 +185,13 @@ offset_right = 80.0
offset_bottom = -6.0 offset_bottom = -6.0
theme_override_font_sizes/font_size = 10 theme_override_font_sizes/font_size = 10
text = "123,123" text = "123,123"
[node name="AnimationLabel" type="Label" parent="DebugInfo"]
unique_name_in_owner = true
layout_mode = 0
offset_left = 24.0
offset_top = -32.0
offset_right = 80.0
offset_bottom = -18.0
theme_override_font_sizes/font_size = 10
text = "123,123"

@ -115,6 +115,8 @@ var ai_bullet_order: Array[BulletOrder] = [] #ai子弹指令
var ai_alert_max: float # 警戒值最大值 var ai_alert_max: float # 警戒值最大值
var ai_alert: float # 警戒值 var ai_alert: float # 警戒值
var ai_is_alert: bool # 是否已激活 var ai_is_alert: bool # 是否已激活
#动画状态
var current_animation: String
#动画触发器 #动画触发器
var trigger_jump: bool # 跳跃 var trigger_jump: bool # 跳跃
var trigger_hit: bool # 受击-地面-轻 var trigger_hit: bool # 受击-地面-轻

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

@ -2,6 +2,7 @@ extends Node3D
class_name ItemManager class_name ItemManager
var pt_count: int var pt_count: int
var pt_cache: int
func _ready(): func _ready():
Global.item_mgr = self Global.item_mgr = self
@ -13,6 +14,8 @@ func on_level_loading_start():
func create_pt(type: Enum.EPtType, value: int, pos: Vector3): func create_pt(type: Enum.EPtType, value: int, pos: Vector3):
value += pt_cache
pt_cache = 0
if pt_count < 20: if pt_count < 20:
value = randi_range(int(0.5 * value), int(1.5 * value)) value = randi_range(int(0.5 * value), int(1.5 * value))
var pt_slice: Array[int] = [100, 50, 20, 10, 5, 2, 1] var pt_slice: Array[int] = [100, 50, 20, 10, 5, 2, 1]
@ -23,8 +26,10 @@ func create_pt(type: Enum.EPtType, value: int, pos: Vector3):
value -= i value -= i
_create_pt(type, i, pos) _create_pt(type, i, pos)
break break
else: elif pt_count < 50:
_create_pt(type, value, pos) _create_pt(type, value, pos)
else:
pt_cache = value
func destroy_pt(pt: PT): func destroy_pt(pt: PT):

@ -13,6 +13,8 @@ class_name Headbar
@onready var mp_sub_bar: TextureProgressBar = (%MpSubBar as TextureProgressBar) @onready var mp_sub_bar: TextureProgressBar = (%MpSubBar as TextureProgressBar)
@onready var pos_lable: Label = (%PosLabel as Label) @onready var pos_lable: Label = (%PosLabel as Label)
@onready var role_lable: Label = (%RoleLabel as Label) @onready var role_lable: Label = (%RoleLabel as Label)
@onready var animation_label: Label = (%AnimationLabel as Label)
var is_show_debug_info: bool var is_show_debug_info: bool
@ -112,6 +114,11 @@ func on_ai_role_changed(value):
role_lable.text = str(value) role_lable.text = str(value)
func on_current_animation_changed(value):
if is_show_debug_info:
animation_label.text = str(value)
func on_hit_text(value: String): func on_hit_text(value: String):
var hit_text: HitText = get_hit_text_object() var hit_text: HitText = get_hit_text_object()
hit_text.show_hit_text(value) hit_text.show_hit_text(value)

Loading…
Cancel
Save