fix(skill): 修复技能相关的显示与逻辑问题
1. 调整技能预制体的锚点和攻击偏移参数 2. 修复SkillView.ts的代码格式与导入错误 3. 补充fixed类型技能的动画结束销毁逻辑
This commit is contained in:
@@ -142,7 +142,7 @@
|
|||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
"x": 0.5,
|
"x": 0.5,
|
||||||
"y": 0
|
"y": 0.5
|
||||||
},
|
},
|
||||||
"_id": ""
|
"_id": ""
|
||||||
},
|
},
|
||||||
@@ -231,7 +231,7 @@
|
|||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
"x": 0.5,
|
"x": 0.5,
|
||||||
"y": 0
|
"y": 0.5
|
||||||
},
|
},
|
||||||
"_id": ""
|
"_id": ""
|
||||||
},
|
},
|
||||||
@@ -252,7 +252,7 @@
|
|||||||
"__id__": 11
|
"__id__": 11
|
||||||
},
|
},
|
||||||
"atk_x": 20,
|
"atk_x": 20,
|
||||||
"atk_y": 0,
|
"atk_y": 30,
|
||||||
"_id": ""
|
"_id": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -314,7 +314,7 @@
|
|||||||
"_offset": {
|
"_offset": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 59.9
|
"y": -0.1
|
||||||
},
|
},
|
||||||
"_size": {
|
"_size": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { _decorator, Animation, CCInteger, Collider2D, Contact2DType, UITransfor
|
|||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
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 { SDataCom } from "./SDataCom";
|
||||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||||
import { DamageQueueHelper } from "../hero/DamageQueueComp";
|
import { DamageQueueHelper } from "../hero/DamageQueueComp";
|
||||||
@@ -24,11 +24,11 @@ export class SkillView extends CCComp {
|
|||||||
|
|
||||||
private debugMode: boolean = false;
|
private debugMode: boolean = false;
|
||||||
|
|
||||||
anim:Animation=null;
|
anim: Animation = null;
|
||||||
group:number=0;
|
group: number = 0;
|
||||||
SConf:SkillConfig=null;
|
SConf: SkillConfig = null;
|
||||||
sData:SDataCom=null;
|
sData: SDataCom = null;
|
||||||
s_uuid:number=1001
|
s_uuid: number = 1001
|
||||||
private collider: Collider2D = null; // 缓存碰撞体引用
|
private collider: Collider2D = null; // 缓存碰撞体引用
|
||||||
private pendingDisableCollider: boolean = false;
|
private pendingDisableCollider: boolean = false;
|
||||||
private isDisposing: boolean = false;
|
private isDisposing: boolean = false;
|
||||||
@@ -41,25 +41,25 @@ export class SkillView extends CCComp {
|
|||||||
this.pendingDisableCollider = false;
|
this.pendingDisableCollider = false;
|
||||||
this.isDisposing = false;
|
this.isDisposing = false;
|
||||||
this.collider = this.getComponent(Collider2D);
|
this.collider = this.getComponent(Collider2D);
|
||||||
if(this.collider) {
|
if (this.collider) {
|
||||||
this.collider.group = this.group;
|
this.collider.group = this.group;
|
||||||
this.collider.off(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
this.collider.off(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||||
this.collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
this.collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||||
this.collider.enabled = this.SConf?.EType === EType.collision;
|
this.collider.enabled = this.SConf?.EType === EType.collision;
|
||||||
}
|
}
|
||||||
if(this.node.getComponent(Animation)){
|
if (this.node.getComponent(Animation)) {
|
||||||
let anim = 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.off(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
||||||
anim.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
anim.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
||||||
|
|
||||||
// 对象池复用时,需要手动播放默认动画(因为 Play On Load 只在首次生效)
|
// 对象池复用时,需要手动播放默认动画(因为 Play On Load 只在首次生效)
|
||||||
if (anim.defaultClip) {
|
if (anim.defaultClip) {
|
||||||
anim.play(anim.defaultClip.name);
|
anim.play(anim.defaultClip.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
|
onBeginContact(seCol: Collider2D, oCol: Collider2D) {
|
||||||
if (!this.sData || !this.SConf) {
|
if (!this.sData || !this.SConf) {
|
||||||
mLogger.warn(this.debugMode, 'SkillView', '[SkillView] onBeginContact 缺少 sData 或 SConf,忽略此次碰撞');
|
mLogger.warn(this.debugMode, 'SkillView', '[SkillView] onBeginContact 缺少 sData 或 SConf,忽略此次碰撞');
|
||||||
return;
|
return;
|
||||||
@@ -126,17 +126,23 @@ export class SkillView extends CCComp {
|
|||||||
this.apply_damage(targetView, this.sData.hit_count)
|
this.apply_damage(targetView, this.sData.hit_count)
|
||||||
}
|
}
|
||||||
|
|
||||||
onAnimationFinished(){
|
onAnimationFinished() {
|
||||||
// animationEnd 类型:动画结束后再关闭碰撞并销毁
|
// animationEnd 类型:动画结束后再关闭碰撞并销毁
|
||||||
if(this.SConf.EType==EType.animationEnd){
|
if (this.SConf.EType == EType.animationEnd) {
|
||||||
this.disable_collider_now();
|
this.disable_collider_now();
|
||||||
this.ent.destroy()
|
this.ent.destroy()
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
// fixed 类型不移动,无法通过移动完成销毁;动画播完作为兜底销毁时机
|
||||||
|
if (this.SConf.RType == RType.fixed) {
|
||||||
|
this.disable_collider_now();
|
||||||
|
this.ent.destroy()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 动画帧事件 atk:仅负责开启一帧碰撞窗口,不负责伤害与计数
|
// 动画帧事件 atk:仅负责开启一帧碰撞窗口,不负责伤害与计数
|
||||||
public atk(args:any){
|
public atk(args: any) {
|
||||||
if(!this.SConf) return;
|
if (!this.SConf) return;
|
||||||
if(this.SConf.EType==EType.collision) return
|
if (this.SConf.EType == EType.collision) return
|
||||||
if (this.enable_collider_safely()) {
|
if (this.enable_collider_safely()) {
|
||||||
mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf?.name}] 开启碰撞检测`);
|
mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf?.name}] 开启碰撞检测`);
|
||||||
this.scheduleOnce(() => {
|
this.scheduleOnce(() => {
|
||||||
@@ -179,7 +185,7 @@ export class SkillView extends CCComp {
|
|||||||
finalRatio,
|
finalRatio,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
close_collider(){
|
close_collider() {
|
||||||
if (!this.collider) return;
|
if (!this.collider) return;
|
||||||
if (this.pendingDisableCollider && !this.collider.enabled) return;
|
if (this.pendingDisableCollider && !this.collider.enabled) return;
|
||||||
this.pendingDisableCollider = true;
|
this.pendingDisableCollider = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user