上阵英雄选择 完成

This commit is contained in:
walkpan
2024-12-10 13:42:54 +08:00
parent 7388f06076
commit 9cd72c108e
7 changed files with 2165 additions and 4099 deletions

View File

@@ -32,6 +32,7 @@ export class HeroSet extends ecs.Entity {
if(smc.heros[uuid].slv>=4) {slv.getChildByName("s4").active=true} else {slv.getChildByName("s4").active=false};
if(smc.heros[uuid].slv>=5) {slv.getChildByName("s5").active=true} else {slv.getChildByName("s5").active=false};
let hcc = node.getComponent(HeroSetComp)!;
console.log(hcc)
hcc.h_uuid = uuid;
this.add(hcc);
}

View File

@@ -1,7 +1,7 @@
import { _decorator, Label } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { HeroHomeComp } from "../map/HeroHomeComp";
import { MissionHomeComp } from "../map/MissionHomeComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { smc } from "../common/SingletonModuleComp";
@@ -11,21 +11,35 @@ const { ccclass, property } = _decorator;
@ccclass('HeroSetComp')
@ecs.register('HeroSetComp', false)
export class HeroSetComp extends CCComp {
hcc_home: HeroHomeComp = null!;
mhc_home: MissionHomeComp = null!;
h_uuid: number = 0;
onLoad() {
oops.message.on("hero_set_show_info", this.check_show, this);
oops.message.on("hero_set_select", this.check_show, this);
oops.message.on("hero_card_update_info", this.update_data, this);
}
/** 视图层逻辑代码分离演示 */
start() {
this.hcc_home=this.node.parent.parent.parent.parent.getComponent(HeroHomeComp);
// console.log("hero_set hcc_home",this.hcc_home)
this.mhc_home=this.node.parent.parent.parent.parent.getComponent(MissionHomeComp);
if(smc.vmdata.fight_heros.indexOf(this.h_uuid)>=0){
this.show_bg(true)
}else{
this.show_bg(false)
}
}
show_info(){
this.hcc_home.hero_show(this.h_uuid)
oops.message.dispatchEvent("hero_set_show_info",{uuid:this.h_uuid})
select(){
this.mhc_home.select_hero(this.h_uuid)
if(smc.vmdata.fight_heros.indexOf(this.h_uuid)>=0){
smc.vmdata.fight_heros.splice(smc.vmdata.fight_heros.indexOf(this.h_uuid),1)
this.show_bg(false)
return
}
if(smc.vmdata.fight_heros.length>= 5){
oops.gui.toast("英雄数量不能超过5个")
return
}
smc.vmdata.fight_heros.push(this.h_uuid)
this.show_bg(true)
}
check_show(event: string, args: any){
// console.log("hero_set check_show",args)