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;