123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- import { _decorator, Label, Node, Sprite, SpriteFrame } from 'cc';
- import { ResKeeper } from '../../../framework/res/ResKeeper';
- import { StringUtil } from '../../../framework/util/StringUtil';
- import { Framework } from '../../../framework/Framework';
- import { ViewID } from '../../../framework/config/LayerConf';
- const { ccclass, property } = _decorator;
- @ccclass('HeroListCard')
- export class HeroListCard extends ResKeeper {
- @property({ type: Sprite, tooltip: "英雄图标" })
- heroIco: Sprite = null;
- @property({ type: Label, tooltip: "英雄名字" })
- heroName: Label = null;
- @property({ type: Node, tooltip: "星级节点" })
- starNode: Node = null;
- @property({ type: [Node], tooltip: "星图" })
- stars: Node[] = [];
- @property({ type: Node, tooltip: "星级背景" })
- starBg: Node = null;
- @property({ type: Label, tooltip: "星字" })
- starTx: Label = null;
-
- private data = {};
- protected onLoad() {
-
- }
- protected onDestroy() {
- //如果该组件有事件自行取消注释
- //Framework.event.removeEvent(this);
- super.onDestroy();
- }
-
- //如果使用了池中的节点,在该函数内归还,该函数会在onDestroy前调用
- onClose() {
-
- }
- //UI事件处理
- private onTouchButton(event: Event) {
- //Framework.audio.playEffect(AudioID.Click);
- let target: any = event.target;
- }
- refreshItem(data) {
- this.data = data;
- this.load('common', `texture/icon/hero/head_${data.conf.Id}/spriteFrame`, SpriteFrame, (res: SpriteFrame) => {
- this.heroIco.spriteFrame = res;
- })
- this.heroName.string = StringUtil.getLanguageData('英雄_' + data.conf.Id);;
- if (data.id) {
- this.node.getComponent(Sprite).grayscale = false;
- this.heroIco.grayscale = false;
- this.starNode.active = true;
- for (const index in this.stars) {
- if (Object.prototype.hasOwnProperty.call(this.stars, index)) {
- const star = this.stars[index];
- star.active = false;
- }
- }
- this.starBg.active = true;
- this.starTx.string = '0';
- } else {
- this.node.getComponent(Sprite).grayscale = true;
- this.heroIco.grayscale = true;
- this.starNode.active = false;
- this.starBg.active = false;
- }
- }
- //打开英雄详情界面
- openHeroAttr() {
- if (!this.data['id']) {
- Framework.tips.setTips(StringUtil.getLanguageData('英雄未激活!'));
- return;
- }
- Framework.layer.open(ViewID.HeroAttr,null,{heroDate:this.data});
- }
- }
|