refactor(英雄): 分离间隔效果的应用与视图更新逻辑
将间隔效果的处理逻辑从 HeroAttrsComp 中分离,改为由 HeroBuffSystem 统一收集并应用效果,同时触发 HeroViewComp 中的视觉反馈。这提高了关注点分离,使属性计算与视图更新解耦,便于维护和扩展新的间隔效果类型。
This commit is contained in:
@@ -14,6 +14,7 @@ import { Tooltip } from "../skill/Tooltip";
|
||||
import { timedCom } from "../skill/timedCom";
|
||||
import { HeroInfo, HType } from "../common/config/heroSet";
|
||||
import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
||||
import { Attrs } from "../common/config/HeroAttrs";
|
||||
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -344,6 +345,36 @@ export class HeroViewComp extends CCComp {
|
||||
this.lastBarUpdateTime = Date.now() / 1000;
|
||||
}
|
||||
|
||||
playIntervalEffect(attr: Attrs, value: number, s_uuid: number) {
|
||||
if (!this.node || !this.node.isValid) return;
|
||||
this.top_node.active = true;
|
||||
this.lastBarUpdateTime = Date.now() / 1000;
|
||||
if (attr === Attrs.hp) {
|
||||
if (value > 0) {
|
||||
this.heathed();
|
||||
this.hp_tip(TooltipTypes.health, value.toFixed(0), s_uuid);
|
||||
} else if (value < 0) {
|
||||
this.in_atked("atked", this.model?.fac == FacSet.HERO ? 1 : -1);
|
||||
this.hp_tip(TooltipTypes.life, Math.abs(value).toFixed(0), s_uuid);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (attr === Attrs.shield) {
|
||||
if (this.model && this.model.shield > 0) {
|
||||
this.show_shield(this.model.shield, this.model.shield_max);
|
||||
}
|
||||
this.hp_tip(TooltipTypes.health, Math.abs(value).toFixed(0), s_uuid);
|
||||
return;
|
||||
}
|
||||
if (attr === Attrs.IN_FROST && value > 0) {
|
||||
this.in_iced(0.3);
|
||||
return;
|
||||
}
|
||||
if (attr === Attrs.IN_STUN && value > 0) {
|
||||
this.in_yun(0.3);
|
||||
}
|
||||
}
|
||||
|
||||
alive(){
|
||||
// 重置复活标记 - 必须最先重置,否则status_change会被拦截
|
||||
this.model.is_reviving = false;
|
||||
|
||||
Reference in New Issue
Block a user