RedBagTask.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import Util from "../../../before/util/Util";
  2. const { ccclass, property } = cc._decorator;
  3. @ccclass
  4. export default class RedBagTask extends cc.Component{
  5. @property({displayName: '数字组', type: cc.Label})
  6. private lbl_value: cc.Label[] = [];
  7. @property({displayName: '任务描述', type: cc.RichText})
  8. private rt_task_des: cc.RichText = null;
  9. @property({displayName: '任务进度条', type: cc.Sprite})
  10. private sp_taskProgress: cc.Sprite = null;
  11. @property({displayName: '任务进度文本', type: cc.Label})
  12. private lbl_taskProgress: cc.Label = null;
  13. @property(cc.Label)
  14. private lbl_reward_value: cc.Label = null;
  15. @property(cc.Sprite)
  16. private spr_cash_out: cc.Sprite = null;
  17. @property(cc.Label)
  18. private lbl_progress: cc.Label = null;
  19. @property(cc.Animation)
  20. private node_cash: cc.Animation = null;
  21. start(){
  22. mk.ad.showBanner();
  23. this.initTaskProgressUI();
  24. this.initCashOutStyle(gData.gameData.gameData.redMoney);
  25. this.showChangePart();
  26. }
  27. update(dt){
  28. if (gData.reward.add_redbag_value) {
  29. this.initCashOutStyle(gData.gameData.gameData.redMoney + gData.reward.add_redbag_value);
  30. }
  31. }
  32. private initTaskProgressUI()
  33. {
  34. cc.tween(this.sp_taskProgress).to(0.2, {fillRange: 0.4}, {onUpdate: ()=>{
  35. let str = this.sp_taskProgress.fillRange * 100;
  36. this.lbl_taskProgress.string = str.toFixed(0) + "%";
  37. }}).start();
  38. cc.tween(this)
  39. }
  40. showChangePart() {
  41. //this.changePart.active = true
  42. let len = this.lbl_value.length;
  43. this.schedule(() => {
  44. for (var i = 0; i < len; i++) {
  45. let ran = Util.rnd(0, 9);
  46. this.lbl_value[i].string = `${ran}`;
  47. }
  48. }, 0.1)
  49. }
  50. /**
  51. * 底部提现相关样式
  52. */
  53. private initCashOutStyle(redMoney: number = 0) {
  54. const cash_bar = gData.redBagCash.cash_bar;
  55. let cash_data = gData.redBagCash.getItemDataByIndex(cash_bar);
  56. if (!cash_data) return;
  57. const newRedMoney = redMoney > cash_data.type_value ? cash_data.type_value : redMoney;
  58. this.lbl_reward_value.string = cash_data.money / 100 + '元';
  59. this.lbl_progress.string = newRedMoney + '/' + cash_data.type_value;
  60. const fillRange = newRedMoney / cash_data.type_value >= 1 ? 1 : newRedMoney / cash_data.type_value;
  61. // this.spr_cash_out.fillRange = fillRange;
  62. cc.tween(this.spr_cash_out).to(fillRange, { fillRange: fillRange }).start();
  63. if (redMoney >= cash_data.type_value) {
  64. this.node_cash.play();
  65. } else {
  66. this.node_cash.stop();
  67. }
  68. }
  69. private clickVideoBtn()
  70. {
  71. }
  72. private clickGetRewardBtn()
  73. {
  74. }
  75. /**
  76. * 提现操作
  77. */
  78. private clickCashOut() {
  79. mk.audio.playEffect("button");
  80. gData.reward.addReward();
  81. mk.ui.closePanel(this.node.name);
  82. // let path = 'module/redBagCash/redBagCash';
  83. // mk.ui.openPanel(path);
  84. }
  85. private clickCloseBtn(){
  86. mk.audio.playEffect("closeButton");
  87. }
  88. }