import GameModel from "../ts/core/GameModel"; cc.Class({ extends: cc.Component, properties: { shigongLab: cc.Label, yinliangLab: cc.Label, xianyuLab: cc.Label, bindLab :cc.Label, scoreLayer:cc.Node, scoreList:[cc.Label], NpcShopUI:cc.Prefab, }, onLoad(){ this.updateGameMoney(); }, updateGameMoney(){ this.shigongLab.string = '0'; let getColor = (num) => { let color = cc.Color.WHITE; if (num >= 0 && num < 1000000) { color = cc.Color.WHITE; } else if (num >= 1000000 && num < 10000000) { color = cc.Color.YELLOW; } else if (num >= 10000000 && num < 100000000) { color = cc.color(0, 255, 255, 255); } else if (num >= 100000000 && num < 1000000000) { color = cc.Color.GREEN; } else if (num >= 1000000000 && num < 10000000000) { color = cc.color(255, 0, 120, 255); } return color; }; if(!GameModel.player.gameData){ return; } this.yinliangLab.string = GameModel.player.gameData.money; this.yinliangLab.node.color = getColor(GameModel.player.gameData.money); this.xianyuLab.string = GameModel.player.gameData.jade; this.xianyuLab.node.color = getColor(GameModel.player.gameData.jade); this.bindLab.string = GameModel.player.gameData.bindjade; this.bindLab.node.color = getColor(GameModel.player.gameData.bindjade); let score=GameModel.player.gameData.shuilugj; this.scoreList[0].string = score; }, ioScoreLayer(){ this.scoreLayer.active = !this.scoreLayer.active; }, onExchangeClick(e, d){ if(d == 'gongji'){ let CPubFunction = require('../game/PubFunction'); let goUI = CPubFunction.CreateSubNode(cc.find('Canvas/MainUI'), { nX: 0, nY: 0 }, this.NpcShopUI, 'NpcShopUI'); let comUI = goUI.getComponent('NpcShopUI'); comUI.nNpcConfigID = 10242;// 魏徵id this.node.parent.destroy(); } } });