feat: 添加击退效果相关逻辑
1. 新增击退概率、击退距离、击退抗性属性配置 2. 实现击退判定与击退位移逻辑,整合进受击流程 3. 重构后退方法支持自定义击退距离参数
This commit is contained in:
@@ -191,7 +191,12 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
||||
// 冰冻判定
|
||||
const freezeChance = damageEvent.Attrs[Attrs.freeze_chance] || 0;
|
||||
const isFrost = !TAttrsComp.isFrost() && this.checkChance(freezeChance);
|
||||
// ✅ 触发视图层表现(伤害数字、受击动画、冰冻)
|
||||
|
||||
// 击退判定
|
||||
const knockbackChance = (damageEvent.Attrs[Attrs.knockback_chance] || 0) - (TAttrsComp.knockback_res || 0);
|
||||
const isKnockback = this.checkChance(knockbackChance);
|
||||
|
||||
// ✅ 触发视图层表现(伤害数字、受击动画、冰冻、击退)
|
||||
if (targetView) {
|
||||
targetView.do_atked(damage, isCrit, damageEvent.s_uuid, false);
|
||||
targetView.playEnd(skillConf.endAnm);
|
||||
@@ -199,6 +204,9 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
||||
TAttrsComp.toFrost();
|
||||
targetView.in_iced(TAttrsComp.frost_end_time);
|
||||
}
|
||||
if (isKnockback) {
|
||||
targetView.back(damageEvent.Attrs[Attrs.knockback_distance] || 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +43,9 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
// ==================== 特殊属性 ====================
|
||||
critical: number = 0; // 暴击率
|
||||
freeze_chance: number = 0; // 冰冻概率
|
||||
knockback_chance: number = 0; // 击退概率
|
||||
knockback_distance: number = 0; // 击退距离强化
|
||||
knockback_res: number = 0; // 击退抗性
|
||||
crit_damage: number = 0; // 额外暴击伤害
|
||||
puncture: number = 0; // 穿刺次数
|
||||
wfuny: number = 0; // 风怒
|
||||
@@ -297,6 +300,9 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.revive = undefined;
|
||||
this.critical = 0;
|
||||
this.freeze_chance = 0;
|
||||
this.knockback_chance = 0;
|
||||
this.knockback_distance = 0;
|
||||
this.knockback_res = 0;
|
||||
this.crit_damage = 0;
|
||||
this.revived_count = 0;
|
||||
this.invincible_time = 0;
|
||||
|
||||
@@ -483,32 +483,35 @@ export class HeroViewComp extends CCComp {
|
||||
private isBackingUp: boolean = false; // 🔥 添加后退状态标记
|
||||
|
||||
//后退
|
||||
back(){
|
||||
back(distance: number = 0){
|
||||
// 🔥 防止重复调用后退动画
|
||||
// if (this.isBackingUp) return;
|
||||
// this.isBackingUp = true; // 🔥 设置后退状态
|
||||
if (this.isBackingUp) return;
|
||||
this.isBackingUp = true; // 🔥 设置后退状态
|
||||
|
||||
// if(this.model.fac==FacSet.MON) {
|
||||
// let tx=this.node.position.x+FightSet.BACK_RANG
|
||||
// if(tx > 320) tx=320
|
||||
// tween(this.node)
|
||||
// .to(0.1, { position:v3(tx,this.node.position.y,0)})
|
||||
// .call(() => {
|
||||
// this.isBackingUp = false; // 🔥 动画完成后重置状态
|
||||
// })
|
||||
// .start()
|
||||
// }
|
||||
if(this.model.fac==FacSet.MON) {
|
||||
// 基础击退距离,加上额外的距离强化
|
||||
let dist = FightSet.BACK_RANG + distance;
|
||||
let tx=this.node.position.x + dist;
|
||||
if(tx > 320) tx=320;
|
||||
tween(this.node)
|
||||
.to(0.1, { position:v3(tx,this.node.position.y,0)})
|
||||
.call(() => {
|
||||
this.isBackingUp = false; // 🔥 动画完成后重置状态
|
||||
})
|
||||
.start();
|
||||
}
|
||||
|
||||
// if(this.model.fac==FacSet.HERO) {
|
||||
// let tx=this.node.position.x-5
|
||||
// if(tx < -320) tx=-320
|
||||
// tween(this.node)
|
||||
// .to(0.1, { position:v3(tx,this.node.position.y,0)})
|
||||
// .call(() => {
|
||||
// this.isBackingUp = false; // 🔥 动画完成后重置状态
|
||||
// })
|
||||
// .start()
|
||||
// }
|
||||
if(this.model.fac==FacSet.HERO) {
|
||||
let dist = 5 + distance;
|
||||
let tx=this.node.position.x - dist;
|
||||
if(tx < -320) tx=-320;
|
||||
tween(this.node)
|
||||
.to(0.1, { position:v3(tx,this.node.position.y,0)})
|
||||
.call(() => {
|
||||
this.isBackingUp = false; // 🔥 动画完成后重置状态
|
||||
})
|
||||
.start();
|
||||
}
|
||||
}
|
||||
// 伤害计算和战斗逻辑已迁移到 HeroBattleSystem
|
||||
|
||||
|
||||
Reference in New Issue
Block a user