refactor(英雄属性): 重构英雄升级逻辑并移除无用meta文件
将英雄升级逻辑从MissionComp迁移到HeroAttrsComp中集中处理 移除两个无用的TypeScript meta文件
This commit is contained in:
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.24",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "c363af64-ebfd-4697-ad86-0afef53353f0",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.24",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "c2a38591-59c8-44e4-b722-41dc6e8db0a1",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||||
|
import { GameEvent } from "../common/config/GameEvent";
|
||||||
import { Attrs, AttrsType, BType, NeAttrs } from "../common/config/HeroAttrs";
|
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";
|
||||||
@@ -73,6 +75,54 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
killed_count:number=0;
|
killed_count:number=0;
|
||||||
// 注意:技能数据已迁移到 HeroSkillsComp,不再存储在这里
|
// 注意:技能数据已迁移到 HeroSkillsComp,不再存储在这里
|
||||||
|
|
||||||
|
onLoad() {
|
||||||
|
// 监听升级事件
|
||||||
|
oops.message.on(GameEvent.CanUpdateLv, this.onLevelUp, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
onDestroy() {
|
||||||
|
oops.message.off(GameEvent.CanUpdateLv, this.onLevelUp, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理英雄升级逻辑
|
||||||
|
*/
|
||||||
|
onLevelUp(event: string, args: any) {
|
||||||
|
// 只有主角才响应升级事件
|
||||||
|
if (!this.is_master) return;
|
||||||
|
|
||||||
|
const newLv = args.lv;
|
||||||
|
if (newLv > this.lv) {
|
||||||
|
console.log(`[HeroAttrs] 英雄升级处理: Lv.${this.lv} -> Lv.${newLv}`);
|
||||||
|
this.lv = newLv;
|
||||||
|
|
||||||
|
// === 属性成长逻辑 (示例: 固定数值成长) ===
|
||||||
|
const hpGrow = 10;
|
||||||
|
const apGrow = 2;
|
||||||
|
const defGrow = 1;
|
||||||
|
|
||||||
|
this.base_hp += hpGrow;
|
||||||
|
this.base_ap += apGrow;
|
||||||
|
this.base_def += defGrow;
|
||||||
|
|
||||||
|
// 重新计算受影响的属性
|
||||||
|
this.recalculateSingleAttr(Attrs.HP_MAX);
|
||||||
|
this.recalculateSingleAttr(Attrs.AP);
|
||||||
|
this.recalculateSingleAttr(Attrs.DEF);
|
||||||
|
|
||||||
|
// 升级福利:回复 20% 最大生命值
|
||||||
|
const healRatio = 0.2;
|
||||||
|
const healAmount = Math.floor(this.Attrs[Attrs.HP_MAX] * healRatio);
|
||||||
|
this.add_hp(healAmount, true);
|
||||||
|
|
||||||
|
// 同步数据到全局
|
||||||
|
smc.updateHeroInfo(this);
|
||||||
|
|
||||||
|
// 简单的UI提示
|
||||||
|
// oops.gui.toast(`升级!HP+${hpGrow} AP+${apGrow}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
start(){
|
start(){
|
||||||
}
|
}
|
||||||
// ==================== BUFF 系统初始化 ====================
|
// ==================== BUFF 系统初始化 ====================
|
||||||
|
|||||||
@@ -55,15 +55,6 @@ export class MissionComp extends CCComp {
|
|||||||
onLevelUp(event: string, args: any) {
|
onLevelUp(event: string, args: any) {
|
||||||
console.log(`[MissionComp] 英雄升级到 ${args.lv} 级!`);
|
console.log(`[MissionComp] 英雄升级到 ${args.lv} 级!`);
|
||||||
|
|
||||||
// 同步等级到 ECS 组件,防止被 updateHeroInfo 覆盖回旧值
|
|
||||||
ecs.query(ecs.allOf(HeroAttrsComp)).forEach(e => {
|
|
||||||
const attrs = e.get(HeroAttrsComp);
|
|
||||||
if (attrs && attrs.is_master) {
|
|
||||||
attrs.lv = args.lv;
|
|
||||||
// 这里可以扩展:更新英雄属性,如 HP 上限等
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 触发奖励选择界面 (暂时留空)
|
// 触发奖励选择界面 (暂时留空)
|
||||||
this.showLevelUpReward();
|
this.showLevelUpReward();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user