import { _decorator, Component, Node, EventHandler, Sprite, SpriteFrame, Label } from 'cc'; import { ResourcesUtils } from '../core/resourceManager/ResourcesUtils'; import { ConfigData } from '../Data/ConfigData'; import { g } from '../Data/g'; const { ccclass, property } = _decorator; @ccclass('PrizeInitUI') export class PrizeInitUI extends Component { @property({ tooltip: "奖品展示图片1", type: Node }) public prize1: Node; @property({ tooltip: "奖品展示图片2", type: Node }) public prize2: Node; @property({ tooltip: "奖品展示图片3", type: Node }) public prize3: Node; @property({ tooltip: "奖品展示图片4", type: Node }) public prize4: Node; @property({ tooltip: "奖品展示图片5", type: Node }) public prize5: Node; @property({ tooltip: "奖品展示图片6", type: Node }) public prize6: Node; @property({ tooltip: "奖品展示图片7", type: Node }) public prize7: Node; @property({ tooltip: "奖品展示图片8", type: Node }) public prize8: Node; @property({ tooltip: "奖品展示文本1", type: Node }) public prizeTxt1: Node; @property({ tooltip: "奖品展示文本2", type: Node }) public prizeTxt2: Node; @property({ tooltip: "奖品展示文本3", type: Node }) public prizeTxt3: Node; @property({ tooltip: "奖品展示文本4", type: Node }) public prizeTxt4: Node; @property({ tooltip: "奖品展示文本5", type: Node }) public prizeTxt5: Node; @property({ tooltip: "奖品展示文本6", type: Node }) public prizeTxt6: Node; @property({ tooltip: "奖品展示文本7", type: Node }) public prizeTxt7: Node; @property({ tooltip: "奖品展示文本8", type: Node }) public prizeTxt8: Node; start() { this.initUI(); } public async initUI() { let configData = ConfigData.configMap.get("turntable").prizeList; let _config: any = ConfigData.configMap.get("turntable").showOrder; for (let i = 0; i < _config.length; i++) { let type = i + 1; let _id = _config[i]; for (let j = 0; j < configData.length; j++) { if (configData[j].id == _id) { let _data = configData[j]; let img: SpriteFrame = await ResourcesUtils.load("Images/turnPrize/prize" + _data.icon + "/spriteFrame", SpriteFrame, this.node); this["prize" + type].getComponent(Sprite).spriteFrame = img; this["prizeTxt" + type].getComponent(Label).string = _data.title; break; } } } } }