// 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 { tMgr } from "../Global"; import { SignTable, TableName } from "../kernel/table/TableDefine"; const { ccclass, property } = cc._decorator; @ccclass export default class SignItem extends cc.Component { private _day: number; setDay(day: number) { this._day = day; let config = tMgr.getConfig(TableName.SIGN, day) as SignTable; // this.node.getChildByName('txtTitle').getComponent(Label).string = '第' + day.toString() + '天'; this.node.getChildByName('txtNum').getComponent(cc.Label).string = config.Num.toString(); let color = cc.color(); color.fromHEX('#946648'); this.node.getChildByName('imgTitle').color = color; if (this._day < 7) { cc.resources.load(config.Icon, cc.SpriteFrame, (error, asset) => { if (!error) { this.node.getChildByName('icon').getComponent(cc.Sprite).spriteFrame = asset as cc.SpriteFrame; } }) } } setCurrent(flag: boolean) { if (this._day > 6) { return; } this.node.getChildByName('imgNormal').active = !flag; this.node.getChildByName('imgCur').active = flag; if (flag) { let color = cc.color(); color.fromHEX('#357c44'); this.node.getChildByName('imgTitle').color = color; } } setLock(flag: boolean) { // if (this._day > 6) { // this.node.getChildByName('imgNormal').getComponent(cc.Button).interactable = !flag; // } // else { this.node.getChildByName('imgMask').active = flag; if (flag) { let color = cc.color(); color.fromHEX('#4a4556'); this.node.getChildByName('imgTitle').color = color; } // } } }