// 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 DailyData from "../datas/DailyData"; import GameM from "../manager/GameM"; const { ccclass, property } = cc._decorator; @ccclass export default class DailyUpItem extends cc.Component { @property(cc.Node) bgNormal: cc.Node = null; @property(cc.Node) bgSel: cc.Node = null; @property(cc.Sprite) icon: cc.Sprite = null; @property(cc.Label) labState: cc.Label = null; @property(cc.Node) iconGet: cc.Node = null; @property(cc.Node) red: cc.Node = null; private selState = false /** 数据 * index 下标 从0开始 getDay 第x天可领取 rewardType 奖励类型 1:红包币 2:汽车 rewardNum 奖励数量/汽车等级 conditionType 获得条件类型 1:累计登陆x天 2:汽车等级达到x级 3:玩家等级达到x级 conditionLv 获得条件累计登陆天数/汽车等级/玩家等级 */ data = null start() { } init(data, hasGet) { this.data = data //console.log("Data:",data); let iconName = '' if (this.data.rewardType == 1) { iconName = 'hongbao' this.icon.node.scale = 0.15 } else { this.icon.node.scale = 0.22 iconName = 'che_' + this.data.rewardNum.toString() } cc.loader.loadRes('daily/' + iconName, cc.SpriteFrame, (err, assets) => { if (err) { cc.error(err); return; } this.icon.getComponent(cc.Sprite).spriteFrame = assets; }) if (hasGet) { this.iconGet.parent.active = true this.iconGet.active = true this.labState.string = '已领取' this.red.active = false } else { this.iconGet.parent.active = false this.iconGet.active = false this.labState.string = `登录${this.data.getDay}天` } this.setSel(false) this.showRed() } showRed() { let red = false let data = null data = DailyData.Instance.dailyCfg[this.node.name] if (DailyData.Instance.dailyGetArr[this.node.name] == '0') { if (GameM.commonData.loginDays >= data.getDay) { if (data.conditionType == 1) { red = true } if (data.conditionType == 2) { if (GameM.commonData.maxCarLevel >= data.conditionLv) { red = true } } else if (data.conditionType == 3) { if (GameM.commonData.roleData.lv >= data.conditionLv) { red = true } } } } this.red.active = red } setSel(sel) { this.selState = sel if (this.selState) { this.bgSel.active = true // this.bgNormal.active = false } else { this.bgSel.active = false // this.bgNormal.active = true } } // update (dt) {} }