From 30d5cfbb7c0f0b3e17a00d47a2fa3ccb587a925e Mon Sep 17 00:00:00 2001 From: panw Date: Thu, 15 May 2025 16:51:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E5=B7=B2=E5=8F=96=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/script/game/hero/Hero.ts | 3 ++- assets/script/game/hero/HeroViewComp.ts | 1 + assets/script/game/map/MissionHeroComp.ts | 23 ++++++++++------------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index 69888958..2439f850 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -29,7 +29,7 @@ export class Hero extends ecs.Entity { } /** 加载角色 */ - load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,info:any={ap:0,hp:0}) { + load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,info:any={ap:0,hp:0},fight_pos:number=0) { console.log("英雄加载:",uuid,pos,scale,info) scale = 1 let box_group=BoxSet.HERO @@ -44,6 +44,7 @@ export class Hero extends ecs.Entity { let hero= HeroInfo[uuid] // 共用英雄数据 hv.scale = scale; hv.fac = 0; + hv.fight_pos=fight_pos hv.type = hero.type; hv.box_group = box_group; hv.hero_uuid= uuid; diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 6c4cadf0..1d3fc567 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -29,6 +29,7 @@ export class HeroViewComp extends CCComp { hero_uuid:number = 1001; hero_name : string = "hero"; + fight_pos:number=0; lv:number =1; slv:number =1; scale: number = 1; /** 角色阵营 1:hero -1 :mon */ diff --git a/assets/script/game/map/MissionHeroComp.ts b/assets/script/game/map/MissionHeroComp.ts index 23703380..e0a98a07 100644 --- a/assets/script/game/map/MissionHeroComp.ts +++ b/assets/script/game/map/MissionHeroComp.ts @@ -51,39 +51,36 @@ export class MissionHeroCompComp extends CCComp { call_hero(event: string, args: any){ this.node.getChildByName("herospos").active=false console.log("call_hero",args) - let hero_pos=0 - if(args.hero_pos){ - hero_pos=args.hero_pos - } + let fight_pos=args this.timer.reset() let hero_list =HeroList let x=RandomManager.instance.getRandomInt(0,hero_list.length,1) // let uuid=args.uuid // console.log("call_hero",uuid) - this.addHero(this.current_hero_uuid,hero_pos) + this.addHero(this.current_hero_uuid,fight_pos) } /** 添加玩家 */ - private addHero(uuid:number=1001,hero_pos:number=0) { + private addHero(uuid:number=1001,fight_pos:number=0) { console.log("call_hero addHero",uuid) let info:any={ap:0,hp:0} - if(this.start_pos[hero_pos].has){ - info=this.get_info_and_remove(hero_pos,uuid) + if(this.start_pos[fight_pos].has){ + info=this.get_info_and_remove(fight_pos,uuid) } let hero = ecs.getEntity(Hero); let scale = 1 - let pos:Vec3 = this.start_pos[hero_pos].pos; + let pos:Vec3 = this.start_pos[fight_pos].pos; console.log("hero load0",pos,this.start_pos) - hero.load(pos,scale,uuid,info); - this.start_pos[hero_pos].has=true + hero.load(pos,scale,uuid,info,fight_pos); + this.start_pos[fight_pos].has=true this.current_hero_uuid=0 } - get_info_and_remove(type:number,uuid:number){ + get_info_and_remove(fight_pos:number,uuid:number){ let info:any={ap:0,hp:0} let heros=ecs.query(ecs.allOf(HeroModelComp)) for(let hero of heros){ - if(hero.get(HeroViewComp).type==type){ + if(hero.get(HeroViewComp).fight_pos==fight_pos){ let hv = hero.get(HeroViewComp) let AP_UP_RATE = hv.hero_uuid === uuid ? GameSet.AP_UPDATE_RATE : GameSet.AP_CHANGE_RATE; let heroUpData = HeroUpInfo[hv.hero_uuid] || {}