import SetGray from "../../component/SetGray"; const { ccclass, property } = cc._decorator; @ccclass export default class Turnable extends cc.Component { @property({displayName: '选中节点', type: cc.Node}) private node_choose: cc.Node = null; @property({displayName: '未选中节点', type: cc.Node}) private node_noChoose: cc.Node = null; @property({displayName: '显示次数', type: cc.Label}) private lbl_times: cc.Label = null; @property({displayName: '显示金额', type: cc.Label}) private lbl_value: cc.Label = null; private isCanNotChoose: boolean = false; private data = null; public setShowUI(data):boolean { this.data = data; let haveTimes = data.cashFrequency - gData.gameData.playerProp.getRedMoneyCashOutTimesByIndex(data.index); this.lbl_times.string = `剩${haveTimes}次`; this.lbl_value.string = (data.money/100) + '元'; return haveTimes > 0; } public setIsChoose(isChoose: boolean) { if(this.isCanNotChoose) { return; } this.node_choose.active = isChoose; this.node_noChoose.active = !isChoose; } public setIsCanNotChoose() { this.isCanNotChoose = true; this.node_choose.active = true; this.node_noChoose.active = false; let com = this.node_choose.getComponent(SetGray); com.setGray(true); } public getIsCanNotChoose() { return this.isCanNotChoose; } public setRemaineTimes(): boolean { let haveTimes = gData.gameData.playerProp.getRedMoneyCashOutTimesByIndex(this.data.index); let remainTimes = this.data.cashFrequency- haveTimes; this.lbl_times.string = `剩${remainTimes}次`; if(remainTimes <= 0) { this.setIsCanNotChoose(); return true; } return false; } }