fix(skill): 修复火焰击技能碰撞检测和消失逻辑

调整技能 atk_f2 的预制体位置、缩放和尺寸,以匹配新的碰撞体设置。
将技能 6004(火焰击)的 hit_num 从 1 改为 6,允许多次命中。
在 SkillView 中优化碰撞检测逻辑,增加 isDisposing 状态防止销毁后误触发。
修复 close_collider 方法的逻辑,确保碰撞体能立即关闭。
为 EType 枚举添加详细注释,明确其职责。
This commit is contained in:
walkpan
2026-03-15 22:25:51 +08:00
parent 0b85345369
commit ad9799d938
3 changed files with 31 additions and 26 deletions

View File

@@ -98,7 +98,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -5.881,
"x": 13.997,
"y": 40.545,
"z": 0
},
@@ -111,8 +111,8 @@
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 2,
"y": -1,
"x": 3,
"y": -2,
"z": 1
},
"_mobility": 0,
@@ -210,8 +210,6 @@
"__id__": 0
},
"fileId": "3arqAMBz1MvoXBzeDaL5M/",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
@@ -527,7 +525,7 @@
"_size": {
"__type__": "cc.Size",
"width": 100,
"height": 100
"height": 199.9
},
"_id": ""
},

View File

@@ -89,13 +89,12 @@ export enum RType {
fixed = 2, //固定起点
fixedEnd = 3, //固定终点
}
export enum EType {
animationEnd = 0,
timeEnd = 1,
distanceEnd = 2,
collision = 3,
countEnd = 4,
//EType 只负责动画什么时候结束,碰撞体什么时候消失不管,但是消失前一定要关闭碰撞体
export enum EType {
animationEnd = 0, //碰撞够也不消失,动画结束才消失
timeEnd = 1, //碰撞够也不消失,时间到才消失
distanceEnd = 2, //碰撞够也不消失,距离到才消失
collision = 3, //碰撞次数够就消失
}
//debuff类型
@@ -230,7 +229,7 @@ export const SkillSet: Record<number, SkillConfig> = {
},
6004: {
uuid:6004,name:"火焰击",sp_name:"atk_f2",icon:"1173",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"max",DTType:DTType.single,
ap:100,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
ap:100,hit_num:6,hit:1,hitcd:0.2,speed:720,with:0,
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
buffs:[],debuffs:[],info:"对前方目标造成150%攻击的伤害",
},

View File

@@ -31,6 +31,7 @@ export class SkillView extends CCComp {
s_uuid:number=1001
private collider: Collider2D = null; // 缓存碰撞体引用
private pendingDisableCollider: boolean = false;
private isDisposing: boolean = false;
private attackFrameCount: number = 0; // 攻击帧计数器
private maxAttackFrames: number = 1; // 最大攻击帧数,可配置
// 已命中目标追踪,防止重复伤害
@@ -40,6 +41,7 @@ export class SkillView extends CCComp {
this.anim = this.node.getComponent(Animation)
this.node.active = true;
this.pendingDisableCollider = false;
this.isDisposing = false;
this.collider = this.getComponent(Collider2D);
if(this.collider) {
this.collider.group = this.group;
@@ -61,6 +63,12 @@ export class SkillView extends CCComp {
this.attackFrameCount = 0; // 重置攻击帧计数
}
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
if (!this.sData || !this.SConf) {
mLogger.warn(this.debugMode, 'SkillView', '[SkillView] onBeginContact 缺少 sData 或 SConf忽略此次碰撞');
return;
}
if (this.isDisposing) return;
if (!this.node || !this.node.activeInHierarchy) return;
// 安全获取双方信息用于日志
const casterName = this.sData.caster?.ent?.get(HeroAttrsComp)?.hero_name ?? '未知施法者';
const casterEid = this.sData.casterEid;
@@ -68,11 +76,6 @@ export class SkillView extends CCComp {
const targetName = targetView?.ent?.get(HeroAttrsComp)?.hero_name ?? '非英雄对象';
const targetEid = targetView?.ent?.eid ?? '未知EID';
mLogger.log(this.debugMode, 'SkillView', `[skillView] 碰撞1 [${this.sData.caster.box_group}][${casterName}][${casterEid}]的[${seCol.group}]:[${this.SConf.name}][${this.ent.eid}]碰撞了 [${oCol.group}]:[ ${targetName}][${targetEid}]`);
// 基本空值与同组过滤
if (!this.sData || !this.SConf) {
mLogger.warn(this.debugMode, 'SkillView', '[SkillView] onBeginContact 缺少 sData 或 SConf忽略此次碰撞');
return;
}
if (oCol.group === seCol.group) return;
if (this.pendingDisableCollider) return;
// 不是 HeroViewComp直接忽略
@@ -93,6 +96,7 @@ export class SkillView extends CCComp {
onAnimationFinished(){
if(this.SConf.EType==EType.animationEnd){
this.disable_collider_now();
this.ent.destroy()
}
}
@@ -159,14 +163,17 @@ export class SkillView extends CCComp {
}
}
close_collider(){
if (!this.collider || this.pendingDisableCollider) return;
if (!this.collider) return;
if (this.pendingDisableCollider && !this.collider.enabled) return;
this.pendingDisableCollider = true;
this.scheduleOnce(() => {
if (this.collider && this.collider.isValid) {
this.collider.enabled = false;
}
this.pendingDisableCollider = false;
}, 0);
if (this.collider.isValid) {
this.collider.enabled = false;
}
this.pendingDisableCollider = false;
}
private disable_collider_now() {
this.isDisposing = true;
this.close_collider();
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
@@ -176,6 +183,7 @@ export class SkillView extends CCComp {
this.collider.enabled = false;
}
this.pendingDisableCollider = false;
this.isDisposing = false;
if (this.anim) {
this.anim.off(Animation.EventType.FINISHED, this.onAnimationFinished, this);
}