英雄召唤修改为到特定位置 取消类型与位置绑定

This commit is contained in:
2025-05-15 16:27:14 +08:00
parent 176bdbc811
commit ea64303410
2 changed files with 27 additions and 14 deletions

View File

@@ -23,6 +23,7 @@ export class MissionHeroCompComp extends CCComp {
1:{pos:v3(-270,205,0),has:false},
2:{pos:v3(-270,65,0),has:false},
}
current_hero_uuid:number=0
onLoad(){
this.on(GameEvent.UseHeroCard,this.show_heros_pos,this)
}
@@ -41,31 +42,41 @@ export class MissionHeroCompComp extends CCComp {
test_call(){
this.addHero(5010)
}
show_heros_pos(){
show_heros_pos(event: string, args: any){
console.log("show_heros_pos",args)
this.current_hero_uuid=args.uuid
this.node.getChildByName("herospos").active=true
}
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
}
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(uuid)
// let uuid=args.uuid
// console.log("call_hero",uuid)
this.addHero(this.current_hero_uuid,hero_pos)
}
/** 添加玩家 */
private addHero(uuid:number=1001) {
private addHero(uuid:number=1001,hero_pos:number=0) {
console.log("call_hero addHero",uuid)
let info:any={ap:0,hp:0}
if(this.start_pos[HeroInfo[uuid].type].has){
info=this.get_info_and_remove(HeroInfo[uuid].type,uuid)
if(this.start_pos[hero_pos].has){
info=this.get_info_and_remove(hero_pos,uuid)
}
let hero = ecs.getEntity<Hero>(Hero);
let scale = 1
let pos:Vec3 = this.start_pos[HeroInfo[uuid].type].pos;
let pos:Vec3 = this.start_pos[hero_pos].pos;
console.log("hero load0",pos,this.start_pos)
hero.load(pos,scale,uuid,info);
this.start_pos[HeroInfo[uuid].type].has=true
this.start_pos[hero_pos].has=true
this.current_hero_uuid=0
}
get_info_and_remove(type:number,uuid:number){