diff --git a/config/player_skill/hero01_long_attack01.tres b/config/player_skill/hero01_long_attack01.tres index 9d8194e..c10fc30 100644 --- a/config/player_skill/hero01_long_attack01.tres +++ b/config/player_skill/hero01_long_attack01.tres @@ -10,8 +10,10 @@ script = ExtResource("1_gik08") weapon = ExtResource("4_id85o") stance_from = 0 stance_to = 1 +action = "light_attack" name = "" skill_animation = ExtResource("2_6nbpq") +break_level = 2 has_animation = false sprite_frams = ExtResource("3_og1bb") animation_name = "long_attack01" diff --git a/config/player_skill/hero01_long_attack02.tres b/config/player_skill/hero01_long_attack02.tres index 96c87d8..15fc960 100644 --- a/config/player_skill/hero01_long_attack02.tres +++ b/config/player_skill/hero01_long_attack02.tres @@ -10,8 +10,10 @@ script = ExtResource("1_e0fqi") weapon = ExtResource("4_novna") stance_from = 1 stance_to = 2 +action = "light_attack" name = "" skill_animation = ExtResource("2_jrgan") -has_animation = true +break_level = 2 +has_animation = false sprite_frams = ExtResource("3_jidy7") animation_name = "long_attack02" diff --git a/config/player_skill/hero01_long_attack03.tres b/config/player_skill/hero01_long_attack03.tres index ce4320f..30ec02d 100644 --- a/config/player_skill/hero01_long_attack03.tres +++ b/config/player_skill/hero01_long_attack03.tres @@ -10,8 +10,10 @@ script = ExtResource("1_uaib7") weapon = ExtResource("2_8uqiw") stance_from = 2 stance_to = 3 +action = "light_attack" name = "" skill_animation = ExtResource("2_ugt3f") +break_level = 2 has_animation = true sprite_frams = ExtResource("3_sr2og") animation_name = "long_attack03" diff --git a/config/player_skill/hero01_long_attack04.tres b/config/player_skill/hero01_long_attack04.tres index 2c8ae60..4b9a46f 100644 --- a/config/player_skill/hero01_long_attack04.tres +++ b/config/player_skill/hero01_long_attack04.tres @@ -10,8 +10,10 @@ script = ExtResource("1_xsxbs") weapon = ExtResource("4_plyre") stance_from = 3 stance_to = 4 +action = "light_attack" name = "" skill_animation = ExtResource("2_sam6s") +break_level = 2 has_animation = true sprite_frams = ExtResource("3_w7h1m") animation_name = "long_attack04" diff --git a/config/player_skill/hero01_long_flash.tres b/config/player_skill/hero01_long_flash.tres new file mode 100644 index 0000000..05e7343 --- /dev/null +++ b/config/player_skill/hero01_long_flash.tres @@ -0,0 +1,19 @@ +[gd_resource type="Resource" script_class="PlayerSkillCfg" load_steps=5 format=3 uid="uid://cyqiiar75vf87"] + +[ext_resource type="Script" path="res://script/config/player_skill_cfg.gd" id="1_yamsl"] +[ext_resource type="Animation" uid="uid://cwm116apu63n1" path="res://resource/skill_animation/hero01_long_flash.tres" id="2_bdxlh"] +[ext_resource type="SpriteFrames" uid="uid://0yuryfn6dc2v" path="res://resource/animation/character/hero01_long_skill01.aseprite" id="2_uof6p"] +[ext_resource type="Resource" uid="uid://cy3wwalxeyro0" path="res://config/weapon/long.tres" id="4_xft4c"] + +[resource] +script = ExtResource("1_yamsl") +weapon = ExtResource("4_xft4c") +stance_from = 100 +stance_to = 0 +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/config/player_skill/hero01_long_skill01.tres b/config/player_skill/hero01_long_skill01.tres index c9488c4..d01ef2a 100644 --- a/config/player_skill/hero01_long_skill01.tres +++ b/config/player_skill/hero01_long_skill01.tres @@ -10,8 +10,10 @@ script = ExtResource("1_ud5ph") weapon = ExtResource("4_3bf64") stance_from = 1 stance_to = 2 +action = "heavy_attack" name = "" skill_animation = ExtResource("2_ewts2") +break_level = 2 has_animation = true sprite_frams = ExtResource("3_qwjfl") animation_name = "long_skill01" diff --git a/project.godot b/project.godot index 7aa168e..9ecc289 100644 --- a/project.godot +++ b/project.godot @@ -110,6 +110,11 @@ jump={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null) ] } +flash={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} [rendering] diff --git a/resource/animation/character/hero01_long_skill01.aseprite b/resource/animation/character/hero01_long_skill01.aseprite index 5ac1a3b..f7af865 100644 Binary files a/resource/animation/character/hero01_long_skill01.aseprite and b/resource/animation/character/hero01_long_skill01.aseprite differ diff --git a/resource/animation/character/hero01_long_skill01.png b/resource/animation/character/hero01_long_skill01.png index fd25fbd..f5fb874 100644 Binary files a/resource/animation/character/hero01_long_skill01.png and b/resource/animation/character/hero01_long_skill01.png differ diff --git a/resource/skill_animation/hero01_long_attack01.tres b/resource/skill_animation/hero01_long_attack01.tres index e3a023a..c0d0185 100644 --- a/resource/skill_animation/hero01_long_attack01.tres +++ b/resource/skill_animation/hero01_long_attack01.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.5, 0.7), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 1, +"values": [0, 2, 4] +} diff --git a/resource/skill_animation/hero01_long_flash.tres b/resource/skill_animation/hero01_long_flash.tres new file mode 100644 index 0000000..b228aa4 --- /dev/null +++ b/resource/skill_animation/hero01_long_flash.tres @@ -0,0 +1,43 @@ +[gd_resource type="Animation" load_steps=2 format=3 uid="uid://cwm116apu63n1"] + +[ext_resource type="SpriteFrames" uid="uid://0yuryfn6dc2v" path="res://resource/animation/character/hero01_long_skill01.aseprite" id="2_3eu5o"] + +[resource] +resource_name = "hero01_long_flash" +length = 0.5 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("View:sprite_frames") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [ExtResource("2_3eu5o")] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("View:animation") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": ["long_flash"] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("View:frame") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [0, 1, 2, 3, 4] +} diff --git a/scene/character/player.tscn b/scene/character/player.tscn index 7837fb0..711dfd1 100644 --- a/scene/character/player.tscn +++ b/scene/character/player.tscn @@ -1,15 +1,13 @@ -[gd_scene load_steps=5 format=3 uid="uid://b85fy0wfgr4gs"] +[gd_scene load_steps=4 format=3 uid="uid://b85fy0wfgr4gs"] [ext_resource type="PackedScene" uid="uid://vnkcr04hevna" path="res://scene/character/character.tscn" id="1_bny0p"] [ext_resource type="Script" path="res://script/character/player/input.gd" id="2_qkra8"] -[ext_resource type="Resource" uid="uid://b6x3jdiqtum6" path="res://config/player_skill/hero01_long_attack01.tres" id="3_n2lf8"] [ext_resource type="Script" path="res://script/character/player/combo.gd" id="4_jsefx"] [node name="Character" instance=ExtResource("1_bny0p")] [node name="Input" type="Node3D" parent="." index="5"] script = ExtResource("2_qkra8") -test_skill_cfg = ExtResource("3_n2lf8") [node name="Combo" type="Node3D" parent="." index="6"] unique_name_in_owner = true diff --git a/script/_global/enum.gd b/script/_global/enum.gd index 5397991..7eea46f 100644 --- a/script/_global/enum.gd +++ b/script/_global/enum.gd @@ -9,4 +9,4 @@ enum EStance { None = 99, Any = 100, } -enum EBreakLevel {None, Cancel, Combo, Jump, Walk} #不可打断 取消技打断 连招打断 跳跃打断 行走打断 +enum EBreakLevel {None, Cancel, Jump, Combo, Walk} #不可打断 取消技打断 跳跃打断 连招打断 行走打断 diff --git a/script/_global/setting.gd b/script/_global/setting.gd index a2d1e2e..f91689c 100644 --- a/script/_global/setting.gd +++ b/script/_global/setting.gd @@ -4,3 +4,5 @@ extends Node3D const pixel_size : float = 0.01 const sprite_scale : float = 1.414 +#技能系统 +const input_alive_time : float = 0.2 diff --git a/script/_global/util.gd b/script/_global/util.gd index 8b96bd8..1176819 100644 --- a/script/_global/util.gd +++ b/script/_global/util.gd @@ -18,3 +18,13 @@ func refresh_animation_lib(): animation_library.add_animation(animation_name,animation) animation_library.animation_added.emit(animation_name) +func get_all_player_skill(): + var ret = [] + var dir_path = "res://config/player_skill" + var dir = DirAccess.open(dir_path) + for file in dir.get_files(): + var path = dir_path + "/" + file + var res = load(path) + if res is PlayerSkillCfg: + ret.append(res) + return ret diff --git a/script/character/player/combo.gd b/script/character/player/combo.gd index c63b3b0..b6f56fa 100644 --- a/script/character/player/combo.gd +++ b/script/character/player/combo.gd @@ -1,13 +1,96 @@ extends Node3D +class_name Combo -var skill_map = {} #stance -> skill +@onready var status = (%Status as Status) +@onready var skill = (%Skill as Skill) +@onready var move = (%Move as Move) + +class InputData: + var action:String + var alive_time:float + +var skill_map = {} #input -> skill[] var input_list = [] #指令缓存 -# Called when the node enters the scene tree for the first time. func _ready(): - pass # Replace with function body. + for player_skill_res in Util.get_all_player_skill(): + var player_skill = player_skill_res as PlayerSkillCfg + add_skill(player_skill.action,player_skill_res) - -# Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): - pass + update_input_alive(delta) + update_break() + update_move() + +func update_input_alive(delta): + var input_list_new = [] + for input in input_list: + input.alive_time -= delta + if input.alive_time > 0: + input_list_new.append(input) + input_list = input_list_new + +func update_break(): + for break_level_name in Enum.EBreakLevel: + var break_level = Enum.EBreakLevel[break_level_name] + if break_level <= status.break_level: + match break_level: + Enum.EBreakLevel.None: pass + Enum.EBreakLevel.Cancel: update_break_cancel() + Enum.EBreakLevel.Jump: update_break_jump() + Enum.EBreakLevel.Combo: update_break_combo() + Enum.EBreakLevel.Walk: update_break_walk() + +func update_break_cancel(): + update_break_by_level(Enum.EBreakLevel.Cancel) + +func update_break_jump(): + var index = input_list.find("jump") + if index == -1: + return + refresh_input(index) + skill.cancel_skill() + move.jump() + +func update_break_combo(): + update_break_by_level(Enum.EBreakLevel.Combo) + +func update_break_walk(): + if status.input_dir.length() > 0: + refresh_input(len(input_list)) + skill.cancel_skill() + +func update_break_by_level(break_level:Enum.EBreakLevel): + for i in range(0,len(input_list)): + var input = input_list[i] + var skillCfgList = [] + if input.action in skill_map: + skillCfgList.append_array(skill_map[input.action]) + if "any" in skill_map: + skillCfgList.append_array(skill_map["any"]) + for skillCfg in skillCfgList: + if skillCfg.break_level == break_level: + skill.cast_skill(skillCfg,status.input_dir) + refresh_input(i) + +func refresh_input(index:int): + if index >= len(input_list)-1: + input_list = [] + else: + input_list = input_list.slice(index+1) + +func update_move(): + if status.is_free_control: + status.move_dir = status.input_dir + +func add_input_action(action:String): + var new_input = InputData.new() + new_input.action = action + new_input.alive_time = Setting.input_alive_time + input_list.append(new_input) + +func add_skill(action:String,skillCfg:SkillCfg): + if not action in skill_map: + skill_map[action] = [] + skill_map[action].append(skillCfg) + diff --git a/script/character/player/input.gd b/script/character/player/input.gd index 1818274..f7c9019 100644 --- a/script/character/player/input.gd +++ b/script/character/player/input.gd @@ -1,9 +1,7 @@ extends Node -@export var test_skill_cfg:SkillCfg @onready var status = (%Status as Status) -@onready var skill = (%Skill as Skill) -@onready var move = (%Move as Move) +@onready var combo = (%Combo as Combo) func _ready(): SignalManager.connect("input_action_pressed",on_input_action_pressed) @@ -11,15 +9,10 @@ func _ready(): SignalManager.connect("input_action_move",on_input_action_move) func on_input_action_pressed(event:InputEvent): - if event.is_action("attack_light"): - skill.cast_skill(test_skill_cfg,Vector2(1,1)) - elif event.is_action("jump"): - move.jump() + combo.add_input_action(event.as_text()) func on_input_action_released(event:InputEvent): pass func on_input_action_move(input_dir): - if !status.is_free_control: - return - status.move_dir = input_dir + status.input_dir = input_dir diff --git a/script/character/skill.gd b/script/character/skill.gd index 330c00d..e4cffc1 100644 --- a/script/character/skill.gd +++ b/script/character/skill.gd @@ -12,9 +12,14 @@ func _process(delta): 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)) -func _on_animation_finished(_anim_name): +func cancel_skill(): view.reset() status.is_free_control = true - + status.is_skill_running = false + +func _on_animation_finished(_anim_name): + cancel_skill() diff --git a/script/character/status.gd b/script/character/status.gd index ea03f20..5d33728 100644 --- a/script/character/status.gd +++ b/script/character/status.gd @@ -25,6 +25,11 @@ class_name Status @export var is_jumped : bool #是否已跳跃 @export_category("技能状态") +@export var is_skill_running : bool #技能是否正在释放 + +@export_category("玩家输入状态") +@export var input_dir : Vector2 #指令方向 +@export var skill_dir : Vector2 #技能释放方向 @export var stance : Enum.EStance #技能姿态 @export var break_level : Enum.EBreakLevel #打断等级 diff --git a/script/config/player_skill_cfg.gd b/script/config/player_skill_cfg.gd index be1fc6c..15fa5e9 100644 --- a/script/config/player_skill_cfg.gd +++ b/script/config/player_skill_cfg.gd @@ -6,3 +6,4 @@ class_name PlayerSkillCfg @export var weapon : WeaponCfg @export var stance_from : Enum.EStance @export var stance_to : Enum.EStance +@export_enum("light_attack","heavy_attack","flash") var action : String = "light_attack" diff --git a/script/config/skill_cfg.gd b/script/config/skill_cfg.gd index f546177..c8bb1ed 100644 --- a/script/config/skill_cfg.gd +++ b/script/config/skill_cfg.gd @@ -5,6 +5,7 @@ class_name SkillCfg @export var name : String @export var skill_animation : Animation +@export var break_level : Enum.EBreakLevel = Enum.EBreakLevel.Combo var _has_animation : bool @export var has_animation : bool :