DailyDownItem.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import GameM from "../manager/GameM";
  2. import Sciencen_M from "../utils/Sciencen_M";
  3. const { ccclass, property } = cc._decorator;
  4. @ccclass
  5. export default class DailyDownItem extends cc.Component {
  6. @property(cc.Node)
  7. hongbaoNode: cc.Node = null;
  8. @property(cc.Label)
  9. labMoney: cc.Label = null;
  10. @property(cc.Label)
  11. labCash: cc.Label = null;
  12. @property(cc.Node)
  13. cheNode: cc.Node = null;
  14. @property(cc.Sprite)
  15. iconLv: cc.Sprite = null;
  16. @property(cc.Mask)
  17. mask: cc.Mask = null;
  18. @property(cc.RichText)
  19. labPro: cc.RichText = null;
  20. @property(cc.Sprite)
  21. iconChe: cc.Sprite = null;
  22. /** 数据
  23. * index 下标 从0开始
  24. getDay 第x天可领取
  25. rewardType 奖励类型 1:红包币 2:汽车
  26. rewardNum 奖励数量/汽车等级
  27. conditionType 获得条件类型 1:累计登陆x天 2:汽车等级达到x级 3:玩家等级达到x级
  28. conditionLv 获得条件累计登陆天数/汽车等级/玩家等级
  29. */
  30. data = null
  31. init(data) {
  32. this.data = data
  33. if (this.data.rewardType == 1) {
  34. this.hongbaoNode.active = true
  35. this.cheNode.active = false
  36. this.labMoney.string = `${this.data.rewardNum}`
  37. this.labCash.string = `≈ ${(this.data.rewardNum * 0.0001).toFixed(2)}元`
  38. }
  39. else {
  40. this.hongbaoNode.active = false
  41. this.cheNode.active = true
  42. let numName = ''
  43. let iconName = ''
  44. numName = 'num_' + this.data.rewardNum.toString()
  45. iconName = 'che_' + this.data.rewardNum.toString()
  46. cc.loader.loadRes('daily/' + numName, cc.SpriteFrame, (err, assets) => {
  47. if (err) {
  48. cc.error(err);
  49. return;
  50. }
  51. this.iconLv.getComponent(cc.Sprite).spriteFrame = assets;
  52. })
  53. cc.loader.loadRes('daily/' + iconName, cc.SpriteFrame, (err, assets) => {
  54. if (err) {
  55. cc.error(err);
  56. return;
  57. }
  58. this.iconChe.getComponent(cc.Sprite).spriteFrame = assets;
  59. this.mask.spriteFrame = assets;
  60. //this.mask.node.width = this.iconChe.node.width
  61. //this.mask.node.height = this.iconChe.node.height
  62. })
  63. // cc.loader.loadRes('daily/' + iconName, cc.SpriteFrame, (err, assets) => {
  64. // if (err) {
  65. // cc.error(err);
  66. // return;
  67. // }
  68. // this.iconChe.getComponent(cc.Sprite).spriteFrame = assets;
  69. // this.mask.spriteFrame = assets;
  70. // this.mask.node.width = this.iconChe.node.width
  71. // this.mask.node.height = this.iconChe.node.height
  72. // })
  73. if (!this.data.cash) {
  74. let getNum = Sciencen_M.instance.format(GameM.commonData.carCfg[this.data.rewardNum.toString()].money, false)
  75. this.labPro.string = `每圈收益增加<color=#FCFF04><size=36>${getNum}</size></c>金币`
  76. }
  77. else {
  78. this.labPro.string = `领取后<color=#ff1206 fontsize=><size=36>${this.data.cash}元</size></c>提现进度增加<color=#ff1206><size=36>${this.data.pro}%</size></c>`
  79. }
  80. }
  81. }
  82. }