refactor(hero): 重构英雄属性同步机制和任务组件
- 在HeroAttrsComp中添加smc.updateHeroInfo调用以同步英雄数据 - 移除MissionComp中冗余的UI状态管理代码 - 在SingletonModuleComp中新增updateHeroInfo方法集中处理英雄数据同步 - 调整heroSet中英雄基础防御值为0 - 添加任务时间倒计时功能
This commit is contained in:
@@ -6,6 +6,9 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
|
||||
import { WxCloudApi } from "../wx_clound_client_api/WxCloudApi";
|
||||
import { GameEvent } from "./config/GameEvent";
|
||||
import * as exp from "constants";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { Attrs } from "./config/HeroAttrs";
|
||||
import { time } from "console";
|
||||
/**
|
||||
* 用远程数据覆盖本地数据(统一方法)
|
||||
* @param remoteData 远程数据(云端或本地调试)
|
||||
@@ -59,6 +62,7 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
level:1,//关卡等级
|
||||
max_mission:4,//最大关卡
|
||||
coin:0,
|
||||
time:15*60,//游戏时间
|
||||
},
|
||||
hero:{
|
||||
name:'',
|
||||
@@ -67,7 +71,8 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
type:0,
|
||||
lv:0,
|
||||
exp:0,
|
||||
exp_max:0,
|
||||
exp_max:100,
|
||||
exp_pre:0,
|
||||
hp:50,
|
||||
hp_max:100,
|
||||
mp:50,
|
||||
@@ -208,6 +213,38 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新主角英雄数据到 VM
|
||||
* @param heroAttrs 英雄属性组件
|
||||
*/
|
||||
updateHeroInfo(heroAttrs: HeroAttrsComp) {
|
||||
if (!heroAttrs || !heroAttrs.is_master) return;
|
||||
|
||||
const h = this.vmdata.hero;
|
||||
|
||||
// 基础信息
|
||||
h.name = heroAttrs.hero_name;
|
||||
h.type = heroAttrs.type;
|
||||
h.lv = heroAttrs.lv;
|
||||
|
||||
// 动态属性
|
||||
h.hp = Math.floor(heroAttrs.hp);
|
||||
h.mp = Math.floor(heroAttrs.mp);
|
||||
|
||||
// 计算属性
|
||||
h.hp_max = Math.floor(heroAttrs.Attrs[Attrs.HP_MAX] || 0);
|
||||
h.mp_max = Math.floor(heroAttrs.Attrs[Attrs.MP_MAX] || 0);
|
||||
h.def = Math.floor(heroAttrs.Attrs[Attrs.DEF] || 0);
|
||||
h.ap = Math.floor(heroAttrs.Attrs[Attrs.AP] || 0);
|
||||
h.dis = Math.floor(heroAttrs.Attrs[Attrs.DIS] || 0);
|
||||
h.speed = Math.floor(heroAttrs.Attrs[Attrs.SPEED] || 0);
|
||||
h.crt = Math.floor(heroAttrs.Attrs[Attrs.CRITICAL] || 0);
|
||||
h.as = Math.floor(heroAttrs.Attrs[Attrs.AS] || 0);
|
||||
}
|
||||
updateHeroExp(exp:number){
|
||||
this.vmdata.hero.exp += exp;
|
||||
this.vmdata.hero.exp_pre =Math.floor(this.vmdata.hero.exp/this.vmdata.hero.exp_max)
|
||||
}
|
||||
error(){
|
||||
oops.gui.toast("数据处理异常,请重试或重新登录")
|
||||
}
|
||||
|
||||
@@ -126,37 +126,37 @@ export const HeroInfo: Record<number, heroInfo> = {
|
||||
|
||||
// 刘邦 - 领导型战士(善于用人,知人善任)
|
||||
5001:{uuid:5001,name:"刘邦",path:"hk1", fac:FacSet.HERO, kind:1,as:1.5,
|
||||
type:HType.warrior,lv:1,hp:200,mp:200,def:9,ap:15,dis:100,speed:120,skills:[6001,6001],
|
||||
type:HType.warrior,lv:1,hp:200,mp:200,def:0,ap:15,dis:100,speed:120,skills:[6001,6001],
|
||||
buff:[],tal:[],info:"楚汉争霸领袖,领导统御型战士"},
|
||||
|
||||
// 荆轲 - 刺客(敏捷型,高速度和暴击率)
|
||||
5002:{uuid:5002,name:"荆轲",path:"hc1", fac:FacSet.HERO, kind:1,as:1.5,
|
||||
type:HType.assassin,lv:1,hp:80,mp:60,def:3,ap:22,dis:120,speed:180,skills:[6002,6001],
|
||||
type:HType.assassin,lv:1,hp:80,mp:60,def:0,ap:22,dis:120,speed:180,skills:[6002,6001],
|
||||
buff:[],tal:[],info:"战国刺客,刺杀专精敏捷型刺客"},
|
||||
|
||||
// 赵武灵王 - 远程射手(胡服骑射,机动型高移动速度和远程攻击)
|
||||
5005:{uuid:5005,name:"赵武灵王",path:"ha1", fac:FacSet.HERO, kind:2,as:1.5,
|
||||
type:HType.remote,lv:1,hp:100,mp:80,def:6,ap:18,dis:450,speed:140,skills:[6002,6001],
|
||||
type:HType.remote,lv:1,hp:100,mp:80,def:0,ap:18,dis:450,speed:140,skills:[6002,6001],
|
||||
buff:[],tal:[],info:"胡服骑射改革者,机动型高远程输出"},
|
||||
|
||||
// 张良 - 智谋法师(运筹帷幄,智谋型法师)
|
||||
5007:{uuid:5007,name:"张良",path:"hh1", fac:FacSet.HERO, kind:2,as:1.5,
|
||||
type:HType.mage,lv:1,hp:88,mp:135,def:5,ap:15,dis:350,speed:100,skills:[6002,6001],
|
||||
type:HType.mage,lv:1,hp:88,mp:135,def:0,ap:15,dis:350,speed:100,skills:[6002,6001],
|
||||
buff:[],tal:[],info:"运筹帷幄谋士,智谋型法师"},
|
||||
|
||||
// 屈原 - 元素法师(离骚诗韵,元素型高魔法输出)
|
||||
5008:{uuid:5008,name:"屈原",path:"hm1", fac:FacSet.HERO, kind:2,as:1.5,
|
||||
type:HType.mage,lv:1,hp:85,mp:140,def:4,ap:16,dis:400,speed:90,skills:[6002,6001],
|
||||
type:HType.mage,lv:1,hp:85,mp:140,def:0,ap:16,dis:400,speed:90,skills:[6002,6001],
|
||||
buff:[],tal:[],info:"离骚诗韵,元素型高魔法输出"},
|
||||
|
||||
// 孙膑 - 谋略法师(兵法谋略,谋略型法师)
|
||||
5009:{uuid:5009,name:"孙膑",path:"hm2", fac:FacSet.HERO, kind:2,as:1.5,
|
||||
type:HType.mage,lv:1,hp:92,mp:135,def:6,ap:14,dis:420,speed:95,skills:[6002,6001],
|
||||
type:HType.mage,lv:1,hp:92,mp:135,def:0,ap:14,dis:420,speed:95,skills:[6002,6001],
|
||||
buff:[],tal:[],info:"兵法谋略,谋略型法师"},
|
||||
|
||||
// 萧何 - 后勤辅助(后勤保障,后勤型辅助)
|
||||
5010:{uuid:5010,name:"萧何",path:"hz1", fac:FacSet.HERO, kind:2,as:1.5,
|
||||
type:HType.support,lv:1,hp:115,mp:145,def:10,ap:8,dis:380,speed:105,skills:[6002,6001],
|
||||
type:HType.support,lv:1,hp:115,mp:145,def:0,ap:8,dis:380,speed:105,skills:[6002,6001],
|
||||
buff:[],tal:[],info:"后勤保障,后勤型辅助"},
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user