SpeedUpUI.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. const { ccclass, property } = cc._decorator;
  2. @ccclass
  3. export default class SpeedUpUI extends cc.Component {
  4. @property(cc.Label)
  5. private lbl_reward_value: cc.Label = null;
  6. @property(cc.Sprite)
  7. private spr_cash_out: cc.Sprite = null;
  8. @property(cc.Label)
  9. private lbl_progress: cc.Label = null;
  10. @property(cc.Animation)
  11. private node_cash: cc.Animation = null;
  12. @property(cc.Label)
  13. private lbl_remainTimes: cc.Label = null;
  14. start() {
  15. this.initCashOutStyle(gData.gameData.gameData.redMoney);
  16. }
  17. onEnable() {
  18. mk.ad.showBanner();
  19. }
  20. onDisable() {
  21. mk.ad.destoryBanner();
  22. }
  23. update(dt) {
  24. if (gData.reward.add_redbag_value) {
  25. this.initCashOutStyle(gData.gameData.gameData.redMoney + gData.reward.add_redbag_value);
  26. }
  27. }
  28. /**
  29. * 底部提现相关样式
  30. */
  31. private initCashOutStyle(redMoney: number = 0) {
  32. const cash_bar = gData.redBagCash.cash_bar;
  33. let cash_data = gData.redBagCash.getItemDataByIndex(cash_bar);
  34. if (!cash_data) return;
  35. const newRedMoney = redMoney > cash_data.type_value ? cash_data.type_value : redMoney;
  36. this.lbl_reward_value.string = cash_data.money / 100 + '元';
  37. this.lbl_progress.string = newRedMoney + '/' + cash_data.type_value;
  38. const fillRange = newRedMoney / cash_data.type_value >= 1 ? 1 : newRedMoney / cash_data.type_value;
  39. // this.spr_cash_out.fillRange = fillRange;
  40. cc.tween(this.spr_cash_out).to(fillRange, { fillRange: fillRange }).start();
  41. if (redMoney >= cash_data.type_value) {
  42. this.node_cash.play();
  43. } else {
  44. this.node_cash.stop();
  45. }
  46. }
  47. /**
  48. * 提现操作
  49. */
  50. private clickCashOut() {
  51. mk.audio.playEffect("button");
  52. gData.reward.addReward();
  53. mk.ui.closePanel(this.node.name);
  54. // let path = 'module/redBagCash/redBagCash';
  55. // mk.ui.openPanel(path);
  56. }
  57. private clickWatchVideoBtn() {
  58. mk.audio.playEffect("button");
  59. }
  60. private clickCloseBtn() {
  61. mk.audio.playEffect("closeButton");
  62. }
  63. }