特效性能

master
chendian 8 months ago
parent 072113046a
commit 88a35fd5c2

@ -155,7 +155,7 @@ func on_update_shield_recover(_rate) -> void:
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", -1) func on_end_mp_recover_cd(_rate) -> void: add_buff("mp_recover", 0.1)
func on_update_mp_recover(_rate) -> void: func on_update_mp_recover(_rate) -> void:

@ -127,7 +127,10 @@ func _cast_attack_particle(index: int, is_attach: bool) -> void:
_cast_particle(attack_particle, is_attach, Vector3.ZERO, Vector3.ZERO) _cast_particle(attack_particle, is_attach, Vector3.ZERO, Vector3.ZERO)
func _cast_particle(resource: Resource, is_attach: bool, offset: Vector3, scale: Vector3) -> void: func _cast_particle(resource: Resource, is_attach: bool, offset: Vector3, effect_scale: Vector3) -> void:
if not is_attach:
Global.effect_mgr.cast_particle(resource, character.pos() + offset + status.basic_offset, Vector3.ZERO, effect_scale)
return
if !resource: if !resource:
print("未配置技能特效") print("未配置技能特效")
return return
@ -136,8 +139,8 @@ func _cast_particle(resource: Resource, is_attach: bool, offset: Vector3, scale:
if not new_particle.is_billboard: if not new_particle.is_billboard:
var angle: float = Util.dir_angle(status.skill_dir) var angle: float = Util.dir_angle(status.skill_dir)
new_particle.rotation.y = angle if is_right else -angle new_particle.rotation.y = angle if is_right else -angle
if scale: if effect_scale:
new_particle.scale = scale new_particle.scale = effect_scale
new_particle.scale.x = abs(new_particle.scale.x) * (1 if is_right else -1) new_particle.scale.x = abs(new_particle.scale.x) * (1 if is_right else -1)
if offset: if offset:
new_particle.position = offset new_particle.position = offset
@ -145,8 +148,6 @@ func _cast_particle(resource: Resource, is_attach: bool, offset: Vector3, scale:
if not new_particle.is_ground: if not new_particle.is_ground:
new_particle.position = status.basic_offset new_particle.position = status.basic_offset
add_child(new_particle) add_child(new_particle)
if !is_attach:
_release_effect(new_particle)
func release_effect(): func release_effect():

@ -174,7 +174,7 @@ func cast_skill(cfg: SkillCfg, cast_dir: Vector2, action_key: String = "") -> vo
var animation_name: String = "animation_library/%s" % cfg.get_res_name() var animation_name: String = "animation_library/%s" % cfg.get_res_name()
play(animation_name, -1, Setting.animation_speed_scale) play(animation_name, -1, Setting.animation_speed_scale)
seek(0.05, true, true) seek(0, true, true)
battle.on_skill_cast(cfg.get_res_name()) battle.on_skill_cast(cfg.get_res_name())

@ -2,11 +2,15 @@ extends Node3D
class_name EffectBase class_name EffectBase
@export var lifetime: float = 1 @export var lifetime: float = 1
@export var is_billboard: bool
@export var is_ground: bool
var resource_name: String
var lifetime_now: float var lifetime_now: float
var is_pause: bool = false var is_pause: bool = false
var rate: float var rate: float
signal effect_destroy(resource_name: String)
func _ready(): func _ready():
on_ready() on_ready()
@ -24,6 +28,7 @@ func _process(delta) -> void:
return return
lifetime_now -= delta lifetime_now -= delta
if lifetime_now <= 0: if lifetime_now <= 0:
effect_destroy.emit(resource_name)
queue_free() queue_free()
return return
rate = lifetime_now / lifetime rate = lifetime_now / lifetime

@ -1,8 +1,6 @@
extends EffectBase extends EffectBase
class_name Particle class_name Particle
@export var is_billboard: bool
@export var is_ground: bool
var particle_list: Array[GPUParticles3D] = [] var particle_list: Array[GPUParticles3D] = []
var particle_speed_scale_list: Array[float] = [] var particle_speed_scale_list: Array[float] = []

@ -106,5 +106,5 @@ func collect() -> void:
Enum.EPtType.HP: target.add_hp(value) Enum.EPtType.HP: target.add_hp(value)
Enum.EPtType.MP: target.add_mp_sub(value, true) Enum.EPtType.MP: target.add_mp_sub(value, true)
_: pass _: pass
target.cast_particle(ResourceManager.particle_pt_collect, true) target.cast_particle(ResourceManager.particle_pt_collect, false)
Global.item_mgr.destroy_pt(self) Global.item_mgr.destroy_pt(self)

@ -1,22 +1,38 @@
extends Node3D extends Node3D
class_name EffectManager class_name EffectManager
var effect_count_max: int = 10
var effect_count_dict: Dictionary = {}
func _ready(): func _ready():
Global.effect_mgr = self Global.effect_mgr = self
SignalManager.effect_create.connect(on_effect_create) SignalManager.effect_create.connect(on_effect_create)
func on_effect_create(effect: Node3D): func on_effect_create(effect: Node3D):
add_child(effect) add_child(effect)
func cast_particle(resource: Resource, pos: Vector3, direction = Vector3.UP) -> void: func cast_particle(resource: Resource, pos: Vector3, direction = Vector3.ZERO, effect_scale: Vector3 = Vector3.ZERO) -> void:
var new_particle: Particle = resource.instantiate() as Particle var resource_name = resource.resource_path
add_child(new_particle) if not resource_name in effect_count_dict:
new_particle.position = pos effect_count_dict[resource_name] = 0
if effect_count_dict[resource_name] >= effect_count_max:
return
var new_effect: EffectBase = resource.instantiate() as EffectBase
new_effect.resource_name = resource_name
new_effect.effect_destroy.connect(_on_effect_destroy)
effect_count_dict[resource_name] += 1
add_child(new_effect)
new_effect.position = pos
if direction:
if direction.abs().angle_to(Vector3.RIGHT) < 0.01: if direction.abs().angle_to(Vector3.RIGHT) < 0.01:
direction.z = 0.1 direction.z = 0.1
if direction.angle_to(Vector3.UP) > 0.01 and (-direction).angle_to(Vector3.UP) > 0.01: if direction.angle_to(Vector3.UP) > 0.01 and (-direction).angle_to(Vector3.UP) > 0.01:
new_particle.look_at(pos - direction) new_effect.look_at(pos - direction)
else: else:
new_particle.rotation.x = deg_to_rad(-90) new_effect.rotation.x = deg_to_rad(-90)
if effect_scale:
new_effect.scale = effect_scale
func _on_effect_destroy(resource_name) -> void:
effect_count_dict[resource_name] -= 1

@ -14,10 +14,12 @@ class_name Headbar
@onready var pos_lable: Label = (%PosLabel as Label) @onready var pos_lable: Label = (%PosLabel as Label)
@onready var role_lable: Label = (%RoleLabel as Label) @onready var role_lable: Label = (%RoleLabel as Label)
var is_show_debug_info: bool
func set_debug_info_show(is_show: bool) -> void: func set_debug_info_show(is_show: bool) -> void:
is_show_debug_info = is_show
var debug_info: Control = (%DebugInfo as Control) var debug_info: Control = (%DebugInfo as Control)
debug_info.visible = is_show debug_info.visible = is_show_debug_info
func set_length(hp: float) -> void: func set_length(hp: float) -> void:
@ -70,28 +72,44 @@ func on_ai_alert_changed(value):
alert_bar.visible = value > 0 alert_bar.visible = value > 0
func on_stun_changed(value): stun_bar.value = value func on_stun_changed(value):
if is_show_debug_info:
stun_bar.value = value
func on_stun_max_changed(value): stun_bar.max_value = value func on_stun_max_changed(value):
if is_show_debug_info:
stun_bar.max_value = value
func on_mp_changed(value): mp_bar.value = value func on_mp_changed(value):
if is_show_debug_info:
mp_bar.value = value
func on_mp_max_changed(value): mp_bar.max_value = value func on_mp_max_changed(value):
if is_show_debug_info:
mp_bar.max_value = value
func on_mp_sub_changed(value): mp_sub_bar.value = value func on_mp_sub_changed(value):
if is_show_debug_info:
mp_sub_bar.value = value
func on_mp_sub_max_changed(value): mp_sub_bar.max_value = value func on_mp_sub_max_changed(value):
if is_show_debug_info:
mp_sub_bar.max_value = value
func on_pos2d_changed(value): pos_lable.text = "(%.2f,%.2f)"%[value.x, value.y] func on_pos2d_changed(value):
if is_show_debug_info:
pos_lable.text = "(%.2f,%.2f)"%[value.x, value.y]
func on_ai_role_changed(value): role_lable.text = str(value) func on_ai_role_changed(value):
if is_show_debug_info:
role_lable.text = str(value)
func on_hit_text(value: String): func on_hit_text(value: String):

Loading…
Cancel
Save