上阵英雄选择 完成
This commit is contained in:
@@ -112,7 +112,7 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
gems:0,
|
||||
energy:0,
|
||||
},
|
||||
fight_heros:[9001,],
|
||||
fight_heros:[9001,9002],
|
||||
items:{
|
||||
1001:1000,
|
||||
1002:0,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
43
assets/script/game/map/MissionHomeComp.ts
Normal file
43
assets/script/game/map/MissionHomeComp.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { _decorator, UITransform } 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 { HeroList } from "../common/config/heroSet";
|
||||
import { HeroSet } from "../hero/HeroSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('MissionHomeComp')
|
||||
@ecs.register('MissionHome', false)
|
||||
export class MissionHomeComp extends CCComp {
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
// this.on(ModuleEvent.Cmd, this.onHandler, this);
|
||||
this.loads()
|
||||
}
|
||||
|
||||
/** 全局消息逻辑处理 */
|
||||
// private onHandler(event: string, args: any) {
|
||||
// switch (event) {
|
||||
// case ModuleEvent.Cmd:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
select_hero(h_uuid:number){
|
||||
|
||||
}
|
||||
loads(){
|
||||
let hc:number =HeroList.length
|
||||
let parent= this.node.getChildByName("heros").getChildByName("view").getChildByName("content")
|
||||
parent.getComponent(UITransform).width=hc*150
|
||||
for (let i = 0; i < hc; i++) {
|
||||
let hcc =ecs.getEntity<HeroSet>(HeroSet)
|
||||
hcc.load(HeroList[i],parent)
|
||||
}
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
9
assets/script/game/map/MissionHomeComp.ts.meta
Normal file
9
assets/script/game/map/MissionHomeComp.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "114984db-549a-4eea-a999-f26f64e79671",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user