refactor(game): 重构英雄数据结构和添加状态栏更新功能

- 将hero_data重命名为hero并调整属性结构
- 添加hp/mp初始值和最大值
- 新增暴击率(crt)属性
- 增加金币初始值
- 在MissionComp中添加状态栏(hp/mp/exp)更新逻辑
This commit is contained in:
walkpan
2026-01-02 19:21:41 +08:00
parent 8c88e84fae
commit 10e287c134
3 changed files with 2362 additions and 2183 deletions

View File

@@ -60,7 +60,7 @@ export class SingletonModuleComp extends ecs.Comp {
max_mission:4,//最大关卡
coin:0,
},
hero_data:{
hero:{
name:'',
path:'',
as:0,
@@ -68,20 +68,21 @@ export class SingletonModuleComp extends ecs.Comp {
lv:0,
exp:0,
exp_max:0,
hp:0,
ho_max:0,
mp:0,
mp_max:0,
hp:50,
hp_max:100,
mp:50,
mp_max:100,
def:0,
ap:0,
dis:0,
crt:0,
speed:0,
skills:[],
buff:[],
tal:[],
info:'',
},
gold: 100, // 金币数据MVVM绑定字段
gold: 200, // 金币数据MVVM绑定字段
};
vmAdd() {
VM.add(this.vmdata, "data");

View File

@@ -1,4 +1,4 @@
import { _decorator, Vec3,Animation, instantiate, Prefab, Node } from "cc";
import { _decorator, Vec3,Animation, instantiate, Prefab, Node, ProgressBar } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { smc } from "../common/SingletonModuleComp";
@@ -21,6 +21,10 @@ export class MissionComp extends CCComp {
// reward:number = 0;
// reward_num:number = 0;
rewards:any[]=[]
info:any=null
hp_bar:any=null
mp_bar:any=null
exp_bar:any=null
game_data:any={
exp:0,
gold:0,
@@ -33,6 +37,10 @@ export class MissionComp extends CCComp {
this.on(GameEvent.FightEnd,this.fight_end,this)
this.on(GameEvent.MissionEnd,this.mission_end,this)
this.on(GameEvent.DO_AD_BACK,this.do_ad,this)
this.info=this.node.getChildByName("info")
this.hp_bar=this.info.getChildByName("hp_bar").getChildByName("bar")
this.mp_bar=this.info.getChildByName("mp_bar").getChildByName("bar")
this.exp_bar=this.info.getChildByName("exp_bar").getChildByName("bar")
// this.on(GameEvent.CanUpdateLv,this.show_uplv_button,this)
}
protected update(dt: number): void {
@@ -41,8 +49,14 @@ export class MissionComp extends CCComp {
}
if(smc.mission.in_fight){
smc.vmdata.mission_data.fight_time+=dt
}
}
this.update_info()
}
update_info(){
this.hp_bar.getComponent(ProgressBar).progress=smc.vmdata.hero.hp/smc.vmdata.hero.hp_max
this.mp_bar.getComponent(ProgressBar).progress=smc.vmdata.hero.mp/smc.vmdata.hero.mp_max
this.exp_bar.getComponent(ProgressBar).progress=smc.vmdata.hero.exp/smc.vmdata.hero.exp_max
}
//奖励发放
do_reward(){
// 奖励发放
@@ -130,6 +144,7 @@ export class MissionComp extends CCComp {
smc.vmdata.mission_data.in_fight=false
smc.vmdata.mission_data.fight_time=0
smc.vmdata.mission_data.level=0
this.rewards=[] // 改为数组,用于存储掉落物品列表
// console.log("[MissionComp]局内数据初始化",smc.vmdata.mission_data)
}