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

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

@@ -13531,7 +13531,7 @@
} }
], ],
"_interactable": true, "_interactable": true,
"_transition": 0, "_transition": 3,
"_normalColor": { "_normalColor": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 255,
@@ -13575,11 +13575,13 @@
}, },
{ {
"__type__": "cc.ClickEvent", "__type__": "cc.ClickEvent",
"target": null, "target": {
"__id__": 2
},
"component": "", "component": "",
"_componentId": "", "_componentId": "0e186v7IoJEnZ9QdXVZry2W",
"handler": "", "handler": "call_hero",
"customEventData": "" "customEventData": "0"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",

View File

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