位置已取消

This commit is contained in:
2025-05-15 16:51:52 +08:00
parent ea64303410
commit 30d5cfbb7c
3 changed files with 13 additions and 14 deletions

View File

@@ -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) console.log("英雄加载:",uuid,pos,scale,info)
scale = 1 scale = 1
let box_group=BoxSet.HERO let box_group=BoxSet.HERO
@@ -44,6 +44,7 @@ export class Hero extends ecs.Entity {
let hero= HeroInfo[uuid] // 共用英雄数据 let hero= HeroInfo[uuid] // 共用英雄数据
hv.scale = scale; hv.scale = scale;
hv.fac = 0; hv.fac = 0;
hv.fight_pos=fight_pos
hv.type = hero.type; hv.type = hero.type;
hv.box_group = box_group; hv.box_group = box_group;
hv.hero_uuid= uuid; hv.hero_uuid= uuid;

View File

@@ -29,6 +29,7 @@ export class HeroViewComp extends CCComp {
hero_uuid:number = 1001; hero_uuid:number = 1001;
hero_name : string = "hero"; hero_name : string = "hero";
fight_pos:number=0;
lv:number =1; lv:number =1;
slv:number =1; slv:number =1;
scale: number = 1; /** 角色阵营 1hero -1 :mon */ scale: number = 1; /** 角色阵营 1hero -1 :mon */

View File

@@ -51,39 +51,36 @@ export class MissionHeroCompComp extends CCComp {
call_hero(event: string, args: any){ call_hero(event: string, args: any){
this.node.getChildByName("herospos").active=false this.node.getChildByName("herospos").active=false
console.log("call_hero",args) console.log("call_hero",args)
let hero_pos=0 let fight_pos=args
if(args.hero_pos){
hero_pos=args.hero_pos
}
this.timer.reset() this.timer.reset()
let hero_list =HeroList let hero_list =HeroList
let x=RandomManager.instance.getRandomInt(0,hero_list.length,1) let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
// let uuid=args.uuid // let uuid=args.uuid
// console.log("call_hero",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) console.log("call_hero addHero",uuid)
let info:any={ap:0,hp:0} let info:any={ap:0,hp:0}
if(this.start_pos[hero_pos].has){ if(this.start_pos[fight_pos].has){
info=this.get_info_and_remove(hero_pos,uuid) info=this.get_info_and_remove(fight_pos,uuid)
} }
let hero = ecs.getEntity<Hero>(Hero); let hero = ecs.getEntity<Hero>(Hero);
let scale = 1 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) console.log("hero load0",pos,this.start_pos)
hero.load(pos,scale,uuid,info); hero.load(pos,scale,uuid,info,fight_pos);
this.start_pos[hero_pos].has=true this.start_pos[fight_pos].has=true
this.current_hero_uuid=0 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 info:any={ap:0,hp:0}
let heros=ecs.query(ecs.allOf(HeroModelComp)) let heros=ecs.query(ecs.allOf(HeroModelComp))
for(let hero of heros){ 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 hv = hero.get(HeroViewComp)
let AP_UP_RATE = hv.hero_uuid === uuid ? GameSet.AP_UPDATE_RATE : GameSet.AP_CHANGE_RATE; let AP_UP_RATE = hv.hero_uuid === uuid ? GameSet.AP_UPDATE_RATE : GameSet.AP_CHANGE_RATE;
let heroUpData = HeroUpInfo[hv.hero_uuid] || {} let heroUpData = HeroUpInfo[hv.hero_uuid] || {}