英雄激活后,上阵队伍可选择
This commit is contained in:
@@ -35,6 +35,7 @@ export class HeroSelect extends ecs.Entity {
|
||||
hcc.h_uuid = uuid;
|
||||
this.add(hcc);
|
||||
}
|
||||
|
||||
/** 模块资源释放 */
|
||||
destroy() {
|
||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user