From 40c430546c758be11dc3869250afc3de14b5574e Mon Sep 17 00:00:00 2001 From: panw Date: Thu, 27 Nov 2025 16:31:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=8B=B1=E9=9B=84=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=87=BB=E6=9D=80=E8=AE=A1=E6=95=B0=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=94=BB=E5=87=BB=E7=B3=BB=E7=BB=9F=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加英雄击杀计数功能,用于统计英雄击杀敌人数量 优化HeroAtkSystem中变量命名,将attackerTAttrsComp改为更清晰的CAttrsComp 修复荆棘伤害可能导致英雄死亡时未触发死亡表现的问题 --- assets/script/game/hero/HeroAtkSystem.ts | 20 ++++++++++++++++---- assets/script/game/hero/HeroAttrsComp.ts | 3 ++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index 976e289f..6c89adb0 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -134,7 +134,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd if (!TAttrsComp || TAttrsComp.is_dead) return reDate; const caster = damageEvent.caster; - const attackerTAttrsComp = caster?.ent?.get(HeroAttrsComp); + const CAttrsComp = caster?.ent?.get(HeroAttrsComp); // 获取技能配置 const skillConf = SkillSet[damageEvent.s_uuid]; @@ -165,7 +165,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd const casterCritDmg = damageEvent.Attrs[Attrs.CRITICAL_DMG] || 0; damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE + casterCritDmg) / 100)); reDate.isCrit=true; - attackerTAttrsComp?.useValueTalByAttr(Attrs.CRITICAL); // 清除施法者的暴击buff + CAttrsComp?.useValueTalByAttr(Attrs.CRITICAL); // 清除施法者的暴击buff } // 护盾吸收 @@ -180,7 +180,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd // 使用施法者的击退概率属性(damageEvent.Attrs 快照) // 击退成功后需要清理施法者的相关天赋buff const isBack = this.checkChance(damageEvent.Attrs[Attrs.BACK_CHANCE] || 0); - if (isBack) attackerTAttrsComp?.useValueTalByAttr(Attrs.BACK_CHANCE); + if (isBack) CAttrsComp?.useValueTalByAttr(Attrs.BACK_CHANCE); // ✅ 触发视图层表现(伤害数字、受击动画、后退) @@ -189,6 +189,8 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd // 检查死亡 if (TAttrsComp.hp <= 0) { + // 增加被击杀计数 + if (caster) CAttrsComp.Attrs.killed_count++; this.doDead(target); // ✅ 触发死亡视图表现 if (targetView) { @@ -204,7 +206,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd return reDate; } check_thorns(TAttrsComp:HeroAttrsComp, caster: ecs.Entity, damage:number) { - // 检查目标是否有反伤属性 + // 检查目标是否有反伤属性,这里受伤的时时施法者 if (!caster||damage<=0) return; let thornsDamage=0; thornsDamage=TAttrsComp.Attrs[Attrs.THORNS]||0+TAttrsComp.useCountValTal(Attrs.THORNS); @@ -217,6 +219,16 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd let CView=caster.get(HeroViewComp); // ✅ 触发视图层表现(伤害数字、受击动画、后退) if (CView) CView.do_atked(thornsDmg, false, SkillSet[5000].uuid, false); + // 检查死亡 + if (CAttrs.hp <= 0) { + this.doDead(caster); + // 增加击杀计数 + if (caster) TAttrsComp.Attrs.killed_count++; + // ✅ 触发死亡视图表现 + if (CView) { + CView.do_dead(); + } + } } /** * 详细伤害计算核心方法 diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index d4238700..36c7c8b0 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -65,7 +65,7 @@ export class HeroAttrsComp extends ecs.Comp { // ==================== 计数统计 ==================== atk_count: number = 0; // 攻击次数 atked_count: number = 0; // 被攻击次数 - + killed_count:number=0; // 注意:技能数据已迁移到 HeroSkillsComp,不再存储在这里 start(){ @@ -561,6 +561,7 @@ export class HeroAttrsComp extends ecs.Comp { this.is_kalami = false; this.atk_count = 0; this.atked_count = 0; + this.killed_count =0; }