From c6b5e1431f43108f0a81fb08cadcc1007afb4d96 Mon Sep 17 00:00:00 2001 From: pan Date: Thu, 13 Aug 2026 15:36:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(skill):=20=E4=BF=AE=E5=A4=8D=E6=8A=80?= =?UTF-8?q?=E8=83=BD=E7=9B=B8=E5=85=B3=E7=9A=84=E6=98=BE=E7=A4=BA=E4=B8=8E?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 调整技能预制体的锚点和攻击偏移参数 2. 修复SkillView.ts的代码格式与导入错误 3. 补充fixed类型技能的动画结束销毁逻辑 --- assets/resources/game/skill/atk/atk.prefab | 8 ++-- assets/script/game/skill/SkillView.ts | 44 ++++++++++++---------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/assets/resources/game/skill/atk/atk.prefab b/assets/resources/game/skill/atk/atk.prefab index 71929c16..8f5e345b 100644 --- a/assets/resources/game/skill/atk/atk.prefab +++ b/assets/resources/game/skill/atk/atk.prefab @@ -142,7 +142,7 @@ "_anchorPoint": { "__type__": "cc.Vec2", "x": 0.5, - "y": 0 + "y": 0.5 }, "_id": "" }, @@ -231,7 +231,7 @@ "_anchorPoint": { "__type__": "cc.Vec2", "x": 0.5, - "y": 0 + "y": 0.5 }, "_id": "" }, @@ -252,7 +252,7 @@ "__id__": 11 }, "atk_x": 20, - "atk_y": 0, + "atk_y": 30, "_id": "" }, { @@ -314,7 +314,7 @@ "_offset": { "__type__": "cc.Vec2", "x": 0, - "y": 59.9 + "y": -0.1 }, "_size": { "__type__": "cc.Size", diff --git a/assets/script/game/skill/SkillView.ts b/assets/script/game/skill/SkillView.ts index dbac88a1..2405fab2 100644 --- a/assets/script/game/skill/SkillView.ts +++ b/assets/script/game/skill/SkillView.ts @@ -2,7 +2,7 @@ import { _decorator, Animation, CCInteger, Collider2D, Contact2DType, UITransfor import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { HeroViewComp } from "../hero/HeroViewComp"; -import { DTType, EType, SkillConfig, SkillSet } from "../common/config/SkillSet"; +import { DTType, EType, RType, SkillConfig, SkillSet } from "../common/config/SkillSet"; import { SDataCom } from "./SDataCom"; import { HeroAttrsComp } from "../hero/HeroAttrsComp"; import { DamageQueueHelper } from "../hero/DamageQueueComp"; @@ -24,11 +24,11 @@ export class SkillView extends CCComp { private debugMode: boolean = false; - anim:Animation=null; - group:number=0; - SConf:SkillConfig=null; - sData:SDataCom=null; - s_uuid:number=1001 + anim: Animation = null; + group: number = 0; + SConf: SkillConfig = null; + sData: SDataCom = null; + s_uuid: number = 1001 private collider: Collider2D = null; // 缓存碰撞体引用 private pendingDisableCollider: boolean = false; private isDisposing: boolean = false; @@ -41,25 +41,25 @@ export class SkillView extends CCComp { this.pendingDisableCollider = false; this.isDisposing = false; this.collider = this.getComponent(Collider2D); - if(this.collider) { + if (this.collider) { this.collider.group = this.group; this.collider.off(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this); this.collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this); this.collider.enabled = this.SConf?.EType === EType.collision; } - if(this.node.getComponent(Animation)){ + if (this.node.getComponent(Animation)) { let anim = this.node.getComponent(Animation); - mLogger.log(this.debugMode, 'SkillView', "[SkillCom]:has anim",anim) + mLogger.log(this.debugMode, 'SkillView', "[SkillCom]:has anim", anim) anim.off(Animation.EventType.FINISHED, this.onAnimationFinished, this); anim.on(Animation.EventType.FINISHED, this.onAnimationFinished, this); - + // 对象池复用时,需要手动播放默认动画(因为 Play On Load 只在首次生效) if (anim.defaultClip) { anim.play(anim.defaultClip.name); } } } - onBeginContact (seCol: Collider2D, oCol: Collider2D) { + onBeginContact(seCol: Collider2D, oCol: Collider2D) { if (!this.sData || !this.SConf) { mLogger.warn(this.debugMode, 'SkillView', '[SkillView] onBeginContact 缺少 sData 或 SConf,忽略此次碰撞'); return; @@ -126,17 +126,23 @@ export class SkillView extends CCComp { this.apply_damage(targetView, this.sData.hit_count) } - onAnimationFinished(){ - // animationEnd 类型:动画结束后再关闭碰撞并销毁 - if(this.SConf.EType==EType.animationEnd){ + onAnimationFinished() { + // animationEnd 类型:动画结束后再关闭碰撞并销毁 + if (this.SConf.EType == EType.animationEnd) { this.disable_collider_now(); this.ent.destroy() - } + return; + } + // fixed 类型不移动,无法通过移动完成销毁;动画播完作为兜底销毁时机 + if (this.SConf.RType == RType.fixed) { + this.disable_collider_now(); + this.ent.destroy() + } } // 动画帧事件 atk:仅负责开启一帧碰撞窗口,不负责伤害与计数 - public atk(args:any){ - if(!this.SConf) return; - if(this.SConf.EType==EType.collision) return + public atk(args: any) { + if (!this.SConf) return; + if (this.SConf.EType == EType.collision) return if (this.enable_collider_safely()) { mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf?.name}] 开启碰撞检测`); this.scheduleOnce(() => { @@ -179,7 +185,7 @@ export class SkillView extends CCComp { finalRatio, ); } - close_collider(){ + close_collider() { if (!this.collider) return; if (this.pendingDisableCollider && !this.collider.enabled) return; this.pendingDisableCollider = true;