From ad9799d9381f56afdafd9ca64785daf873fb2314 Mon Sep 17 00:00:00 2001 From: walkpan Date: Sun, 15 Mar 2026 22:25:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(skill):=20=E4=BF=AE=E5=A4=8D=E7=81=AB?= =?UTF-8?q?=E7=84=B0=E5=87=BB=E6=8A=80=E8=83=BD=E7=A2=B0=E6=92=9E=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E5=92=8C=E6=B6=88=E5=A4=B1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整技能 atk_f2 的预制体位置、缩放和尺寸,以匹配新的碰撞体设置。 将技能 6004(火焰击)的 hit_num 从 1 改为 6,允许多次命中。 在 SkillView 中优化碰撞检测逻辑,增加 isDisposing 状态防止销毁后误触发。 修复 close_collider 方法的逻辑,确保碰撞体能立即关闭。 为 EType 枚举添加详细注释,明确其职责。 --- assets/resources/game/skill/atk/atk_f2.prefab | 10 +++--- assets/script/game/common/config/SkillSet.ts | 15 ++++----- assets/script/game/skill/SkillView.ts | 32 ++++++++++++------- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/assets/resources/game/skill/atk/atk_f2.prefab b/assets/resources/game/skill/atk/atk_f2.prefab index 3e0a3e49..b4def6a1 100644 --- a/assets/resources/game/skill/atk/atk_f2.prefab +++ b/assets/resources/game/skill/atk/atk_f2.prefab @@ -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": "" }, diff --git a/assets/script/game/common/config/SkillSet.ts b/assets/script/game/common/config/SkillSet.ts index 4be6f117..f8a136fe 100644 --- a/assets/script/game/common/config/SkillSet.ts +++ b/assets/script/game/common/config/SkillSet.ts @@ -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 = { }, 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%攻击的伤害", }, diff --git a/assets/script/game/skill/SkillView.ts b/assets/script/game/skill/SkillView.ts index 06f5a55a..edea13ce 100644 --- a/assets/script/game/skill/SkillView.ts +++ b/assets/script/game/skill/SkillView.ts @@ -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); }