fix(skill): 修复技能相关的显示与逻辑问题

1. 调整技能预制体的锚点和攻击偏移参数
2. 修复SkillView.ts的代码格式与导入错误
3. 补充fixed类型技能的动画结束销毁逻辑
This commit is contained in:
pan
2026-08-13 15:36:57 +08:00
parent 7fa18329d6
commit c6b5e1431f
2 changed files with 29 additions and 23 deletions

View File

@@ -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",

View File

@@ -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,15 +41,15 @@ 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);
@@ -59,7 +59,7 @@ export class SkillView extends CCComp {
}
}
}
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;