diff --git a/assets/script/game/common/config/GameSet.ts b/assets/script/game/common/config/GameSet.ts index 9d36ea95..a0e0685e 100644 --- a/assets/script/game/common/config/GameSet.ts +++ b/assets/script/game/common/config/GameSet.ts @@ -147,4 +147,5 @@ export const TooltipTypes = { apup:7, hpup:8, addmp:9, + shield:10, } diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index e85024be..cafe072a 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -36,7 +36,7 @@ interface FinalData { @ecs.register('HeroAtkSystem') export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate { - private debugMode: boolean = false; // 是否启用调试模式 + private debugMode: boolean = true; // 是否启用调试模式 /** * 过滤器:处理拥有伤害队列的实体 @@ -164,8 +164,13 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd } if (this.debugMode) console.log("[HeroAtkSystem] after crit",damage) // 护盾吸收 - damage =Math.floor(this.absorbShield(TAttrsComp, damage)) + const shieldResult = this.absorbShield(TAttrsComp, damage); + damage = shieldResult.remainingDamage; if (this.debugMode) console.log("[HeroAtkSystem] after shield",damage) + // 显示护盾吸收飘字 + if (shieldResult.absorbedDamage > 0 && targetView) { + targetView.shield_tip(shieldResult.absorbedDamage); + } if (damage <= 0) return reDate; // 应用伤害到数据层 TAttrsComp.hp -= damage; @@ -429,10 +434,14 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd * * @param TAttrsComp 被攻击者的属性组件(包含当前护盾值) * @param damage 原始伤害值 - * @returns 剩余伤害值(护盾吸收后的结果) + * @returns {remainingDamage, absorbedDamage} 剩余伤害值和吸收的护盾值 */ - private absorbShield(TAttrsComp: HeroAttrsComp, damage: number): number { - if (TAttrsComp.shield <= 0) return damage; + private absorbShield(TAttrsComp: HeroAttrsComp, damage: number): {remainingDamage: number, absorbedDamage: number} { + + if (TAttrsComp.shield <= 0) { + console.log("[HeroAtkSystem] 护盾值小于等于0,无法吸收伤害"); + return {remainingDamage: damage, absorbedDamage: 0}; + }; if (TAttrsComp.shield >= damage) { TAttrsComp.shield -= damage; @@ -440,12 +449,15 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd TAttrsComp.shield = 0; TAttrsComp.Attrs[Attrs.SHIELD_MAX] = 0; } - return 0; + console.log(`[HeroAtkSystem] 护盾值完全吸收伤害 ${damage}`); + return {remainingDamage: 0, absorbedDamage: damage}; } else { + const absorbedDamage = TAttrsComp.shield; const remainingDamage = damage - TAttrsComp.shield; TAttrsComp.shield = 0; TAttrsComp.Attrs[Attrs.SHIELD_MAX] = 0; - return remainingDamage; + console.log(`[HeroAtkSystem] 护盾值部分吸收伤害 ${absorbedDamage}`); + return {remainingDamage, absorbedDamage}; } } diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index 3cf83e52..1d26f887 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -159,7 +159,6 @@ export class HeroAttrsComp extends ecs.Comp { addValue = value * this.Attrs[Attrs.HP_MAX] / 100; } this.shield += addValue; - this.shield = Math.max(0, Math.min(this.shield, this.Attrs[Attrs.HP_MAX])); this.dirty_shield = true; // 标记护盾需要更新 } // ==================== BUFF 管理 ==================== diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 881c3b7f..8b46e8f8 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -280,6 +280,11 @@ export class HeroViewComp extends CCComp { let pos = v3(x, ny, 0); tip.load(pos, type, value, s_uuid, this.node.parent); } + + /** 护盾吸收提示 */ + shield_tip(absorbed: number) { + this.hp_tip(TooltipTypes.life, absorbed.toFixed(0)); + } /** 治疗特效 */ private heathed() { diff --git a/assets/script/game/hero/SACastSystem.ts b/assets/script/game/hero/SACastSystem.ts index 34bbef3a..0b28c16c 100644 --- a/assets/script/game/hero/SACastSystem.ts +++ b/assets/script/game/hero/SACastSystem.ts @@ -9,6 +9,7 @@ import { smc } from "../common/SingletonModuleComp"; import { TalComp } from "./TalComp"; import { TalEffet, TriType } from "../common/config/TalSet"; import { BoxSet } from "../common/config/GameSet"; +import { Attrs } from "../common/config/HeroAttrs"; /** * ==================== 自动施法系统 ==================== @@ -389,14 +390,14 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat * 执行治疗技能 */ private executeHealSkill(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp, hset: HSSet): boolean { - const heroAttrs = casterEntity.get(HeroAttrsComp); + const hAttrsCom = casterEntity.get(HeroAttrsComp); const config = SkillSet[s_uuid]; if (!config) return false; - const targets = this.sHealTargets(heroView, heroAttrs, config); + const targets = this.sHealTargets(heroView, hAttrsCom, config); if (targets.length === 0) return false; - const healAmount = config.ap; + const healAmount = config.ap * hAttrsCom.Attrs[Attrs.HP_MAX]; const delay = 0.3; heroView.scheduleOnce(() => { @@ -417,14 +418,14 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat * 执行护盾技能 */ private executeShieldSkill(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp, hset: HSSet): boolean { - const heroAttrs = casterEntity.get(HeroAttrsComp); + const hAttrsCom = casterEntity.get(HeroAttrsComp); const config = SkillSet[s_uuid]; if (!config) return false; - const targets = this.sShieldTargets(heroView, heroAttrs, config); + const targets = this.sShieldTargets(heroView, hAttrsCom, config); if (targets.length === 0) return false; - const shieldAmount = config.ap; + const shieldAmount = config.ap * hAttrsCom.Attrs[Attrs.HP_MAX]; const delay = 0.3; heroView.scheduleOnce(() => { diff --git a/assets/script/game/skill/TooltipCom.ts b/assets/script/game/skill/TooltipCom.ts index 7f9016f1..a4ad8f7d 100644 --- a/assets/script/game/skill/TooltipCom.ts +++ b/assets/script/game/skill/TooltipCom.ts @@ -102,6 +102,15 @@ export class TooltipCom extends CCComp { this.scheduleOnce(()=>{ this.ent.destroy() },0.5) + break + case TooltipTypes.shield: + this.node.setSiblingIndex(110); + this.node.getChildByName("add_life").getChildByName("hp").getComponent(Label).string = this.value; + this.node.getChildByName("add_life").active=true; + this.scheduleOnce(()=>{ + this.ent.destroy() + },0.5) + break } // console.log("TooltipView start:",this.node.getSiblingIndex());