diff --git a/resource/skill_animation/hero01_long_attack01.tres b/resource/skill_animation/hero01_long_attack01.tres index 4f729be..bc7ea6b 100644 --- a/resource/skill_animation/hero01_long_attack01.tres +++ b/resource/skill_animation/hero01_long_attack01.tres @@ -53,3 +53,27 @@ tracks/3/keys = { "update": 1, "values": [0, 3, 4] } +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Status:speed_up_rate") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0.1, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [-0.5, -1.0] +} +tracks/5/type = "value" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("Status:skill_move_speed") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0.1, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [1.0, 0.0] +} diff --git a/resource/skill_animation/hero01_long_attack02.tres b/resource/skill_animation/hero01_long_attack02.tres index 3bc3e0f..ab7cfa0 100644 --- a/resource/skill_animation/hero01_long_attack02.tres +++ b/resource/skill_animation/hero01_long_attack02.tres @@ -53,3 +53,27 @@ tracks/3/keys = { "update": 1, "values": [0, 3, 4] } +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Status:speed_up_rate") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0.1, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [-0.5, -1.0] +} +tracks/5/type = "value" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("Status:skill_move_speed") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0.1, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [1.0, 0.0] +} diff --git a/resource/skill_animation/hero01_long_attack03.tres b/resource/skill_animation/hero01_long_attack03.tres index 98bf232..7a13350 100644 --- a/resource/skill_animation/hero01_long_attack03.tres +++ b/resource/skill_animation/hero01_long_attack03.tres @@ -53,3 +53,27 @@ tracks/3/keys = { "update": 1, "values": [0, 3, 4] } +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Status:speed_up_rate") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0.1, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [-0.5, -1.0] +} +tracks/5/type = "value" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("Status:skill_move_speed") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0.1, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [1.0, 0.0] +} diff --git a/resource/skill_animation/hero01_long_attack04.tres b/resource/skill_animation/hero01_long_attack04.tres index 19f52e9..9a66994 100644 --- a/resource/skill_animation/hero01_long_attack04.tres +++ b/resource/skill_animation/hero01_long_attack04.tres @@ -53,3 +53,27 @@ tracks/3/keys = { "update": 1, "values": [0, 3, 4] } +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Status:speed_up_rate") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0.1, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [-0.5, -1.0] +} +tracks/5/type = "value" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("Status:skill_move_speed") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0.1, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [1.0, 0.0] +} diff --git a/resource/skill_animation/hero01_long_flash.tres b/resource/skill_animation/hero01_long_flash.tres index b228aa4..32cb32c 100644 --- a/resource/skill_animation/hero01_long_flash.tres +++ b/resource/skill_animation/hero01_long_flash.tres @@ -41,3 +41,27 @@ tracks/2/keys = { "update": 0, "values": [0, 1, 2, 3, 4] } +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Status:speed_up_rate") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0.1, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [0.0, 0.0] +} +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Status:skill_move_speed") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0.1, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [4.0, 0.0] +} diff --git a/resource/skill_animation/hero01_long_skill01.tres b/resource/skill_animation/hero01_long_skill01.tres index b193d4b..3163c25 100644 --- a/resource/skill_animation/hero01_long_skill01.tres +++ b/resource/skill_animation/hero01_long_skill01.tres @@ -52,3 +52,27 @@ tracks/3/keys = { "update": 1, "values": [0, 3, 4] } +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Status:speed_up_rate") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0.1, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [-0.5, -1.0] +} +tracks/5/type = "value" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("Status:skill_move_speed") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0.1, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [1.0, 0.0] +} diff --git a/scene/character/character.tscn b/scene/character/character.tscn index 616923c..667e09e 100644 --- a/scene/character/character.tscn +++ b/scene/character/character.tscn @@ -28,7 +28,7 @@ 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_ibonj") -animation = &"long_attack04" +animation = &"long_attack01" script = ExtResource("4_vijjv") metadata/_aseprite_wizard_config_ = { "layer": "", diff --git a/scene/character/player.tscn b/scene/character/player.tscn index 711dfd1..d233719 100644 --- a/scene/character/player.tscn +++ b/scene/character/player.tscn @@ -1,11 +1,16 @@ -[gd_scene load_steps=4 format=3 uid="uid://b85fy0wfgr4gs"] +[gd_scene load_steps=5 format=3 uid="uid://b85fy0wfgr4gs"] [ext_resource type="PackedScene" uid="uid://vnkcr04hevna" path="res://scene/character/character.tscn" id="1_bny0p"] +[ext_resource type="SpriteFrames" uid="uid://0yuryfn6dc2v" path="res://resource/animation/character/hero01_long_skill01.aseprite" id="2_cg8l2"] [ext_resource type="Script" path="res://script/character/player/input.gd" id="2_qkra8"] [ext_resource type="Script" path="res://script/character/player/combo.gd" id="4_jsefx"] [node name="Character" instance=ExtResource("1_bny0p")] +[node name="View" parent="." index="2"] +sprite_frames = ExtResource("2_cg8l2") +animation = &"long_flash" + [node name="Input" type="Node3D" parent="." index="5"] script = ExtResource("2_qkra8") diff --git a/script/character/move.gd b/script/character/move.gd index d4c3ab3..72c016d 100644 --- a/script/character/move.gd +++ b/script/character/move.gd @@ -28,19 +28,16 @@ func update_gravity(delta): status.speed_y = character.velocity.y func update_move(): - var input_dir = status.move_dir - var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized() - var speed = status.cfg.move.speed - if direction: - character.velocity.x = direction.x * speed - character.velocity.z = direction.z * speed - else: - character.velocity.x = move_toward(character.velocity.x, 0, speed) - character.velocity.z = move_toward(character.velocity.z, 0, speed) + var move_speed = status.cfg.move.speed * (1 + status.speed_up_rate) + var move_velocity = status.move_dir * move_speed + var skill_velocity = status.skill_dir * status.skill_move_speed + move_velocity += skill_velocity + character.velocity.x = move_velocity.x + character.velocity.z = move_velocity.y status.speed_xz = Vector2(character.velocity.x,character.velocity.z).length() - if status.is_free_turn and direction.x != 0: - status.is_right = direction.x > 0 + if status.is_free_turn and move_velocity.x != 0: + status.is_right = move_velocity.x > 0 func jump(): character.velocity.y = status.cfg.move.jump_velocity diff --git a/script/character/player/combo.gd b/script/character/player/combo.gd index 5cecfbf..c89a5ea 100644 --- a/script/character/player/combo.gd +++ b/script/character/player/combo.gd @@ -85,10 +85,10 @@ func refresh_input(index:int): input_list = input_list.slice(index+1) func update_move(): + status.move_dir = status.input_dir if status.is_skill_running: - status.move_dir = Vector2.ZERO + pass 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 diff --git a/script/character/skill.gd b/script/character/skill.gd index 1f3d146..aadc69c 100644 --- a/script/character/skill.gd +++ b/script/character/skill.gd @@ -11,8 +11,12 @@ func _process(delta): pass func cast_skill(cfg:SkillCfg,cast_dir:Vector2): + if cast_dir.length() == 0: + cast_dir = Vector2.RIGHT if status.is_right else Vector2.LEFT + var animation_name = "animation_library/%s" % Util.get_resource_name(cfg) if has_animation(animation_name): + status.speed_up_rate = -1 status.is_free_control = false status.is_skill_running = true status.skill_dir = cast_dir @@ -22,10 +26,11 @@ func cast_skill(cfg:SkillCfg,cast_dir:Vector2): print("技能animation不存在",animation_name) func cancel_skill(): + stop() + status.speed_up_rate = 0 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): diff --git a/script/character/status.gd b/script/character/status.gd index 9e8b271..8fbb960 100644 --- a/script/character/status.gd +++ b/script/character/status.gd @@ -16,6 +16,7 @@ class_name Status @export_category("移动状态") @export var move_dir : Vector2 #移动方向 +@export var speed_up_rate : float #移动速度比率 @export var speed_xz : float #水平移动速度 @export var speed_y : float #竖直移动速度 @export var is_free_control : bool = true #是否可以自由控制 @@ -27,14 +28,13 @@ class_name Status @export_category("技能状态") @export var is_skill_running : bool #技能是否正在释放 +@export var skill_dir : Vector2 #技能释放方向 +@export var skill_move_speed : float #技能位移速度 @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 #跳跃