refactor(hero): 简化伤害队列和动画处理逻辑
移除伤害队列中的冗余字段,将受击动画播放移至伤害触发时统一处理,提高代码可维护性并消除重复逻辑。
This commit is contained in:
@@ -56,8 +56,6 @@ export class HeroViewComp extends CCComp {
|
||||
private damageQueue: Array<{
|
||||
damage: number,
|
||||
isCrit: boolean,
|
||||
delay: number,
|
||||
anm:string,
|
||||
}> = [];
|
||||
private isProcessingDamage: boolean = false;
|
||||
private damageInterval: number = 0.01; // 伤害数字显示间隔
|
||||
@@ -479,8 +477,10 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
// 视图层表现
|
||||
let SConf=SkillSet[s_uuid]
|
||||
const hitAnm = EAnmConf[SConf?.DAnm]?.path || "atked";
|
||||
if (isBack) this.back()
|
||||
this.showDamage(damage, isCrit, SConf.DAnm);
|
||||
this.in_atked(hitAnm, this.model.fac==FacSet.HERO?1:-1);
|
||||
this.showDamage(damage, isCrit);
|
||||
}
|
||||
|
||||
private isBackingUp: boolean = false; // 🔥 添加后退状态标记
|
||||
@@ -535,13 +535,10 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
/** 显示伤害数字 */
|
||||
|
||||
showDamage(damage: number, isCrit: boolean,DAnm:number) {
|
||||
let anm=EAnmConf[DAnm].path // DAnm和EAnm共用设定数组
|
||||
showDamage(damage: number, isCrit: boolean) {
|
||||
this.damageQueue.push({
|
||||
damage,
|
||||
isCrit,
|
||||
delay: this.damageInterval,
|
||||
anm
|
||||
});
|
||||
}
|
||||
|
||||
@@ -552,7 +549,7 @@ export class HeroViewComp extends CCComp {
|
||||
this.isProcessingDamage = true;
|
||||
const damageInfo = this.damageQueue.shift()!;
|
||||
|
||||
this.showDamageImmediate(damageInfo.damage, damageInfo.isCrit,damageInfo.anm);
|
||||
this.showDamageImmediate(damageInfo.damage, damageInfo.isCrit);
|
||||
|
||||
// 设置延时处理下一个伤
|
||||
this.scheduleOnce(() => {
|
||||
@@ -561,11 +558,10 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
|
||||
/** 立即显示伤害效果 */
|
||||
private showDamageImmediate(damage: number, isCrit: boolean, anm:string="atked") {
|
||||
private showDamageImmediate(damage: number, isCrit: boolean) {
|
||||
if (!this.model) return;
|
||||
|
||||
this.hp_show();
|
||||
this.in_atked(anm, this.model.fac==FacSet.HERO?1:-1);
|
||||
if (isCrit) {
|
||||
this.hp_tip(TooltipTypes.crit, damage.toFixed(0));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user