97 lines
4.5 KiB
TypeScript
97 lines
4.5 KiB
TypeScript
import { EventTouch, Label, Node,Sprite,SpriteAtlas,_decorator, resources } 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 { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
import { UIID } from "../common/config/GameUIConfig";
|
|
import { Items } from "../common/config/Items";
|
|
import { SkillSet } from "../common/config/SkillSet";
|
|
import { HeroInfo, HeroSet } from "../common/config/heroSet";
|
|
const { ccclass, property } = _decorator;
|
|
|
|
/** 视图层对象 */
|
|
@ccclass('ItemInfoComp')
|
|
@ecs.register('ItemInfo', false)
|
|
export class ItemInfoComp extends CCComp {
|
|
onAdded(args: any) {
|
|
this.node.getChildByName("item").active = false;
|
|
this.node.getChildByName("skill").active = false;
|
|
this.node.getChildByName("hero").active = false;
|
|
if(args.type==0){
|
|
this.node.getChildByName("item").active = true;
|
|
this.node.getChildByName("name").getComponent(Label).string=Items[args.uuid].name
|
|
this.node.getChildByName("info").getComponent(Label).string=Items[args.uuid].info
|
|
let url = "gui/items";
|
|
let pathName= Items[args.uuid].path;
|
|
this.node.getChildByName("item").getChildByName("lv1").active = false;
|
|
this.node.getChildByName("item").getChildByName("lv2").active = false;
|
|
this.node.getChildByName("item").getChildByName("lv3").active = false;
|
|
this.node.getChildByName("item").getChildByName("lv4").active = false;
|
|
|
|
switch(Items[args.uuid].lv){
|
|
case 1:
|
|
this.node.getChildByName("item").getChildByName("lv1").active = true;
|
|
break;
|
|
case 2:
|
|
this.node.getChildByName("item").getChildByName("lv2").active = true;
|
|
break;
|
|
case 3:
|
|
this.node.getChildByName("item").getChildByName("lv3").active = true;
|
|
break;
|
|
case 4:
|
|
this.node.getChildByName("item").getChildByName("lv4").active = true;
|
|
break;
|
|
}
|
|
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
|
const sprite = this.node.getChildByName("item").getChildByName("icon").getComponent(Sprite);
|
|
sprite.spriteFrame = atlas.getSpriteFrame(pathName);
|
|
});
|
|
}
|
|
if(args.type==1){ //技能碎片
|
|
this.node.getChildByName("skill").active = true;
|
|
this.node.getChildByName("name").getComponent(Label).string=SkillSet[args.uuid].name+" 碎片"
|
|
this.node.getChildByName("info").getComponent(Label).string="「"+SkillSet[args.uuid].name+"」碎片,用于技能升星"
|
|
var icon_path = "game/skills/skill_icon"
|
|
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
|
const sprite = this.node.getChildByName("skill").getChildByName("skill").getChildByName("icon").getComponent(Sprite);
|
|
// console.log("update_data",atlas,sprite)
|
|
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[args.uuid].path);
|
|
});
|
|
|
|
|
|
}
|
|
if(args.type==2){ //英雄碎片
|
|
this.node.getChildByName("hero").active = true
|
|
this.node.getChildByName("name").getComponent(Label).string=HeroInfo[args.uuid].name+" 碎片"
|
|
this.node.getChildByName("info").getComponent(Label).string="「"+HeroInfo[args.uuid].name+"」碎片,用于英雄升星"
|
|
var icon_path = "game/heros/herois"
|
|
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
|
const sprite = this.node.getChildByName("hero").getChildByName("hero").getChildByName("icon").getComponent(Sprite);
|
|
sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[args.uuid].path);
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
private onTouchEnd(event: EventTouch) {
|
|
switch (event.target.name) {
|
|
case "btn":
|
|
this.reset();
|
|
break;
|
|
}
|
|
|
|
event.propagationStopped = true;
|
|
}
|
|
|
|
reset() {
|
|
oops.gui.remove(UIID.ItemInfo, false);
|
|
|
|
// // 注:模拟二次删除清理缓存
|
|
// setTimeout(() => {
|
|
// oops.gui.remove(UIID.ItemInfo);
|
|
// }, 100);
|
|
}
|
|
|
|
protected onDestroy(): void {
|
|
console.log("释放角色信息界面");
|
|
}
|
|
} |