From 42e934728d7b5747f90223ae77ac6c4ffaa16580 Mon Sep 17 00:00:00 2001 From: chendian <-> Date: Thu, 5 Oct 2023 03:27:33 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=8A=80=E8=83=BD=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/player_skill/hero01_long_flash.tres | 2 +- resource/skill_animation/her5F00.tmp | 0 resource/skill_animation/her9803.tmp | 0 resource/skill_animation/her9D9B.tmp | 0 .../skill_animation/hero01_long_attack01.tres | 2 +- .../skill_animation/hero01_long_attack02.tres | 12 ++++++++++++ .../skill_animation/hero01_long_attack03.tres | 12 ++++++++++++ .../skill_animation/hero01_long_attack04.tres | 12 ++++++++++++ .../skill_animation/hero01_long_skill01.tres | 12 ++++++++++++ .../animation_library.tres | 4 +++- scene/character/character.tscn | 7 +++---- scene/character/player.tscn | 3 --- script/_global/setting.gd | 3 +++ script/_global/util.gd | 7 ++++++- script/character/move.gd | 11 ++++++++--- script/character/player/combo.gd | 8 +++++--- script/character/player/input.gd | 10 ++++++++-- script/character/skill.gd | 17 ++++++++++++----- script/character/status.gd | 5 ++++- 19 files changed, 102 insertions(+), 25 deletions(-) delete mode 100644 resource/skill_animation/her5F00.tmp delete mode 100644 resource/skill_animation/her9803.tmp delete mode 100644 resource/skill_animation/her9D9B.tmp diff --git a/config/player_skill/hero01_long_flash.tres b/config/player_skill/hero01_long_flash.tres index 05e7343..11535ab 100644 --- a/config/player_skill/hero01_long_flash.tres +++ b/config/player_skill/hero01_long_flash.tres @@ -10,10 +10,10 @@ script = ExtResource("1_yamsl") weapon = ExtResource("4_xft4c") stance_from = 100 stance_to = 0 +break_level = 1 action = "flash" name = "" skill_animation = ExtResource("2_bdxlh") -break_level = 1 has_animation = true sprite_frams = ExtResource("2_uof6p") animation_name = "long_flash" diff --git a/resource/skill_animation/her5F00.tmp b/resource/skill_animation/her5F00.tmp deleted file mode 100644 index e69de29..0000000 diff --git a/resource/skill_animation/her9803.tmp b/resource/skill_animation/her9803.tmp deleted file mode 100644 index e69de29..0000000 diff --git a/resource/skill_animation/her9D9B.tmp b/resource/skill_animation/her9D9B.tmp deleted file mode 100644 index e69de29..0000000 diff --git a/resource/skill_animation/hero01_long_attack01.tres b/resource/skill_animation/hero01_long_attack01.tres index eab8b70..4f729be 100644 --- a/resource/skill_animation/hero01_long_attack01.tres +++ b/resource/skill_animation/hero01_long_attack01.tres @@ -48,7 +48,7 @@ tracks/3/path = NodePath("Status:break_level") tracks/3/interp = 1 tracks/3/loop_wrap = true tracks/3/keys = { -"times": PackedFloat32Array(0, 0.3, 0.7), +"times": PackedFloat32Array(0, 0.3, 0.5), "transitions": PackedFloat32Array(1, 1, 1), "update": 1, "values": [0, 3, 4] diff --git a/resource/skill_animation/hero01_long_attack02.tres b/resource/skill_animation/hero01_long_attack02.tres index c89821b..3bc3e0f 100644 --- a/resource/skill_animation/hero01_long_attack02.tres +++ b/resource/skill_animation/hero01_long_attack02.tres @@ -41,3 +41,15 @@ tracks/2/keys = { "update": 0, "values": [0, 1, 2, 3, 4, 5, 6, 7, 8] } +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Status:break_level") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.3, 0.5), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 1, +"values": [0, 3, 4] +} diff --git a/resource/skill_animation/hero01_long_attack03.tres b/resource/skill_animation/hero01_long_attack03.tres index 6ee5969..98bf232 100644 --- a/resource/skill_animation/hero01_long_attack03.tres +++ b/resource/skill_animation/hero01_long_attack03.tres @@ -41,3 +41,15 @@ tracks/2/keys = { "update": 0, "values": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] } +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Status:break_level") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.7, 0.9), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 1, +"values": [0, 3, 4] +} diff --git a/resource/skill_animation/hero01_long_attack04.tres b/resource/skill_animation/hero01_long_attack04.tres index cec1554..19f52e9 100644 --- a/resource/skill_animation/hero01_long_attack04.tres +++ b/resource/skill_animation/hero01_long_attack04.tres @@ -41,3 +41,15 @@ tracks/2/keys = { "update": 0, "values": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] } +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Status:break_level") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.6, 1), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 1, +"values": [0, 3, 4] +} diff --git a/resource/skill_animation/hero01_long_skill01.tres b/resource/skill_animation/hero01_long_skill01.tres index e001eb0..b193d4b 100644 --- a/resource/skill_animation/hero01_long_skill01.tres +++ b/resource/skill_animation/hero01_long_skill01.tres @@ -40,3 +40,15 @@ tracks/2/keys = { "update": 0, "values": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] } +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Status:break_level") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.3, 0.5), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 1, +"values": [0, 3, 4] +} diff --git a/resource/skill_animation_library/animation_library.tres b/resource/skill_animation_library/animation_library.tres index b9aa528..bab1bf4 100644 --- a/resource/skill_animation_library/animation_library.tres +++ b/resource/skill_animation_library/animation_library.tres @@ -1,9 +1,10 @@ -[gd_resource type="AnimationLibrary" load_steps=6 format=3 uid="uid://croik07a1qko5"] +[gd_resource type="AnimationLibrary" load_steps=7 format=3 uid="uid://croik07a1qko5"] [ext_resource type="Animation" uid="uid://daopmieibx3b7" path="res://resource/skill_animation/hero01_long_attack01.tres" id="1_nwjtl"] [ext_resource type="Animation" uid="uid://bf6jaraltouun" path="res://resource/skill_animation/hero01_long_attack02.tres" id="2_klfcs"] [ext_resource type="Animation" uid="uid://c8yueqe7rjn60" path="res://resource/skill_animation/hero01_long_attack03.tres" id="3_g8q4d"] [ext_resource type="Animation" uid="uid://dk1o3gqhjmuvh" path="res://resource/skill_animation/hero01_long_attack04.tres" id="4_36e6x"] +[ext_resource type="Animation" uid="uid://cwm116apu63n1" path="res://resource/skill_animation/hero01_long_flash.tres" id="5_fumom"] [ext_resource type="Animation" uid="uid://bjnkrte7660pt" path="res://resource/skill_animation/hero01_long_skill01.tres" id="5_kt0qw"] [resource] @@ -12,5 +13,6 @@ _data = { "hero01_long_attack02": ExtResource("2_klfcs"), "hero01_long_attack03": ExtResource("3_g8q4d"), "hero01_long_attack04": ExtResource("4_36e6x"), +"hero01_long_flash": ExtResource("5_fumom"), "hero01_long_skill01": ExtResource("5_kt0qw") } diff --git a/scene/character/character.tscn b/scene/character/character.tscn index b606144..616923c 100644 --- a/scene/character/character.tscn +++ b/scene/character/character.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://script/character/character.gd" id="1_tonbs"] [ext_resource type="Script" path="res://script/character/status.gd" id="2_txdip"] -[ext_resource type="SpriteFrames" uid="uid://7swf8owxd63i" path="res://resource/animation/character/hero01_long_attack.aseprite" id="3_d0x76"] +[ext_resource type="SpriteFrames" uid="uid://7swf8owxd63i" path="res://resource/animation/character/hero01_long_attack.aseprite" id="3_ibonj"] [ext_resource type="Script" path="res://script/character/move.gd" id="4_66r53"] [ext_resource type="Script" path="res://script/character/view.gd" id="4_vijjv"] [ext_resource type="Script" path="res://script/character/skill.gd" id="6_h4xqy"] @@ -21,15 +21,14 @@ shape = SubResource("BoxShape3D_ty8lx") [node name="Status" type="Node3D" parent="."] unique_name_in_owner = true script = ExtResource("2_txdip") -break_level = 4 [node name="View" type="AnimatedSprite3D" parent="."] unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 1.414, 0, 0, 0, 1, 0, 0, 0) alpha_cut = 2 texture_filter = 0 -sprite_frames = ExtResource("3_d0x76") -animation = &"long_attack01" +sprite_frames = ExtResource("3_ibonj") +animation = &"long_attack04" script = ExtResource("4_vijjv") metadata/_aseprite_wizard_config_ = { "layer": "", diff --git a/scene/character/player.tscn b/scene/character/player.tscn index 5b04159..711dfd1 100644 --- a/scene/character/player.tscn +++ b/scene/character/player.tscn @@ -6,9 +6,6 @@ [node name="Character" instance=ExtResource("1_bny0p")] -[node name="Status" parent="." index="1"] -break_level = 0 - [node name="Input" type="Node3D" parent="." index="5"] script = ExtResource("2_qkra8") diff --git a/script/_global/setting.gd b/script/_global/setting.gd index 8613fdb..e5b8fd5 100644 --- a/script/_global/setting.gd +++ b/script/_global/setting.gd @@ -4,5 +4,8 @@ extends Node3D const pixel_size : float = 0.01 const sprite_scale : float = 1.414 +#移动 +const is_jumped_check_time : float = 0.1 + #技能系统 const input_alive_time : float = 0.5 diff --git a/script/_global/util.gd b/script/_global/util.gd index 1176819..68f9552 100644 --- a/script/_global/util.gd +++ b/script/_global/util.gd @@ -1,12 +1,14 @@ @tool extends Node3D -var animation_library = load("res://resource/skill_animation_library/animation_library.tres") func get_resource_name(resource:Resource) -> String: return resource.resource_path.get_file().trim_suffix('.tres') #todo 性能 func refresh_animation_lib(): + var animation_library_path = "res://resource/skill_animation_library/animation_library.tres" + var animation_library = load(animation_library_path) + var dir_path = "res://resource/skill_animation" var dir = DirAccess.open(dir_path) for file in dir.get_files(): @@ -15,8 +17,11 @@ func refresh_animation_lib(): if res is Animation: var animation = res as Animation var animation_name = Util.get_resource_name(animation) + print(animation_name) animation_library.add_animation(animation_name,animation) animation_library.animation_added.emit(animation_name) + + ResourceSaver.save(animation_library,animation_library_path) func get_all_player_skill(): var ret = [] diff --git a/script/character/move.gd b/script/character/move.gd index 96ab3e0..d4c3ab3 100644 --- a/script/character/move.gd +++ b/script/character/move.gd @@ -7,16 +7,20 @@ class_name Move var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") func _physics_process(delta): - update_on_floor() + update_on_floor(delta) update_gravity(delta) update_move() character.move_and_slide() -func update_on_floor(): +func update_on_floor(delta): status.is_on_floor = character.is_on_floor() if status.is_on_floor: - status.is_jumped = false + if status.is_jumped_check_time > 0: + status.is_jumped_check_time -= delta + else: + status.is_jumped_check_time = 0 + status.is_jumped = false func update_gravity(delta): if not status.is_on_floor: @@ -41,4 +45,5 @@ func update_move(): func jump(): character.velocity.y = status.cfg.move.jump_velocity status.is_jumped = true + status.is_jumped_check_time = Setting.is_jumped_check_time status.trigger_jump = true diff --git a/script/character/player/combo.gd b/script/character/player/combo.gd index 33a23b8..5cecfbf 100644 --- a/script/character/player/combo.gd +++ b/script/character/player/combo.gd @@ -47,7 +47,7 @@ func update_break_cancel(): func update_break_jump(): for i in range(0,len(input_list)): var input = input_list[i] - if input.action == "jump": + if input.action == "jump" and not status.is_jumped: refresh_input(i) skill.cancel_skill() move.jump() @@ -85,11 +85,13 @@ func refresh_input(index:int): input_list = input_list.slice(index+1) func update_move(): - if status.is_free_control: + if status.is_skill_running: + status.move_dir = Vector2.ZERO + else: status.move_dir = status.input_dir status.stance = Enum.EStance.Idle if status.is_on_floor else Enum.EStance.AirIdle status.break_level = Enum.EBreakLevel.Walk - + func add_input_action(action:String): var new_input = InputData.new() new_input.action = action diff --git a/script/character/player/input.gd b/script/character/player/input.gd index 48da78d..c177ec7 100644 --- a/script/character/player/input.gd +++ b/script/character/player/input.gd @@ -3,6 +3,8 @@ extends Node @onready var status = (%Status as Status) @onready var combo = (%Combo as Combo) +var action_map = {} + func _ready(): SignalManager.connect("input_action_pressed",on_input_action_pressed) SignalManager.connect("input_action_pressed",on_input_action_released) @@ -11,10 +13,14 @@ func _ready(): func on_input_action_pressed(event:InputEvent): for action_name in InputMap.get_actions(): if event.is_action(action_name): - combo.add_input_action(action_name) + if not action_name in action_map: + action_map[action_name] = true + combo.add_input_action(action_name) func on_input_action_released(event:InputEvent): - pass + for action_name in InputMap.get_actions(): + if event.is_action(action_name): + action_map.erase(action_name) func on_input_action_move(input_dir): status.input_dir = input_dir diff --git a/script/character/skill.gd b/script/character/skill.gd index e4cffc1..1f3d146 100644 --- a/script/character/skill.gd +++ b/script/character/skill.gd @@ -11,15 +11,22 @@ func _process(delta): pass func cast_skill(cfg:SkillCfg,cast_dir:Vector2): - status.is_free_control = false - status.is_skill_running = true - status.skill_dir = cast_dir - play("animation_library/%s"%Util.get_resource_name(cfg)) + var animation_name = "animation_library/%s" % Util.get_resource_name(cfg) + if has_animation(animation_name): + status.is_free_control = false + status.is_skill_running = true + status.skill_dir = cast_dir + status.break_level = Enum.EBreakLevel.None + play(animation_name) + else: + print("技能animation不存在",animation_name) func cancel_skill(): - view.reset() status.is_free_control = true status.is_skill_running = false + status.break_level = Enum.EBreakLevel.Walk + stop() + view.reset() func _on_animation_finished(_anim_name): cancel_skill() diff --git a/script/character/status.gd b/script/character/status.gd index 5d33728..9e8b271 100644 --- a/script/character/status.gd +++ b/script/character/status.gd @@ -23,15 +23,18 @@ class_name Status @export var is_free_turn : bool = true #是否允许转向 @export var is_right : bool = true #是否向右 @export var is_jumped : bool #是否已跳跃 +@export var is_jumped_check_time : float #是否已跳跃检测时间 避免未起直接判定落地 @export_category("技能状态") @export var is_skill_running : bool #技能是否正在释放 -@export_category("玩家输入状态") +@export_category("玩家技能状态") @export var input_dir : Vector2 #指令方向 @export var skill_dir : Vector2 #技能释放方向 @export var stance : Enum.EStance #技能姿态 @export var break_level : Enum.EBreakLevel #打断等级 +@export var skill_move_speed : float #技能位移速度 +@export var skill_step_speed : float #技能操控速度 @export_category("动画触发器") @export var trigger_jump : bool #跳跃