|
|
|
@ -14,48 +14,52 @@ class BuffInfo:
|
|
|
|
var ignore_pause: bool
|
|
|
|
var ignore_pause: bool
|
|
|
|
|
|
|
|
|
|
|
|
var buff_map: Dictionary = {} # buff信息
|
|
|
|
var buff_map: Dictionary = {} # buff信息
|
|
|
|
var buff_tick_frame_max = 1
|
|
|
|
var delta_cache_max = 0.05
|
|
|
|
var buff_tick_frame = 0
|
|
|
|
|
|
|
|
var delta_cache: float = 0
|
|
|
|
var delta_cache: float = 0
|
|
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
|
|
|
|
buff_tick_frame_max = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
func _process(delta):
|
|
|
|
|
|
|
|
tick(delta)
|
|
|
|
delta_cache += delta
|
|
|
|
delta_cache += delta
|
|
|
|
buff_tick_frame += 1
|
|
|
|
if delta_cache < delta_cache_max:
|
|
|
|
if buff_tick_frame < buff_tick_frame_max:
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
tick(delta_cache)
|
|
|
|
tick_update(delta_cache)
|
|
|
|
buff_tick_frame = 0
|
|
|
|
|
|
|
|
delta_cache = 0
|
|
|
|
delta_cache = 0
|
|
|
|
|
|
|
|
|
|
|
|
func tick(delta) -> void:
|
|
|
|
func tick(delta) -> void:
|
|
|
|
|
|
|
|
for buff_name in buff_map:
|
|
|
|
|
|
|
|
var buff_info = buff_map[buff_name]
|
|
|
|
|
|
|
|
if buff_info.duration_max == -1:
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
if buff_info.duration == 0:
|
|
|
|
|
|
|
|
trigger_buff_effect(buff_info, "second")
|
|
|
|
|
|
|
|
buff_info.duration += delta
|
|
|
|
|
|
|
|
if buff_info.duration >= buff_info.duration_max:
|
|
|
|
|
|
|
|
buff_info.duration = buff_info.duration_max
|
|
|
|
|
|
|
|
trigger_buff_effect_update(buff_info, delta)
|
|
|
|
|
|
|
|
remove_buff(buff_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func tick_update(delta) -> void:
|
|
|
|
for buff_name in buff_map:
|
|
|
|
for buff_name in buff_map:
|
|
|
|
var buff_info = buff_map[buff_name]
|
|
|
|
var buff_info = buff_map[buff_name]
|
|
|
|
if has_buff("pause") and buff_name != "pause" and !buff_info.ignore_pause:
|
|
|
|
if has_buff("pause") and buff_name != "pause" and !buff_info.ignore_pause:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
if buff_info.duration_max == -1:
|
|
|
|
trigger_buff_effect_update(buff_info, delta)
|
|
|
|
trigger_buff_effect(buff_info, "update")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
if buff_info.duration == 0:
|
|
|
|
|
|
|
|
trigger_buff_effect(buff_info, "second")
|
|
|
|
|
|
|
|
buff_info.duration += delta
|
|
|
|
|
|
|
|
if buff_info.duration >= buff_info.duration_max:
|
|
|
|
|
|
|
|
buff_info.duration = buff_info.duration_max
|
|
|
|
|
|
|
|
trigger_buff_effect(buff_info, "update")
|
|
|
|
|
|
|
|
remove_buff(buff_name)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
trigger_buff_effect(buff_info, "update")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func trigger_buff_effect(buff: BuffInfo, trigger_name: String):
|
|
|
|
func trigger_buff_effect(buff: BuffInfo, trigger_name: String):
|
|
|
|
var buff_name: String = buff.name
|
|
|
|
var buff_name: String = buff.name
|
|
|
|
var function_name: String = "on_%s_%s" % [trigger_name, buff_name]
|
|
|
|
var function_name: String = "on_%s_%s" % [trigger_name, buff_name]
|
|
|
|
if has_method(function_name):
|
|
|
|
if has_method(function_name):
|
|
|
|
var rate: float = buff.duration / buff.duration_max
|
|
|
|
call(function_name)
|
|
|
|
call(function_name, rate)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func trigger_buff_effect_update(buff: BuffInfo, delta: float):
|
|
|
|
|
|
|
|
var buff_name: String = buff.name
|
|
|
|
|
|
|
|
var function_name: String = "on_update_%s" % [buff_name]
|
|
|
|
|
|
|
|
if has_method(function_name):
|
|
|
|
|
|
|
|
var rate: float = 0
|
|
|
|
|
|
|
|
if buff.duration_max > 0:
|
|
|
|
|
|
|
|
rate = buff.duration / buff.duration_max
|
|
|
|
|
|
|
|
call(function_name, delta, rate)
|
|
|
|
|
|
|
|
|
|
|
|
func has_buff(buff_name: String) -> bool:
|
|
|
|
func has_buff(buff_name: String) -> bool:
|
|
|
|
return buff_name in buff_map
|
|
|
|
return buff_name in buff_map
|
|
|
|
@ -84,95 +88,107 @@ func remove_buff(buff_name: String):
|
|
|
|
|
|
|
|
|
|
|
|
#==具体实现==
|
|
|
|
#==具体实现==
|
|
|
|
#位移
|
|
|
|
#位移
|
|
|
|
func on_end_hit_back(_rate) -> void: status.set_status("hit_back_speed", 0)
|
|
|
|
func on_end_hit_back() -> void:
|
|
|
|
|
|
|
|
status.set_status("hit_back_speed", 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_hit_up(_rate) -> void: status.set_status("hit_up_speed", 0)
|
|
|
|
func on_end_hit_up() -> void:
|
|
|
|
|
|
|
|
status.set_status("hit_up_speed", 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_start_jumping(_rate) -> void: status.set_status("is_jumping", true)
|
|
|
|
func on_start_jumping() -> void:
|
|
|
|
|
|
|
|
status.set_status("is_jumping", true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_jumping(_rate) -> void: status.set_status("is_jumping", false)
|
|
|
|
func on_end_jumping() -> void:
|
|
|
|
|
|
|
|
status.set_status("is_jumping", false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_start_rising(_rate) -> void: status.set_status("is_rising", true)
|
|
|
|
func on_start_rising() -> void:
|
|
|
|
|
|
|
|
status.set_status("is_rising", true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_rising(_rate) -> void: status.set_status("is_rising", false)
|
|
|
|
func on_end_rising() -> void:
|
|
|
|
|
|
|
|
status.set_status("is_rising", false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_start_floating(_rate) -> void:
|
|
|
|
func on_start_floating() -> void:
|
|
|
|
status.set_status("is_floating", true)
|
|
|
|
status.set_status("is_floating", true)
|
|
|
|
add_buff("rising", 0.1)
|
|
|
|
add_buff("rising", 0.1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_update_floating(_rate) -> void:
|
|
|
|
func on_update_floating(_delta, _rate) -> void:
|
|
|
|
if not status.is_on_floor or status.is_rising:
|
|
|
|
if not status.is_on_floor or status.is_rising:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
remove_buff("floating")
|
|
|
|
remove_buff("floating")
|
|
|
|
add_buff("stagger", 3)
|
|
|
|
add_buff("stagger", 3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_floating(_rate) -> void: status.set_status("is_floating", false)
|
|
|
|
func on_end_floating() -> void:
|
|
|
|
|
|
|
|
status.set_status("is_floating", false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#战斗状态
|
|
|
|
#战斗状态
|
|
|
|
func on_start_die(_rate) -> void:
|
|
|
|
func on_start_die() -> void:
|
|
|
|
status.set_status("is_dead", true)
|
|
|
|
status.set_status("is_dead", true)
|
|
|
|
SignalManager.character_die.emit(status.id)
|
|
|
|
SignalManager.character_die.emit(status.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_die(_rate) -> void: add_buff("die2", -1)
|
|
|
|
func on_end_die() -> void:
|
|
|
|
|
|
|
|
add_buff("die2", -1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_update_die2(_rate) -> void: if status.is_on_floor and not status.is_rising: remove_buff("die2")
|
|
|
|
func on_update_die2(_delta, _rate) -> void:
|
|
|
|
|
|
|
|
if status.is_on_floor and not status.is_rising: remove_buff("die2")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_die2(_rate) -> void:
|
|
|
|
func on_end_die2() -> void:
|
|
|
|
effect.cast_corpse()
|
|
|
|
effect.cast_corpse()
|
|
|
|
Global.character_mgr.destroy_character(status.id)
|
|
|
|
Global.character_mgr.destroy_character(status.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_start_stagger(_rate) -> void:
|
|
|
|
func on_start_stagger() -> void:
|
|
|
|
status.set_status("is_stagger", true)
|
|
|
|
status.set_status("is_stagger", true)
|
|
|
|
status.set_skill_break_level_add(-1)
|
|
|
|
status.set_skill_break_level_add(-1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_stagger(_rate) -> void:
|
|
|
|
func on_end_stagger() -> void:
|
|
|
|
status.set_status("is_stagger", false)
|
|
|
|
status.set_status("is_stagger", false)
|
|
|
|
status.set_skill_break_level_add(0)
|
|
|
|
status.set_skill_break_level_add(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_shield_recover_cd(_rate) -> void: add_buff("shield_recover", -1)
|
|
|
|
func on_end_shield_recover_cd() -> void:
|
|
|
|
|
|
|
|
add_buff("shield_recover", -1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_update_shield_recover(_rate) -> void:
|
|
|
|
func on_update_shield_recover(delta, _rate) -> void:
|
|
|
|
var shield_add: float = get_process_delta_time() * status.cfg.shield.recover_speed
|
|
|
|
var shield_add: float = delta * status.cfg.shield.recover_speed
|
|
|
|
shield_add = min(status.shield_max - status.shield, shield_add)
|
|
|
|
shield_add = min(status.shield_max - status.shield, shield_add)
|
|
|
|
if shield_add == status.shield_max - status.shield:
|
|
|
|
if shield_add == status.shield_max - status.shield:
|
|
|
|
remove_buff("shield_recover")
|
|
|
|
remove_buff("shield_recover")
|
|
|
|
character.set_shield(status.shield + shield_add)
|
|
|
|
character.set_shield(status.shield + shield_add)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_mp_recover_cd(_rate) -> void: add_buff("mp_recover", 0.1)
|
|
|
|
func on_end_mp_recover_cd() -> void:
|
|
|
|
|
|
|
|
add_buff("mp_recover", 0.1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_update_mp_recover(_rate) -> void:
|
|
|
|
func on_update_mp_recover(delta, _rate) -> void:
|
|
|
|
var mp_add: float = get_process_delta_time() * status.cfg.mp.recover_speed
|
|
|
|
var mp_add: float = delta * status.cfg.mp.recover_speed
|
|
|
|
character.add_mp_sub(mp_add, false)
|
|
|
|
character.add_mp_sub(mp_add, false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_update_charging(_rate) -> void:
|
|
|
|
func on_update_charging(delta, _rate) -> void:
|
|
|
|
var mp_add: float = get_process_delta_time() * status.cfg.mp.charging_speed
|
|
|
|
var mp_add: float = delta * status.cfg.mp.charging_speed
|
|
|
|
character.add_mp_sub(mp_add, true)
|
|
|
|
character.add_mp_sub(mp_add, true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_stun_recover_break_cd(_rate) -> void: add_buff("stun_recover_break", -1)
|
|
|
|
func on_end_stun_recover_break_cd() -> void:
|
|
|
|
|
|
|
|
add_buff("stun_recover_break", -1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_update_stun_recover_break(_rate) -> void:
|
|
|
|
func on_update_stun_recover_break(delta, _rate) -> void:
|
|
|
|
var stun_sub: float = get_process_delta_time() * status.cfg.stun.recover_break_speed
|
|
|
|
var stun_sub: float = delta * status.cfg.stun.recover_break_speed
|
|
|
|
stun_sub = min(status.stun, stun_sub)
|
|
|
|
stun_sub = min(status.stun, stun_sub)
|
|
|
|
status.set_status("stun", status.stun - stun_sub)
|
|
|
|
status.set_status("stun", status.stun - stun_sub)
|
|
|
|
if status.stun == 0:
|
|
|
|
if status.stun == 0:
|
|
|
|
@ -180,21 +196,23 @@ func on_update_stun_recover_break(_rate) -> void:
|
|
|
|
status.set_status("is_stun", false)
|
|
|
|
status.set_status("is_stun", false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_stun_recover_cd(_rate) -> void: add_buff("stun_recover", -1)
|
|
|
|
func on_end_stun_recover_cd() -> void:
|
|
|
|
|
|
|
|
add_buff("stun_recover", -1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_update_stun_recover(_rate) -> void:
|
|
|
|
func on_update_stun_recover(delta, _rate) -> void:
|
|
|
|
var stun_sub: float = get_process_delta_time() * status.cfg.stun.recover_speed
|
|
|
|
var stun_sub: float = delta * status.cfg.stun.recover_speed
|
|
|
|
stun_sub = min(status.stun, stun_sub)
|
|
|
|
stun_sub = min(status.stun, stun_sub)
|
|
|
|
status.set_status("stun", status.stun - stun_sub)
|
|
|
|
status.set_status("stun", status.stun - stun_sub)
|
|
|
|
if status.stun == 0:
|
|
|
|
if status.stun == 0:
|
|
|
|
remove_buff("stun_recover")
|
|
|
|
remove_buff("stun_recover")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_update_weapon_index_change(rate) -> void: status.set_status("weapon_index_change_rate", rate)
|
|
|
|
func on_update_weapon_index_change(_delta, rate) -> void:
|
|
|
|
|
|
|
|
status.set_status("weapon_index_change", rate)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_weapon_index_change(_rate) -> void:
|
|
|
|
func on_end_weapon_index_change() -> void:
|
|
|
|
var weapon_index: int = status.weapon_index + status.weapon_index_change_dir
|
|
|
|
var weapon_index: int = status.weapon_index + status.weapon_index_change_dir
|
|
|
|
var weapon_len: int = len(status.weapon_list)
|
|
|
|
var weapon_len: int = len(status.weapon_list)
|
|
|
|
weapon_index = (weapon_index % weapon_len + weapon_len) % weapon_len
|
|
|
|
weapon_index = (weapon_index % weapon_len + weapon_len) % weapon_len
|
|
|
|
@ -203,43 +221,50 @@ func on_end_weapon_index_change(_rate) -> void:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#表现
|
|
|
|
#表现
|
|
|
|
func on_start_freeze(_rate) -> void:
|
|
|
|
func on_start_freeze() -> void:
|
|
|
|
status.set_status("is_pause", true)
|
|
|
|
status.set_status("is_pause", true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_freeze(_rate) -> void:
|
|
|
|
func on_end_freeze() -> void:
|
|
|
|
status.set_status("is_pause", false)
|
|
|
|
status.set_status("is_pause", false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_second_pause(_rate) -> void:
|
|
|
|
func on_second_pause() -> void:
|
|
|
|
status.set_status("is_pause", true)
|
|
|
|
status.set_status("is_pause", true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_pause(_rate) -> void:
|
|
|
|
func on_end_pause() -> void:
|
|
|
|
status.set_status("is_pause", false)
|
|
|
|
status.set_status("is_pause", false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_start_flash_white(_rate) -> void: status.set_status("flash_white_rate", 1)
|
|
|
|
func on_start_flash_white() -> void:
|
|
|
|
|
|
|
|
status.set_status("flash_white", 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_update_flash_white(rate) -> void: status.set_status("flash_white_rate", 1 - rate)
|
|
|
|
func on_update_flash_white(_delta, rate) -> void:
|
|
|
|
|
|
|
|
status.set_status("flash_white", 1 - rate)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_flash_white(_rate) -> void: status.set_status("flash_white_rate", 0)
|
|
|
|
func on_end_flash_white() -> void:
|
|
|
|
|
|
|
|
status.set_status("flash_white", 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_update_shake_x(rate) -> void:
|
|
|
|
func on_update_shake_x(_delta, rate) -> void:
|
|
|
|
var shake_rate: float = 0.5 * status.pause_time
|
|
|
|
var shake: float = 0.5 * status.pause_time
|
|
|
|
status.set_status("shake_offset", Vector3((sin(rate * PI * 6) - 0.5) * shake_rate, 0, 0))
|
|
|
|
status.set_status("shake_offset", Vector3((sin(rate * PI * 6) - 0.5) * shake, 0, 0))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_shake_x(_rate) -> void: status.set_status("shake_offset", Vector3.ZERO)
|
|
|
|
func on_end_shake_x() -> void:
|
|
|
|
|
|
|
|
status.set_status("shake_offset", Vector3.ZERO)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_start_deformation(_rate) -> void: status.set_status("deformation_rate", 1)
|
|
|
|
func on_start_deformation() -> void:
|
|
|
|
|
|
|
|
status.set_status("deformation", 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_update_deformation(rate) -> void: status.set_status("deformation_rate", 1 - rate)
|
|
|
|
func on_update_deformation(_delta, rate) -> void:
|
|
|
|
|
|
|
|
status.set_status("deformation", 1 - rate)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_end_deformation(_rate) -> void: status.set_status("deformation_rate", 0)
|
|
|
|
func on_end_deformation() -> void:
|
|
|
|
|
|
|
|
status.set_status("deformation", 0)
|
|
|
|
|