refactor(skill): 优化技能系统实现和配置

- 删除未使用的ECS元文件和组件
- 修复技能视图和移动逻辑,添加调试日志
- 调整技能预制体配置和动画参数
- 简化技能加载和方向处理逻辑
- 新增技能6002并更新英雄配置
- 统一受击特效路径命名
This commit is contained in:
2025-10-31 16:42:57 +08:00
parent 65b1eebd84
commit 028a175df4
18 changed files with 200 additions and 558 deletions

View File

@@ -103,7 +103,7 @@ export class AtkConCom extends CCComp {
this.do_anim()
}
do_fixedStart(){
this.node.setPosition(this.startPos.x > 360?300:this.startPos.x,this.node.position.y,0)
this.node.setPosition(this.startPos.x,this.node.position.y,0)
this.do_anim()
}

View File

@@ -18,7 +18,7 @@ export class SMoveDataComp extends ecs.Comp {
/** 移动持续时间 */
duration: number = 0;
/** 移动方向 */
direction: Vec3 = v3();
scale: number = 1;
/** 是否自动销毁(到达目标后) */
autoDestroy: boolean = true;
s_uuid:number=0;
@@ -27,13 +27,14 @@ export class SMoveDataComp extends ecs.Comp {
this.targetPos.set(0, 0, 0);
this.speed = 500;
this.duration = 0;
this.direction.set(0, 0, 0);
this.scale=1;
this.autoDestroy = true;
}
rePos(originalStart:Vec3){
if(!originalStart){
return
}
console.log("[SMoveDataComp]rePos",originalStart,this.targetPos)
// 计算延长后的目标点坐标
const originalTarget = v3(this.targetPos.x, this.targetPos.y + BoxSet.ATK_Y);
const direction = new Vec3();

View File

@@ -36,7 +36,7 @@ export class Skill extends ecs.Entity {
load(startPos: Vec3, parent: Node, s_uuid: number, targetPos: Vec3,
caster:HeroViewComp) {
const config = SkillSet[s_uuid];
let casterAttrs=caster.ent.get(HeroAttrsComp).Attrs
if (!config) {
console.error("[Skill] 技能配置不存在:", s_uuid);
return;
@@ -51,20 +51,15 @@ export class Skill extends ecs.Entity {
}
// console.log("load skill startPos",startPos)
const node: Node = instantiate(prefab);
console.log("load skill node",node)
// console.log("load skill node",node)
node.parent = parent;
// 设置节点属性
node.setPosition(startPos);
if(casterAttrs.fac==FacSet.MON){
node.scale=v3(node.scale.x*-1,1,1)
}else{
if(casterAttrs.type==HType.warrior){
if(casterAttrs.node.scale<0){
node.scale=v3(node.scale.x*-1,node.scale.y,1)
}
}
if(caster.node.scale.x < 0){
node.setScale(v3(node.scale.x*-1,node.scale.y,1))
}
// 初始视图
const SView = node.getComponent(SkillView);
// 只设置必要的运行时属性,配置信息通过 SkillSet[uuid] 访问
@@ -78,14 +73,15 @@ export class Skill extends ecs.Entity {
sMoveCom.startPos=startPos
sMoveCom.targetPos=targetPos
sMoveCom.s_uuid=s_uuid
sMoveCom.scale=caster.node.scale.x < 0 ? -1 : 1
let casterAttrs=caster.ent.get(HeroAttrsComp).Attrs
// 初始化数据组件
const sDataCom = this.get(SDataCom);
sDataCom.group=caster.box_group
sDataCom.caster=caster
sDataCom.Attrs=casterAttrs
sDataCom.s_uuid=s_uuid
}
/** 模块资源释放 */

View File

@@ -21,13 +21,16 @@ export class SkillView extends CCComp {
@property({ type: CCInteger })
atk_x: number = 0
@property({ type: CCInteger })
atk_y: number = 0
@property({ type: CCInteger })
runType: number = 0 //技能运行类型 0-线性 1-贝塞尔 2-开始位置固定 3-目标位置固定
anim:Animation=null;
group:number=0;
SConf:any=null;
s_uuid:number=1001
start() {
console.log("SkillView start scale",this.node.scale)
this.SConf = SkillSet[this.s_uuid]
this.anim=this.node.getComponent(Animation)
this.node.active = true;
@@ -38,13 +41,14 @@ export class SkillView extends CCComp {
}
const SMove=this.ent.get(SMoveDataComp)
// 计算延长后的目标点坐标
SMove.rePos(v3(this.node.position.x + this.atk_x, this.node.position.y + this.atk_y))
switch(this.SConf.RType){
switch(this.runType){
case RType.linear:
SMove.rePos(v3(this.node.position.x + this.atk_x, this.node.position.y + this.atk_y))
this.do_linear(SMove.startPos,SMove.targetPos)
break
case RType.bezier:
SMove.rePos(v3(this.node.position.x + this.atk_x, this.node.position.y + this.atk_y))
this.do_bezier(SMove.startPos,SMove.targetPos)
break
case RType.fixed:
@@ -67,6 +71,7 @@ export class SkillView extends CCComp {
}
do_bezier(startPos:Vec3,targetPos:Vec3){
console.log("do_bezier",startPos,targetPos)
let bm=this.node.getComponent(BezierMove)
this.node.angle +=10
// bm.speed=700
@@ -75,6 +80,7 @@ export class SkillView extends CCComp {
bm.moveTo(targetPos)
}
do_linear(startPos:Vec3,targetPos:Vec3){
console.log("do_linear",startPos,targetPos)
let bm=this.node.getComponent(BezierMove)
let s_x=startPos.x
let s_y=startPos.y
@@ -95,11 +101,13 @@ export class SkillView extends CCComp {
bm.moveTo(targetPos);
}
do_fixedEnd(startPos:Vec3,targetPos:Vec3){
console.log("do_fixedEnd",startPos,targetPos)
this.node.setPosition(targetPos.x > 360?300:targetPos.x,this.node.position.y,0)
this.do_anim()
}
do_fixedStart(startPos:Vec3,targetPos:Vec3){
this.node.setPosition(startPos.x > 360?300:startPos.x,this.node.position.y,0)
console.log("do_fixedStart",startPos,targetPos)
this.node.setPosition(startPos.x,this.node.position.y,0)
this.do_anim()
}
do_anim(){
@@ -168,11 +176,12 @@ export class SkillView extends CCComp {
if (!this.SConf) return;
let sData=this.ent.get(SDataCom)
//伤害处理
let dmgData=target.ent.add(DmgDataCom)
target.ent.add(DmgDataCom)
let dmgData=target.ent.get(DmgDataCom)
dmgData.Attrs=sData.Attrs
dmgData.caster=sData.caster
dmgData.s_uuid=sData.s_uuid
console.log("[SkillCom]:apply_damage",target,sData,dmgData)
sData.hit_count++
// console.log("[SkillCom]:碰撞次数:技能次数:穿刺次数",this.hit_count,this.Config.hit,this.puncture)
if(sData.hit_count>=(this.SConf.hit+sData.Attrs[Attrs.PUNCTURE])&&(this.SConf.DTType!=DTType.range)&&(this.SConf.EType!=EType.animationEnd)&&(this.SConf.EType!=EType.timeEnd)) this.ent.destroy// 技能命中次数