|
|
|
|
extends Node3D
|
|
|
|
|
class_name Combo
|
|
|
|
|
|
|
|
|
|
@onready var character: Character = (get_owner() as Character)
|
|
|
|
|
@onready var status: Status = (%Status as Status)
|
|
|
|
|
@onready var skill: Skill = (%Skill as Skill)
|
|
|
|
|
@onready var move: Move = (%Move as Move)
|
|
|
|
|
@onready var core: Core = (%Core as Core)
|
|
|
|
|
@onready var battle: Battle = (%Battle as Battle)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InputData:
|
|
|
|
|
var action: String
|
|
|
|
|
var alive_time: float
|
|
|
|
|
var is_switch: bool
|
|
|
|
|
|
|
|
|
|
var input_list: Array[InputData] = [] #指令缓存
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
|
# test
|
|
|
|
|
add_basic_skill()
|
|
|
|
|
add_weapon(load("res://config/weapon/long.tres") as WeaponCfg)
|
|
|
|
|
add_weapon(load("res://config/weapon/short.tres") as WeaponCfg)
|
|
|
|
|
add_weapon(load("res://config/weapon/fist.tres") as WeaponCfg)
|
|
|
|
|
|
|
|
|
|
core.set_active_core(0, load("res://config/core/hero01_remote01.tres") as CoreCfg)
|
|
|
|
|
core.set_active_core(1, load("res://config/core/monster03_slash01.tres") as CoreCfg)
|
|
|
|
|
core.set_active_core(2, load("res://config/core/monster03_slash02.tres") as CoreCfg)
|
|
|
|
|
core.set_active_core(3, load("res://config/core/monster03_slash03.tres") as CoreCfg)
|
|
|
|
|
|
|
|
|
|
core.set_active_core(4, load("res://config/core/hero01_remote01.tres") as CoreCfg)
|
|
|
|
|
core.set_active_core(5, load("res://config/core/monster03_slash01.tres") as CoreCfg)
|
|
|
|
|
core.set_active_core(6, load("res://config/core/monster03_slash02.tres") as CoreCfg)
|
|
|
|
|
core.set_active_core(7, load("res://config/core/monster03_slash03.tres") as CoreCfg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
|
update_input_alive(delta)
|
|
|
|
|
update_charging()
|
|
|
|
|
update_break()
|
|
|
|
|
update_move()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func update_charging() -> void:
|
|
|
|
|
if not status.is_charging:
|
|
|
|
|
return
|
|
|
|
|
var release_key: String = "%s_release" % status.skill_action_key
|
|
|
|
|
for i in range(0, len(input_list)):
|
|
|
|
|
var input: InputData = input_list[i]
|
|
|
|
|
if not input.action == release_key:
|
|
|
|
|
continue
|
|
|
|
|
refresh_input(i)
|
|
|
|
|
battle.on_skill_release_trigger(status.skill_cfg.get_res_name())
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func update_input_alive(delta):
|
|
|
|
|
var input_list_new: Array[InputData] = []
|
|
|
|
|
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:
|
|
|
|
|
var is_break: bool = false
|
|
|
|
|
match break_level:
|
|
|
|
|
Enum.EBreakLevel.None: is_break = update_break_none()
|
|
|
|
|
Enum.EBreakLevel.Cancel: is_break = update_break_cancel()
|
|
|
|
|
Enum.EBreakLevel.Jump: is_break = update_break_jump()
|
|
|
|
|
Enum.EBreakLevel.Break: is_break = update_break_break()
|
|
|
|
|
Enum.EBreakLevel.Walk: is_break = update_break_walk()
|
|
|
|
|
if is_break:
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
func update_break_none() -> bool:
|
|
|
|
|
return update_break_by_level(Enum.EBreakLevel.None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func update_break_cancel() -> bool:
|
|
|
|
|
return update_break_by_level(Enum.EBreakLevel.Cancel)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func update_break_jump() -> bool:
|
|
|
|
|
for i in range(0, len(input_list)):
|
|
|
|
|
var input: InputData = input_list[i]
|
|
|
|
|
if (input.action == "jump") and not status.is_jumped:
|
|
|
|
|
refresh_input(i)
|
|
|
|
|
skill.cancel_skill()
|
|
|
|
|
move.jump()
|
|
|
|
|
return true
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func update_break_break() -> bool:
|
|
|
|
|
return update_break_by_level(Enum.EBreakLevel.Break)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func update_break_walk() -> bool:
|
|
|
|
|
if status.is_skill_running and status.input_dir.length() > 0:
|
|
|
|
|
refresh_input(len(input_list))
|
|
|
|
|
skill.cancel_skill()
|
|
|
|
|
return true
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func update_break_by_level(break_level: Enum.EBreakLevel) -> bool:
|
|
|
|
|
for i in range(0, len(input_list)):
|
|
|
|
|
var input: InputData = input_list[i]
|
|
|
|
|
if input.is_switch:
|
|
|
|
|
if core.cast_skill_by_action( input.action, status.input_dir):
|
|
|
|
|
refresh_input(i)
|
|
|
|
|
return true
|
|
|
|
|
else:
|
|
|
|
|
if input.action in skill.skill_map:
|
|
|
|
|
for skill_cfg: SkillCfg in skill.skill_map[input.action]:
|
|
|
|
|
#释放技能扣除mp检查
|
|
|
|
|
var skill_cfg_with_cost: SkillCfg = skill.cast_skill_mp_cost_check(skill_cfg)
|
|
|
|
|
if not skill_cfg_with_cost:
|
|
|
|
|
continue
|
|
|
|
|
#施放技能条件检查
|
|
|
|
|
if not skill.cast_skill_check(skill_cfg_with_cost, break_level):
|
|
|
|
|
continue
|
|
|
|
|
#施放技能扣除mp
|
|
|
|
|
if not skill.cast_skill_mp_cost(skill_cfg_with_cost):
|
|
|
|
|
continue
|
|
|
|
|
skill.cast_skill(skill_cfg_with_cost, status.input_dir, input.action)
|
|
|
|
|
refresh_input(i)
|
|
|
|
|
return true
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func refresh_input(index: int):
|
|
|
|
|
if index >= len(input_list)-1:
|
|
|
|
|
input_list = []
|
|
|
|
|
else:
|
|
|
|
|
input_list = input_list.slice(index+1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func update_move():
|
|
|
|
|
status.move_dir = status.input_dir
|
|
|
|
|
if status.is_skill_running:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
if not status.is_on_floor or status.is_jumping:
|
|
|
|
|
status.stance = Enum.EStance.AirIdle
|
|
|
|
|
else:
|
|
|
|
|
status.stance = Enum.EStance.GroundIdle
|
|
|
|
|
status.break_level = Enum.EBreakLevel.Walk
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func add_input_action(action: String, is_switch: bool) -> void:
|
|
|
|
|
if is_switch:
|
|
|
|
|
var action_index: int = core.get_action_index(action)
|
|
|
|
|
if action_index < 0:
|
|
|
|
|
return
|
|
|
|
|
if action_index >= 4:
|
|
|
|
|
core.cast_skill_sub(action_index, status.input_dir, status.target)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
var new_input = InputData.new()
|
|
|
|
|
new_input.action = action
|
|
|
|
|
new_input.alive_time = Setting.input_alive_time
|
|
|
|
|
new_input.is_switch = is_switch
|
|
|
|
|
input_list.append(new_input)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func add_weapon(weapon: WeaponCfg):
|
|
|
|
|
status.weapon_list.append(weapon)
|
|
|
|
|
for skill_player_weapon: SkillWeaponCfg in Util.get_skill_player_weapon_by_weapon(weapon):
|
|
|
|
|
skill.add_skill(skill_player_weapon.action, skill_player_weapon)
|
|
|
|
|
status.emit_status("weapon_list")
|
|
|
|
|
status.set_status("weapon_index", 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func add_basic_skill():
|
|
|
|
|
for skill_player_weapon: SkillWeaponCfg in Util.get_all_skill_player_basic():
|
|
|
|
|
skill.add_skill(skill_player_weapon.action, skill_player_weapon)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func weapon_index_change(dir: int) -> void:
|
|
|
|
|
if not status.weapon_list:
|
|
|
|
|
return
|
|
|
|
|
if status.weapon_index_change_dir:
|
|
|
|
|
return
|
|
|
|
|
if abs(dir) != 1:
|
|
|
|
|
return
|
|
|
|
|
status.set_status("weapon_index_change_dir", dir)
|
|
|
|
|
character.add_buff("weapon_index_change", Setting.weapon_anime_duration)
|
|
|
|
|
return
|