feat(英雄属性): 添加HP/MP基础属性管理方法并移除health方法冗余参数

添加add_hp、add_mp和add_shield方法用于管理英雄基础属性
移除HeroViewComp.health方法中不再使用的is_num参数
恢复TalComp中HP和MP天赋效果的处理逻辑
This commit is contained in:
2025-11-25 16:45:05 +08:00
parent b73d756106
commit b965c88961
3 changed files with 34 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ import { Attrs, AttrsType, BType, NeAttrs } from "../common/config/HeroAttrs";
import { BuffConf } from "../common/config/SkillSet"; import { BuffConf } from "../common/config/SkillSet";
import { HeroInfo, AttrSet } from "../common/config/heroSet"; import { HeroInfo, AttrSet } from "../common/config/heroSet";
import { HeroSkillsComp } from "./HeroSkills"; import { HeroSkillsComp } from "./HeroSkills";
import { HeroViewComp } from "./HeroViewComp";
interface talTrigger{ 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 管理 ====================
/** /**
* 添加 buff 效果(支持多次叠加) * 添加 buff 效果(支持多次叠加)

View File

@@ -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]); 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 层处理,这里只负责视图表现 // 生命值更新由 Model 层处理,这里只负责视图表现
this.heathed(); this.heathed();
this.hp_tip(TooltipTypes.health, hp.toFixed(0)); this.hp_tip(TooltipTypes.health, hp.toFixed(0));

View File

@@ -211,12 +211,12 @@ export class TalComp extends ecs.Comp {
case TalEffet.LDMG: case TalEffet.LDMG:
heroAttrs.addCountTal(TalEffet.LDMG, talent.value + talent.value_add); heroAttrs.addCountTal(TalEffet.LDMG, talent.value + talent.value_add);
break; break;
// case TalEffet.HP: case TalEffet.HP:
// heroAttrs.addCountTal(TalEffet.HP, talent.value + talent.value_add); heroAttrs.add_hp(talent.value + talent.value_add,talent.vType == BType.VALUE);
// break; break;
// case TalEffet.MP: case TalEffet.MP:
// heroAttrs.addCountTal(TalEffet.MP, talent.value + talent.value_add); heroAttrs.add_mp(talent.value + talent.value_add,talent.vType == BType.VALUE);
// break; break;
case TalEffet.WFUNY: case TalEffet.WFUNY:
heroAttrs.addCountTal(TalEffet.WFUNY, talent.value + talent.value_add); heroAttrs.addCountTal(TalEffet.WFUNY, talent.value + talent.value_add);
break; break;