feat: 添加击晕状态相关功能

1. 新增击晕概率、抗性属性配置与组件字段
2. 实现击晕判定逻辑与视图特效播放
3. 增加击晕时技能CD暂停清零的处理
4. 配置默认击晕持续时间为2秒
This commit is contained in:
panFD
2026-06-12 21:34:39 +08:00
parent 3ea1a4d44c
commit 44ce6cd30c
7 changed files with 65 additions and 2 deletions

View File

@@ -49,6 +49,8 @@ export class HeroAttrsComp extends ecs.Comp {
critical_res: number = 0; // 暴击抗性
freeze_chance: number = 0; // 冰冻概率
freeze_res: number = 0; // 冰冻抗性
stun_chance: number = 0; // 击晕概率
stun_res: number = 0; // 击晕抗性
knockback_chance: number = 0; // 击退概率
knockback_distance: number = 0; // 击退距离强化
knockback_res: number = 0; // 击退抗性
@@ -61,6 +63,7 @@ export class HeroAttrsComp extends ecs.Comp {
frost_end_time: number = 0;
stun_end_time: number = 0;
boom: boolean = false; // 自爆怪
@@ -100,6 +103,7 @@ export class HeroAttrsComp extends ecs.Comp {
*/
initAttrs() {
this.frost_end_time = 0;
this.stun_end_time = 0;
}
/*******************基础属性管理********************/
@@ -162,11 +166,35 @@ export class HeroAttrsComp extends ecs.Comp {
const frostTime = FightSet.FROST_TIME * time;
this.frost_end_time = Math.max(this.frost_end_time, frostTime);
}
toStun(time: number=1) {
const stunTime = FightSet.STUN_TIME * time;
this.stun_end_time = Math.max(this.stun_end_time, stunTime);
// 击晕时 CD 清零
for (const key in this.skills) {
const skill = this.skills[key];
if (skill) {
skill.ccd = 0;
}
}
}
updateCD(dt: number){
// 如果处于冰冻状态,则技能 CD 暂停刷新
if (this.isFrost()) return;
// 如果处于击晕状态,则技能 CD 暂停刷新(且保持清零状态)
if (this.isStun()) {
for (const key in this.skills) {
const skill = this.skills[key];
if (skill) {
skill.ccd = 0;
}
}
return;
}
for (const key in this.skills) {
const skill = this.skills[key];
if (!skill) continue;
@@ -185,6 +213,9 @@ export class HeroAttrsComp extends ecs.Comp {
isFrost(): boolean {
return this.frost_end_time > 0
}
isStun(): boolean {
return this.stun_end_time > 0
}
getSkillLevel(skillId: number): number {
if (!skillId) return 0;
return this.skills[skillId]?.lv ?? 0;
@@ -352,6 +383,8 @@ export class HeroAttrsComp extends ecs.Comp {
this.critical_res = 0;
this.freeze_chance = 0;
this.freeze_res = 0;
this.stun_chance = 0;
this.stun_res = 0;
this.knockback_chance = 0;
this.knockback_distance = 0;
this.knockback_res = 0;
@@ -363,6 +396,7 @@ export class HeroAttrsComp extends ecs.Comp {
this.boom = false;
this.frost_end_time = 0;
this.stun_end_time = 0;
// 重置技能距离缓存
this.maxSkillDistance = 0;
@@ -406,7 +440,12 @@ export class HeroBuffSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
attrsComp.frost_end_time = 0;
}
}
if(attrsComp.stun_end_time > 0){
attrsComp.stun_end_time -= 0.1;
if(attrsComp.stun_end_time <= 0){
attrsComp.stun_end_time = 0;
}
}
}
void e;
}