fix(技能): 修复技能升级配置和属性计算错误
- 将 SkillUpList 中的 buff_max 字段更正为 buff_hp - 移除 add_hp 和 add_shield 方法的 isValue 参数,改为直接使用数值 - 在 SCastSystem 中应用技能升级加成计算 AP、命中次数和 buff 值 - 为 HeroAttrsComp 添加 add_hp_max 和 add_ap 方法,替换原有的通用 buff 处理逻辑 - 简化伤害和技能效果应用逻辑,确保属性计算正确
This commit is contained in:
@@ -80,19 +80,9 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
}
|
||||
/*******************基础属性管理********************/
|
||||
|
||||
add_hp(value:number,isValue:boolean){
|
||||
add_hp(value:number){
|
||||
const oldHp = this.hp;
|
||||
let addValue = value;
|
||||
if(!isValue){
|
||||
addValue = value * this.hp_max / 100;
|
||||
}
|
||||
|
||||
// ✅ 数据层只负责数据修改,不调用视图层
|
||||
// let heroView = this.ent.get(HeroViewComp);
|
||||
// if(heroView && addValue > 0){
|
||||
// heroView.health(addValue);
|
||||
// }
|
||||
|
||||
this.hp += addValue;
|
||||
this.hp = Math.max(0, Math.min(this.hp, this.hp_max));
|
||||
this.dirty_hp = true; // ✅ 仅标记需要更新
|
||||
@@ -101,13 +91,9 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
}
|
||||
return addValue;
|
||||
}
|
||||
|
||||
add_shield(value:number,isValue:boolean){
|
||||
add_shield(value:number){
|
||||
const oldShield = this.shield;
|
||||
let addValue = value;
|
||||
if(!isValue){
|
||||
addValue = value * this.hp_max / 100;
|
||||
}
|
||||
this.shield += addValue;
|
||||
this.shield_max += addValue;
|
||||
if (this.shield < 0) this.shield = 0;
|
||||
@@ -117,44 +103,23 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
mLogger.log(this.debugMode, 'HeroAttrs', ` 护盾变更: ${this.hero_name}, 变化=${addValue.toFixed(1)}, ${oldShield.toFixed(1)} -> ${this.shield.toFixed(1)}`);
|
||||
}
|
||||
}
|
||||
// ==================== BUFF 管理 ====================
|
||||
/**
|
||||
* 添加 buff 效果
|
||||
* @param buffConf buff 配置
|
||||
*/
|
||||
addBuff(buffConf: BuffConf) {
|
||||
this.applyAttrChange(buffConf.buff, buffConf.value);
|
||||
if (this.debugMode) {
|
||||
mLogger.log(this.debugMode, 'HeroAttrs', `属性:${buffConf.buff}, 值:${buffConf.value}`);
|
||||
}
|
||||
add_hp_max(value:number){
|
||||
this.hp_max+=value
|
||||
this.hp+=value
|
||||
this.dirty_hp = true; // ✅ 仅标记需要更新
|
||||
return value
|
||||
}
|
||||
|
||||
|
||||
add_ap(value:number){
|
||||
this.ap +=value
|
||||
return value
|
||||
}
|
||||
|
||||
|
||||
toFrost(time: number=1) {
|
||||
this.frost_end_time += FightSet.FROST_TIME*time;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用属性修改应用
|
||||
* @param attr 属性名
|
||||
* @param value 变化值
|
||||
*/
|
||||
private applyAttrChange(attr: Attrs, value: number,) {
|
||||
const mappedAttr = attr === Attrs.hp ? Attrs.hp_max : (attr === Attrs.shield ? Attrs.shield_max : attr);
|
||||
if (mappedAttr !== Attrs.ap && mappedAttr !== Attrs.hp_max && mappedAttr !== Attrs.shield_max) return;
|
||||
if (mappedAttr === Attrs.ap) {
|
||||
this.ap = Math.max(0, this.ap + value);
|
||||
return;
|
||||
}
|
||||
if (mappedAttr === Attrs.hp_max) {
|
||||
this.hp_max = Math.max(1, this.hp_max + value);
|
||||
if (this.hp > this.hp_max) this.hp = this.hp_max;
|
||||
this.dirty_hp = true;
|
||||
return;
|
||||
}
|
||||
this.shield_max = Math.max(0, this.shield_max + value);
|
||||
this.shield = Math.max(0, Math.min(this.shield + value, this.shield_max));
|
||||
this.dirty_shield = true;
|
||||
}
|
||||
updateCD(dt: number){
|
||||
for (const key in this.skills) {
|
||||
const skill = this.skills[key];
|
||||
|
||||
Reference in New Issue
Block a user