逐步 去掉 主英雄设定

This commit is contained in:
panw
2025-08-05 10:32:18 +08:00
parent b6228f7747
commit 3db3cc78eb
6 changed files with 138 additions and 137 deletions

View File

@@ -19,7 +19,7 @@ export class Hero extends ecs.Entity {
HeroModel!: HeroModelComp;
HeroView!: HeroViewComp;
BattleMove!: BattleMoveComp;
vmHero:any={}
protected init() {
this.addComponents<ecs.Comp>(
BattleMoveComp,
@@ -38,29 +38,26 @@ export class Hero extends ecs.Entity {
}
super.destroy();
}
hart_load(uuid:number=5004) {
console.log("主体加载")
var path = "game/heros/"+HeroInfo[uuid].path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
var scene = smc.map.MapView.scene;
node.parent = scene.entityLayer!.node!
let pos=HeroPos[0].pos
// if(HeroInfo[uuid].type==HType.warrior) pos=HeroPos[1].pos
node.setPosition(pos)
var hv = this.hero_init(uuid,node)
hv.scale = 1;
hv.is_master=true;
hv.lv=1
this.add(hv);
this.addComponents<ecs.Comp>(MasterModelComp)
oops.message.dispatchEvent(GameEvent.MasterCalled,{uuid:uuid})
}
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,info:any={ap:0,hp:0,lv:1,crit:0,crit_d:0,dod:0,dod_no:false,crit_no:false},fight_pos:number=1) {
// console.log("英雄加载:",uuid,pos,scale,info)
scale = 1
if(smc.vmdata.hero1.uuid==0){
this.vmHero=smc.vmdata.hero1
}else if(smc.vmdata.hero2.uuid==0){
this.vmHero=smc.vmdata.hero2
}else if(smc.vmdata.hero3.uuid==0){
this.vmHero=smc.vmdata.hero3
}else{
console.log("[Hero] 英雄已满")
return
}
this.vmHero.uuid=uuid
this.vmHero.count=1
var path = "game/heros/"+HeroInfo[uuid].path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
@@ -69,18 +66,21 @@ export class Hero extends ecs.Entity {
node.setPosition(pos)
// console.log("hero load",pos)
var hv = this.hero_init(uuid,node,info)
hv.fight_pos=fight_pos
hv.is_friend=true
this.add(hv);
this.addComponents<ecs.Comp>(FriendModelComp);
// const move = this.get(BattleMoveComp);
// move.direction = 1; // 向右移动
// move.targetX = 800; // 右边界'
this.addComponents<ecs.Comp>(MasterModelComp)
oops.message.dispatchEvent(GameEvent.MasterCalled,{uuid:uuid})
const move = this.get(BattleMoveComp);
move.direction = 1; // 向右移动
move.targetX = 800; // 右边界'
}
hero_init(uuid:number=1001,node:Node,info:any={ap:0,hp:0,lv:1,crit:0,crit_d:0,dod:0,dod_no:false,crit_no:false}) {
var hv = node.getComponent(HeroViewComp)!;
let hero= HeroInfo[uuid] // 共用英雄数据
hv.vmHero=this.vmHero
this.vmHero.name=hero.name
hv.scale = 1;
hv.is_master=true;
hv.lv=1
hv.lv=info.lv
hv.fac = FacSet.HERO;
hv.type = hero.type;
@@ -89,8 +89,8 @@ export class Hero extends ecs.Entity {
hv.hero_name= hero.name;
hv.speed =hv.ospeed = hero.speed;
hv.dis = hero.dis;
hv.cd = hv.cd_base = hero.cd
hv.hp= hv.hp_max = hv.hp_base=hero.hp+info.hp
this.vmHero.cd_max=hv.cd = hv.cd_base = hero.cd
this.vmHero.hp=this.vmHero.hp_max= hv.hp = hv.hp_max = hv.hp_base=hero.hp+info.hp
hv.ap = hv.ap_base=hero.ap+info.ap;
hero.buff.forEach((buff:any)=>{
switch(buff.buff_type){