From b965c889611c03fd47673d402c02aaf918b6d391 Mon Sep 17 00:00:00 2001 From: panw Date: Tue, 25 Nov 2025 16:45:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=8B=B1=E9=9B=84=E5=B1=9E=E6=80=A7):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0HP/MP=E5=9F=BA=E7=A1=80=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=96=B9=E6=B3=95=E5=B9=B6=E7=A7=BB=E9=99=A4?= =?UTF-8?q?health=E6=96=B9=E6=B3=95=E5=86=97=E4=BD=99=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加add_hp、add_mp和add_shield方法用于管理英雄基础属性 移除HeroViewComp.health方法中不再使用的is_num参数 恢复TalComp中HP和MP天赋效果的处理逻辑 --- assets/script/game/hero/HeroAttrsComp.ts | 27 ++++++++++++++++++++++++ assets/script/game/hero/HeroViewComp.ts | 2 +- assets/script/game/hero/TalComp.ts | 12 +++++------ 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index e00272a8..67ccff60 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -3,6 +3,7 @@ import { Attrs, AttrsType, BType, NeAttrs } from "../common/config/HeroAttrs"; import { BuffConf } from "../common/config/SkillSet"; import { HeroInfo, AttrSet } from "../common/config/heroSet"; import { HeroSkillsComp } from "./HeroSkills"; +import { HeroViewComp } from "./HeroViewComp"; interface talTrigger{ @@ -117,7 +118,33 @@ export class HeroAttrsComp extends ecs.Comp { } } } + /*******************基础属性管理********************/ + add_hp(value:number,isValue:boolean){ + let addValue = value; + if(!isValue){ + addValue = value * this.Attrs[Attrs.HP_MAX]; + } + let heroView = this.ent.get(HeroViewComp); + if(heroView){ + heroView.health(addValue); + } + this.hp += addValue; + this.hp = Math.max(0, Math.min(this.hp, this.Attrs[Attrs.HP_MAX])); + } + add_mp(value:number,isValue:boolean){ + let addValue = value; + if(!isValue){ + addValue = value * this.Attrs[Attrs.MP_MAX]; + } + this.mp += addValue; + this.mp = Math.max(0, Math.min(this.mp, this.Attrs[Attrs.MP_MAX])); + } + add_shield(value:number,isValue:boolean){ + let addValue = value; + this.shield += addValue; + this.shield = Math.max(0, Math.min(this.shield, this.Attrs[Attrs.HP_MAX])); + } // ==================== BUFF 管理 ==================== /** * 添加 buff 效果(支持多次叠加) diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index c2f260f5..4e46faf8 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -289,7 +289,7 @@ export class HeroViewComp extends CCComp { if(this.model && this.model.shield>0) this.show_shield(this.model.shield, this.model.Attrs[Attrs.SHIELD_MAX]); } - health(hp: number = 0, is_num:boolean=true) { + health(hp: number = 0) { // 生命值更新由 Model 层处理,这里只负责视图表现 this.heathed(); this.hp_tip(TooltipTypes.health, hp.toFixed(0)); diff --git a/assets/script/game/hero/TalComp.ts b/assets/script/game/hero/TalComp.ts index 6a95b889..a50a6933 100644 --- a/assets/script/game/hero/TalComp.ts +++ b/assets/script/game/hero/TalComp.ts @@ -211,12 +211,12 @@ export class TalComp extends ecs.Comp { case TalEffet.LDMG: heroAttrs.addCountTal(TalEffet.LDMG, talent.value + talent.value_add); break; - // case TalEffet.HP: - // heroAttrs.addCountTal(TalEffet.HP, talent.value + talent.value_add); - // break; - // case TalEffet.MP: - // heroAttrs.addCountTal(TalEffet.MP, talent.value + talent.value_add); - // break; + case TalEffet.HP: + heroAttrs.add_hp(talent.value + talent.value_add,talent.vType == BType.VALUE); + break; + case TalEffet.MP: + heroAttrs.add_mp(talent.value + talent.value_add,talent.vType == BType.VALUE); + break; case TalEffet.WFUNY: heroAttrs.addCountTal(TalEffet.WFUNY, talent.value + talent.value_add); break;