This commit is contained in:
2024-12-10 11:05:23 +08:00
parent a5d2bdb55a
commit 7388f06076
10 changed files with 11393 additions and 3937 deletions

View File

@@ -1,9 +1,3 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 15:56:01
* @LastEditors: dgflash
* @LastEditTime: 2022-08-17 13:43:25
*/
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
/**

View File

@@ -0,0 +1,43 @@
import { instantiate, Label, Prefab, resources, Sprite, SpriteAtlas } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { HeroSetComp } from "./HeroSetComp";
import { smc } from "../common/SingletonModuleComp";
import { HeroInfo } from "../common/config/heroSet";
/** HeroSet 模块 */
@ecs.register(`HeroSet`)
export class HeroSet extends ecs.Entity {
protected init() {
// this.addComponents<ecs.Comp>();
}
load(uuid:number=101,parent:any) {
// var path = "game/monster/"+prefab_path;
var path = "game/gui/hero_set";
var icon_path = "game/heros/herois"
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
let slv = node.getChildByName("slv");
node.parent = parent;
node.getChildByName("name").getComponent(Label).string = HeroInfo[uuid].name
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = node.getChildByName("Mask").getChildByName("hero").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[uuid].path);
});
node.getChildByName("lv").getComponent(Label).string = smc.heros[uuid].lv.toString()+"级";
if(smc.heros[uuid].slv>=1) {slv.getChildByName("s1").active=true} else {slv.getChildByName("s1").active=false};
if(smc.heros[uuid].slv>=2) {slv.getChildByName("s2").active=true} else {slv.getChildByName("s2").active=false};
if(smc.heros[uuid].slv>=3) {slv.getChildByName("s3").active=true} else {slv.getChildByName("s3").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};
let hcc = node.getComponent(HeroSetComp)!;
hcc.h_uuid = uuid;
this.add(hcc);
}
/** 模块资源释放 */
destroy() {
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
super.destroy();
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"03dbdc6b-b8d2-44e9-9477-1ef40669367a","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,62 @@
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 { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { smc } from "../common/SingletonModuleComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('HeroSetComp')
@ecs.register('HeroSetComp', false)
export class HeroSetComp extends CCComp {
hcc_home: HeroHomeComp = null!;
h_uuid: number = 0;
onLoad() {
oops.message.on("hero_set_show_info", 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)
}
show_info(){
this.hcc_home.hero_show(this.h_uuid)
oops.message.dispatchEvent("hero_set_show_info",{uuid:this.h_uuid})
}
check_show(event: string, args: any){
// console.log("hero_set check_show",args)
this.show_bg(false)
if(args.uuid==this.h_uuid){
this.show_bg(true)
}
}
show_bg(val:boolean){
this.node.getChildByName("show").active=val
}
update_data(event: string, args: any){
if(args.uuid!=this.h_uuid) return
let slv = this.node.getChildByName("slv")
this.node.getChildByName("lv").getComponent(Label).string=smc.heros[this.h_uuid].lv.toString()+"级"
if(smc.heros[this.h_uuid].slv>=1) {slv.getChildByName("s1").active=true} else {slv.getChildByName("s1").active=false};
if(smc.heros[this.h_uuid].slv>=2) {slv.getChildByName("s2").active=true} else {slv.getChildByName("s2").active=false};
if(smc.heros[this.h_uuid].slv>=3) {slv.getChildByName("s3").active=true} else {slv.getChildByName("s3").active=false};
if(smc.heros[this.h_uuid].slv>=4) {slv.getChildByName("s4").active=true} else {slv.getChildByName("s4").active=false};
if(smc.heros[this.h_uuid].slv>=5) {slv.getChildByName("s5").active=true} else {slv.getChildByName("s5").active=false};
}
/** 全局消息逻辑处理 */
// private onHandler(event: string, args: any) {
// switch (event) {
// case ModuleEvent.Cmd:
// break;
// }
// }
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"51ececcc-7526-4b87-80c3-abff34028917","files":[],"subMetas":{},"userData":{}}