feat: 添加击退效果相关逻辑
1. 新增击退概率、击退距离、击退抗性属性配置 2. 实现击退判定与击退位移逻辑,整合进受击流程 3. 重构后退方法支持自定义击退距离参数
This commit is contained in:
@@ -26,6 +26,7 @@ export enum FightSet {
|
|||||||
MERGE_MAX=3, //英雄最大等级
|
MERGE_MAX=3, //英雄最大等级
|
||||||
MERGE_NEED=3, //英雄升级需要的英雄数
|
MERGE_NEED=3, //英雄升级需要的英雄数
|
||||||
// BACK_RANG=30,//后退范围
|
// BACK_RANG=30,//后退范围
|
||||||
|
BACK_RANG=30,//后退范围
|
||||||
FiIGHT_TIME=30,//战斗时间
|
FiIGHT_TIME=30,//战斗时间
|
||||||
// BACK_CHANCE=40,//击退概率
|
// BACK_CHANCE=40,//击退概率
|
||||||
FROST_TIME=3,//冰冻时间
|
FROST_TIME=3,//冰冻时间
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ export enum Attrs {
|
|||||||
|
|
||||||
// ==================== 特殊效果属性 ====================
|
// ==================== 特殊效果属性 ====================
|
||||||
freeze_chance = "freeze_chance", // 冰冻概率
|
freeze_chance = "freeze_chance", // 冰冻概率
|
||||||
|
knockback_chance = "knockback_chance", // 击退概率
|
||||||
|
knockback_distance = "knockback_distance", // 击退距离强化
|
||||||
|
knockback_res = "knockback_res", // 击退抗性
|
||||||
invincible_time = "invincible_time",// 无敌时间
|
invincible_time = "invincible_time",// 无敌时间
|
||||||
puncture = "puncture", // 穿刺次数
|
puncture = "puncture", // 穿刺次数
|
||||||
wfuny = "wfuny", // 风怒
|
wfuny = "wfuny", // 风怒
|
||||||
|
|||||||
@@ -191,7 +191,12 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
// 冰冻判定
|
// 冰冻判定
|
||||||
const freezeChance = damageEvent.Attrs[Attrs.freeze_chance] || 0;
|
const freezeChance = damageEvent.Attrs[Attrs.freeze_chance] || 0;
|
||||||
const isFrost = !TAttrsComp.isFrost() && this.checkChance(freezeChance);
|
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) {
|
if (targetView) {
|
||||||
targetView.do_atked(damage, isCrit, damageEvent.s_uuid, false);
|
targetView.do_atked(damage, isCrit, damageEvent.s_uuid, false);
|
||||||
targetView.playEnd(skillConf.endAnm);
|
targetView.playEnd(skillConf.endAnm);
|
||||||
@@ -199,6 +204,9 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
TAttrsComp.toFrost();
|
TAttrsComp.toFrost();
|
||||||
targetView.in_iced(TAttrsComp.frost_end_time);
|
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; // 暴击率
|
critical: number = 0; // 暴击率
|
||||||
freeze_chance: number = 0; // 冰冻概率
|
freeze_chance: number = 0; // 冰冻概率
|
||||||
|
knockback_chance: number = 0; // 击退概率
|
||||||
|
knockback_distance: number = 0; // 击退距离强化
|
||||||
|
knockback_res: number = 0; // 击退抗性
|
||||||
crit_damage: number = 0; // 额外暴击伤害
|
crit_damage: number = 0; // 额外暴击伤害
|
||||||
puncture: number = 0; // 穿刺次数
|
puncture: number = 0; // 穿刺次数
|
||||||
wfuny: number = 0; // 风怒
|
wfuny: number = 0; // 风怒
|
||||||
@@ -297,6 +300,9 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
this.revive = undefined;
|
this.revive = undefined;
|
||||||
this.critical = 0;
|
this.critical = 0;
|
||||||
this.freeze_chance = 0;
|
this.freeze_chance = 0;
|
||||||
|
this.knockback_chance = 0;
|
||||||
|
this.knockback_distance = 0;
|
||||||
|
this.knockback_res = 0;
|
||||||
this.crit_damage = 0;
|
this.crit_damage = 0;
|
||||||
this.revived_count = 0;
|
this.revived_count = 0;
|
||||||
this.invincible_time = 0;
|
this.invincible_time = 0;
|
||||||
|
|||||||
@@ -483,32 +483,35 @@ export class HeroViewComp extends CCComp {
|
|||||||
private isBackingUp: boolean = false; // 🔥 添加后退状态标记
|
private isBackingUp: boolean = false; // 🔥 添加后退状态标记
|
||||||
|
|
||||||
//后退
|
//后退
|
||||||
back(){
|
back(distance: number = 0){
|
||||||
// 🔥 防止重复调用后退动画
|
// 🔥 防止重复调用后退动画
|
||||||
// if (this.isBackingUp) return;
|
if (this.isBackingUp) return;
|
||||||
// this.isBackingUp = true; // 🔥 设置后退状态
|
this.isBackingUp = true; // 🔥 设置后退状态
|
||||||
|
|
||||||
// if(this.model.fac==FacSet.MON) {
|
if(this.model.fac==FacSet.MON) {
|
||||||
// let tx=this.node.position.x+FightSet.BACK_RANG
|
// 基础击退距离,加上额外的距离强化
|
||||||
// if(tx > 320) tx=320
|
let dist = FightSet.BACK_RANG + distance;
|
||||||
// tween(this.node)
|
let tx=this.node.position.x + dist;
|
||||||
// .to(0.1, { position:v3(tx,this.node.position.y,0)})
|
if(tx > 320) tx=320;
|
||||||
// .call(() => {
|
tween(this.node)
|
||||||
// this.isBackingUp = false; // 🔥 动画完成后重置状态
|
.to(0.1, { position:v3(tx,this.node.position.y,0)})
|
||||||
// })
|
.call(() => {
|
||||||
// .start()
|
this.isBackingUp = false; // 🔥 动画完成后重置状态
|
||||||
// }
|
})
|
||||||
|
.start();
|
||||||
|
}
|
||||||
|
|
||||||
// if(this.model.fac==FacSet.HERO) {
|
if(this.model.fac==FacSet.HERO) {
|
||||||
// let tx=this.node.position.x-5
|
let dist = 5 + distance;
|
||||||
// if(tx < -320) tx=-320
|
let tx=this.node.position.x - dist;
|
||||||
// tween(this.node)
|
if(tx < -320) tx=-320;
|
||||||
// .to(0.1, { position:v3(tx,this.node.position.y,0)})
|
tween(this.node)
|
||||||
// .call(() => {
|
.to(0.1, { position:v3(tx,this.node.position.y,0)})
|
||||||
// this.isBackingUp = false; // 🔥 动画完成后重置状态
|
.call(() => {
|
||||||
// })
|
this.isBackingUp = false; // 🔥 动画完成后重置状态
|
||||||
// .start()
|
})
|
||||||
// }
|
.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 伤害计算和战斗逻辑已迁移到 HeroBattleSystem
|
// 伤害计算和战斗逻辑已迁移到 HeroBattleSystem
|
||||||
|
|
||||||
|
|||||||
@@ -216,6 +216,8 @@ export class Skill extends ecs.Entity {
|
|||||||
sDataCom.Attrs[Attrs.critical] = cAttrsComp.getRuntimeCritical() + sCrt;
|
sDataCom.Attrs[Attrs.critical] = cAttrsComp.getRuntimeCritical() + sCrt;
|
||||||
sDataCom.Attrs[Attrs.critical_damage] = cAttrsComp.getRuntimeCritDamageBonus();
|
sDataCom.Attrs[Attrs.critical_damage] = cAttrsComp.getRuntimeCritDamageBonus();
|
||||||
sDataCom.Attrs[Attrs.freeze_chance] = cAttrsComp.getRuntimeFreezeChance() + sFrz;
|
sDataCom.Attrs[Attrs.freeze_chance] = cAttrsComp.getRuntimeFreezeChance() + sFrz;
|
||||||
|
sDataCom.Attrs[Attrs.knockback_chance] = cAttrsComp.knockback_chance || 0;
|
||||||
|
sDataCom.Attrs[Attrs.knockback_distance] = cAttrsComp.knockback_distance || 0;
|
||||||
sDataCom.s_uuid=s_uuid
|
sDataCom.s_uuid=s_uuid
|
||||||
sDataCom.skill_lv = Math.max(0, skill_lv);
|
sDataCom.skill_lv = Math.max(0, skill_lv);
|
||||||
sDataCom.fac=cAttrsComp.fac
|
sDataCom.fac=cAttrsComp.fac
|
||||||
|
|||||||
Reference in New Issue
Block a user