refactor(英雄属性): 重构属性系统为扁平结构并移除技能组件
- 将 Attrs 枚举从数字索引改为字符串键值对,直接映射到 HeroAttrsComp 的字段 - 删除 HeroSkillsComp 组件,将攻击和技能计时器移至 HeroAttrsComp - 移除复杂的属性类型映射和初始化函数,简化属性访问逻辑 - 更新 HeroViewComp 以直接使用模型字段而非通过 Attrs 枚举 - 重命名 NeAttrs 为 Debuff 并调整相关配置接口
This commit is contained in:
@@ -8,8 +8,7 @@ import { smc } from "../common/SingletonModuleComp";
|
||||
import { EAnmConf, SkillSet,} from "../common/config/SkillSet";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { TooltipTypes } from "../common/config/GameSet";
|
||||
import { Attrs, } from "../common/config/HeroAttrs";
|
||||
import { TooltipTypes } from "../common/config/GameSet";
|
||||
import { HeroAttrsComp } from "./HeroAttrsComp";
|
||||
import { Tooltip } from "../skill/Tooltip";
|
||||
import { timedCom } from "../skill/timedCom";
|
||||
@@ -113,7 +112,6 @@ export class HeroViewComp extends CCComp {
|
||||
this.top_node = this.node.getChildByName("top");
|
||||
// let hp_y = this.node.getComponent(UITransform).height+10;
|
||||
// this.top_node.setPosition(0, hp_y, 0);
|
||||
smc.updateHeroInfo(this.model)
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +160,7 @@ export class HeroViewComp extends CCComp {
|
||||
// }
|
||||
|
||||
if (this.model.dirty_shield) {
|
||||
this.show_shield(this.model.shield, this.model.Attrs[Attrs.SHIELD_MAX]);
|
||||
this.show_shield(this.model.shield, this.model.shield_max);
|
||||
this.model.dirty_shield = false;
|
||||
}
|
||||
}
|
||||
@@ -186,7 +184,7 @@ export class HeroViewComp extends CCComp {
|
||||
this.lastBarUpdateTime = Date.now() / 1000;
|
||||
// 不再基于血量是否满来决定显示状态,只更新进度条
|
||||
let hp=this.model.hp;
|
||||
let hp_max=this.model.Attrs[Attrs.HP_MAX];
|
||||
let hp_max=this.model.hp_max;
|
||||
// mLogger.log(this.debugMode, 'HeroViewComp', "hp_show",hp,hp_max)
|
||||
|
||||
let targetProgress = hp / hp_max;
|
||||
@@ -209,18 +207,7 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
/** 显示魔法值 */
|
||||
private mp_show() {
|
||||
this.lastBarUpdateTime = Date.now() / 1000;
|
||||
if(!this.top_node.active) return
|
||||
let mp=this.model.mp;
|
||||
let mp_max=this.model.Attrs[Attrs.MP_MAX];
|
||||
mLogger.log(this.debugMode, 'HeroViewComp', "mp_show",mp,mp_max)
|
||||
this.top_node.getChildByName("mp").getComponent(ProgressBar).progress = mp / mp_max;
|
||||
this.scheduleOnce(() => {
|
||||
this.top_node.getChildByName("mp").getChildByName("mpb").getComponent(ProgressBar).progress = mp / mp_max;
|
||||
}, 0.15);
|
||||
}
|
||||
|
||||
|
||||
/** 升级特效 */
|
||||
private lv_up() {
|
||||
@@ -342,7 +329,7 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
add_shield(shield:number){
|
||||
// 护盾数据更新由 Model 层处理,这里只负责视图表现
|
||||
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.shield_max);
|
||||
}
|
||||
|
||||
health(hp: number = 0) {
|
||||
@@ -369,7 +356,7 @@ export class HeroViewComp extends CCComp {
|
||||
this.model.is_count_dead=false
|
||||
this.as.do_buff();
|
||||
this.status_change("idle");
|
||||
this.model.hp =this.model.Attrs[Attrs.HP_MAX]*50/100;
|
||||
this.model.hp =this.model.hp_max*50/100;
|
||||
this.top_node.active=false
|
||||
this.lastBarUpdateTime=0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user