dd
This commit is contained in:
2708
assets/resources/game/gui/hero_set.prefab
Normal file
2708
assets/resources/game/gui/hero_set.prefab
Normal file
File diff suppressed because it is too large
Load Diff
13
assets/resources/game/gui/hero_set.prefab.meta
Normal file
13
assets/resources/game/gui/hero_set.prefab.meta
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.1.50",
|
||||||
|
"importer": "prefab",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "a200fc7f-7296-4e79-95c2-84f0f01485d7",
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {
|
||||||
|
"syncNodeName": "hero_set"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -485,10 +485,10 @@
|
|||||||
"height": 180,
|
"height": 180,
|
||||||
"rawWidth": 32,
|
"rawWidth": 32,
|
||||||
"rawHeight": 180,
|
"rawHeight": 180,
|
||||||
"borderTop": 0,
|
"borderTop": 24,
|
||||||
"borderBottom": 0,
|
"borderBottom": 129,
|
||||||
"borderLeft": 0,
|
"borderLeft": 11,
|
||||||
"borderRight": 0,
|
"borderRight": 10,
|
||||||
"packable": true,
|
"packable": true,
|
||||||
"pixelsToUnit": 100,
|
"pixelsToUnit": 100,
|
||||||
"pivotX": 0.5,
|
"pivotX": 0.5,
|
||||||
@@ -1359,10 +1359,10 @@
|
|||||||
"height": 84,
|
"height": 84,
|
||||||
"rawWidth": 40,
|
"rawWidth": 40,
|
||||||
"rawHeight": 84,
|
"rawHeight": 84,
|
||||||
"borderTop": 133,
|
"borderTop": 45,
|
||||||
"borderBottom": 94,
|
"borderBottom": 19,
|
||||||
"borderLeft": 58,
|
"borderLeft": 16,
|
||||||
"borderRight": 55,
|
"borderRight": 16,
|
||||||
"packable": true,
|
"packable": true,
|
||||||
"pixelsToUnit": 100,
|
"pixelsToUnit": 100,
|
||||||
"pivotX": 0.5,
|
"pivotX": 0.5,
|
||||||
@@ -1405,10 +1405,10 @@
|
|||||||
"height": 30,
|
"height": 30,
|
||||||
"rawWidth": 30,
|
"rawWidth": 30,
|
||||||
"rawHeight": 30,
|
"rawHeight": 30,
|
||||||
"borderTop": 942,
|
"borderTop": 5,
|
||||||
"borderBottom": 242,
|
"borderBottom": 5,
|
||||||
"borderLeft": 0,
|
"borderLeft": 5,
|
||||||
"borderRight": 0,
|
"borderRight": 5,
|
||||||
"packable": true,
|
"packable": true,
|
||||||
"pixelsToUnit": 100,
|
"pixelsToUnit": 100,
|
||||||
"pivotX": 0.5,
|
"pivotX": 0.5,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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";
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
43
assets/script/game/hero/HeroSet.ts
Normal file
43
assets/script/game/hero/HeroSet.ts
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
1
assets/script/game/hero/HeroSet.ts.meta
Normal file
1
assets/script/game/hero/HeroSet.ts.meta
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"03dbdc6b-b8d2-44e9-9477-1ef40669367a","files":[],"subMetas":{},"userData":{}}
|
||||||
62
assets/script/game/hero/HeroSetComp.ts
Normal file
62
assets/script/game/hero/HeroSetComp.ts
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
1
assets/script/game/hero/HeroSetComp.ts.meta
Normal file
1
assets/script/game/hero/HeroSetComp.ts.meta
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"51ececcc-7526-4b87-80c3-abff34028917","files":[],"subMetas":{},"userData":{}}
|
||||||
Reference in New Issue
Block a user