技能系统
parent
fd2f2ce5e5
commit
473c8ec96a
@ -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"
|
||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 25 KiB |
@ -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]
|
||||||
|
}
|
||||||
@ -1,13 +1,96 @@
|
|||||||
extends Node3D
|
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 = [] #指令缓存
|
var input_list = [] #指令缓存
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready():
|
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):
|
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)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue