// Learn TypeScript: // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html import { SaveDataManager } from "../component/SaveDataManager"; import { tMgr } from "../Global"; import { GamePlayTable, TableName, WheelTable } from "../kernel/table/TableDefine"; const { ccclass, property } = cc._decorator; @ccclass export default class WheelItem extends cc.Component { private _config: WheelTable; // get config(): WheelTable { return this._config; } // LIFE-CYCLE CALLBACKS: // onLoad () {} setId(id: number): void { this._config = tMgr.getConfig(TableName.WHEEL, id) as WheelTable; if (this._config.Type == 5 && SaveDataManager.ins.runtimeData.ballSkinUnlocked.includes(5)) { //已获得西瓜球皮肤的情况下 替换为钻石 let diamondConfig = tMgr.getConfig(TableName.WHEEL, 1) as WheelTable; //随便读一个钻石配置 let gameplayConfig = (tMgr.getConfig(TableName.GAME_PLAY, 19) as GamePlayTable); this.node.getChildByName('txtNum').active = true; this.node.getChildByName('txtNum').getComponent(cc.Label).string = 'x' + gameplayConfig.Value.toString(); cc.resources.load(diamondConfig.Icon, cc.SpriteFrame, (error, asset) => { if (!error) { this.node.getChildByName('icon').getComponent(cc.Sprite).spriteFrame = asset as cc.SpriteFrame; } }) } else { cc.resources.load(this._config.Icon, cc.SpriteFrame, (error, asset) => { if (!error) { this.node.getChildByName('icon').getComponent(cc.Sprite).spriteFrame = asset as cc.SpriteFrame; } }) this.node.getChildByName('txtNum').active = (this._config.Type == 1); if (this._config.Type == 1) { this.node.getChildByName('txtNum').getComponent(cc.Label).string = 'x' + this._config.Num.toString(); } } } refresh() { if (this._config) { this.setId(this._config.ID); } } // update (dt) {} }