英雄激活后,上阵队伍可选择

This commit is contained in:
2024-12-21 17:29:33 +08:00
parent e6e3db0f80
commit 177bc0e346
16 changed files with 6078 additions and 12 deletions

View File

@@ -82,7 +82,7 @@ export class CardControllerComp extends CCComp {
case "home":
this.node.getChildByName("mission_home").active = true
this.bbg.setPosition(v3(this.bbg_x[2],this.bbg_y))
this.node.getChildByName("mission_home").getComponent(MissionHomeComp).load_hero_card()
this.node.getChildByName("mission_home").getComponent(MissionHomeComp).update_hero_cards()
break;
}
}

View File

@@ -64,21 +64,25 @@ export class MissionHomeComp extends CCComp {
this.node.active=false;
}
load_hero_card(){
let loaded:any = ecs.query(ecs.allOf(HeroSelectComp));
if(loaded.length>0){
for(let i=0;i<loaded.length;i++){
loaded[i].HeroSelectComp.reset()
loaded[i].HeroSelectComp.ent.destroy()
}
}
let hc:number =HeroList.length
let parent= this.node.getChildByName("heros").getChildByName("view").getChildByName("content")
let height=Math.ceil(hc / 4)*135
parent.getComponent(UITransform).height=height
for (let i = 0; i < hc; i++) {
if(smc.heros[HeroList[i]].slv > 0) {
let hcc =ecs.getEntity<HeroSelect>(HeroSelect)
hcc.load(HeroList[i],parent)
}
this.update_hero_cards()
}
update_hero_cards(){
let loaded:any = ecs.query(ecs.allOf(HeroSelectComp));
for(let i=0;i<loaded.length;i++){
if(smc.heros[loaded[i].HeroSelectComp.h_uuid].slv ==0 ) {
loaded[i].HeroSelectComp.node.active=false
console.log("loaded[i].HeroSelectComp",loaded[i].HeroSelectComp)
}else{
loaded[i].HeroSelectComp.node.active=true
}
}
}
@@ -106,7 +110,7 @@ export class MissionHomeComp extends CCComp {
});
}
select_hero(h_uuid:number){
for(let i=0;i<4;i++){
for(let i=0;i<=4;i++){
if(this.heros_pos[i].uuid==0){
this.heros_pos[i].uuid=h_uuid
this.call_hero(h_uuid,i)
@@ -115,7 +119,7 @@ export class MissionHomeComp extends CCComp {
}
}
cancel_hero(h_uuid:number){
for(let i=0;i<4;i++){
for(let i=0;i<=4;i++){
if(this.heros_pos[i].uuid==h_uuid){
this.heros_pos[i].uuid=0
this.destory_hero(h_uuid)
@@ -129,6 +133,7 @@ export class MissionHomeComp extends CCComp {
var scene = smc.map.MapView.scene;
node.parent = scene.entityLayer!.node!
node.setPosition(this.heros_pos[index].px,BoxSet.GAME_LINE,0);
console.log("this.heros_pos[index].px",this.heros_pos[index].px)
let comp = node.getComponent(UiHeroComp)
comp.h_uuid = h_uuid
this.heros.push(comp)