| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- import GameM from "../manager/GameM";
- import Sciencen_M from "../utils/Sciencen_M";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class DailyDownItem extends cc.Component {
- @property(cc.Node)
- hongbaoNode: cc.Node = null;
- @property(cc.Label)
- labMoney: cc.Label = null;
- @property(cc.Label)
- labCash: cc.Label = null;
- @property(cc.Node)
- cheNode: cc.Node = null;
- @property(cc.Sprite)
- iconLv: cc.Sprite = null;
- @property(cc.Mask)
- mask: cc.Mask = null;
- @property(cc.RichText)
- labPro: cc.RichText = null;
- @property(cc.Sprite)
- iconChe: cc.Sprite = null;
- /** 数据
- * index 下标 从0开始
- getDay 第x天可领取
- rewardType 奖励类型 1:红包币 2:汽车
- rewardNum 奖励数量/汽车等级
- conditionType 获得条件类型 1:累计登陆x天 2:汽车等级达到x级 3:玩家等级达到x级
- conditionLv 获得条件累计登陆天数/汽车等级/玩家等级
- */
- data = null
- init(data) {
- this.data = data
- if (this.data.rewardType == 1) {
- this.hongbaoNode.active = true
- this.cheNode.active = false
- this.labMoney.string = `${this.data.rewardNum}`
- this.labCash.string = `≈ ${(this.data.rewardNum * 0.0001).toFixed(2)}元`
- }
- else {
- this.hongbaoNode.active = false
- this.cheNode.active = true
- let numName = ''
- let iconName = ''
- numName = 'num_' + this.data.rewardNum.toString()
- iconName = 'che_' + this.data.rewardNum.toString()
- cc.loader.loadRes('daily/' + numName, cc.SpriteFrame, (err, assets) => {
- if (err) {
- cc.error(err);
- return;
- }
- this.iconLv.getComponent(cc.Sprite).spriteFrame = assets;
- })
- cc.loader.loadRes('daily/' + iconName, cc.SpriteFrame, (err, assets) => {
- if (err) {
- cc.error(err);
- return;
- }
- this.iconChe.getComponent(cc.Sprite).spriteFrame = assets;
- this.mask.spriteFrame = assets;
- //this.mask.node.width = this.iconChe.node.width
- //this.mask.node.height = this.iconChe.node.height
- })
- // cc.loader.loadRes('daily/' + iconName, cc.SpriteFrame, (err, assets) => {
- // if (err) {
- // cc.error(err);
- // return;
- // }
- // this.iconChe.getComponent(cc.Sprite).spriteFrame = assets;
- // this.mask.spriteFrame = assets;
- // this.mask.node.width = this.iconChe.node.width
- // this.mask.node.height = this.iconChe.node.height
- // })
- if (!this.data.cash) {
- let getNum = Sciencen_M.instance.format(GameM.commonData.carCfg[this.data.rewardNum.toString()].money, false)
- this.labPro.string = `每圈收益增加<color=#FCFF04><size=36>${getNum}</size></c>金币`
- }
- else {
- this.labPro.string = `领取后<color=#ff1206 fontsize=><size=36>${this.data.cash}元</size></c>提现进度增加<color=#ff1206><size=36>${this.data.pro}%</size></c>`
- }
- }
- }
- }
|