上阵英雄选择 完成

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

View File

@@ -47,10 +47,16 @@
}, },
{ {
"__id__": 114 "__id__": 114
},
{
"__id__": 116
},
{
"__id__": 118
} }
], ],
"_prefab": { "_prefab": {
"__id__": 116 "__id__": 121
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -2693,6 +2699,94 @@
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "32bpMN2RNIXbFGf0XrTQcR" "fileId": "32bpMN2RNIXbFGf0XrTQcR"
}, },
{
"__type__": "51ecezMdSZLh4DDq/80AokX",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 117
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "6bSZ2zJWFD1avkHKX88S6F"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 119
},
"clickEvents": [
{
"__id__": 120
}
],
"_interactable": true,
"_transition": 3,
"_normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_hoverColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_pressedColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_normalSprite": null,
"_hoverSprite": null,
"_pressedSprite": null,
"_disabledSprite": null,
"_duration": 0.1,
"_zoomScale": 1.2,
"_target": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "39WCxIOVJEHo9e3y3tsU62"
},
{
"__type__": "cc.ClickEvent",
"target": {
"__id__": 1
},
"component": "",
"_componentId": "51ecezMdSZLh4DDq/80AokX",
"handler": "select",
"customEventData": ""
},
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {

File diff suppressed because it is too large Load Diff

View File

@@ -112,7 +112,7 @@ export class SingletonModuleComp extends ecs.Comp {
gems:0, gems:0,
energy:0, energy:0,
}, },
fight_heros:[9001,], fight_heros:[9001,9002],
items:{ items:{
1001:1000, 1001:1000,
1002:0, 1002:0,

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>=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}; if(smc.heros[uuid].slv>=5) {slv.getChildByName("s5").active=true} else {slv.getChildByName("s5").active=false};
let hcc = node.getComponent(HeroSetComp)!; let hcc = node.getComponent(HeroSetComp)!;
console.log(hcc)
hcc.h_uuid = uuid; hcc.h_uuid = uuid;
this.add(hcc); this.add(hcc);
} }

View File

@@ -1,7 +1,7 @@
import { _decorator, Label } from "cc"; import { _decorator, Label } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; 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 { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { smc } from "../common/SingletonModuleComp"; import { smc } from "../common/SingletonModuleComp";
@@ -11,21 +11,35 @@ const { ccclass, property } = _decorator;
@ccclass('HeroSetComp') @ccclass('HeroSetComp')
@ecs.register('HeroSetComp', false) @ecs.register('HeroSetComp', false)
export class HeroSetComp extends CCComp { export class HeroSetComp extends CCComp {
hcc_home: HeroHomeComp = null!; mhc_home: MissionHomeComp = null!;
h_uuid: number = 0; h_uuid: number = 0;
onLoad() { 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); oops.message.on("hero_card_update_info", this.update_data, this);
} }
/** 视图层逻辑代码分离演示 */ /** 视图层逻辑代码分离演示 */
start() { 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(){ select(){
this.hcc_home.hero_show(this.h_uuid) this.mhc_home.select_hero(this.h_uuid)
oops.message.dispatchEvent("hero_set_show_info",{uuid: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){ check_show(event: string, args: any){
// console.log("hero_set check_show",args) // console.log("hero_set check_show",args)

View 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();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "114984db-549a-4eea-a999-f26f64e79671",
"files": [],
"subMetas": {},
"userData": {}
}