PigBank.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. const { ccclass, property } = cc._decorator;
  2. /**
  3. * 存钱罐界面样式
  4. * @author 薛鸿潇
  5. */
  6. @ccclass
  7. export default class PigBank extends cc.Component {
  8. @property({ type: cc.Label, displayName: '按钮描述' })
  9. private lbl_get_desc: cc.Label = null!;
  10. @property({ type: cc.Label, displayName: '存款数量' })
  11. private lbl_deposit: cc.Label = null!;
  12. @property({ type: cc.Node, displayName: '提示动画' })
  13. private node_tip_anim: cc.Node = null!;
  14. @property({ type: cc.Animation, displayName: '提现动画' })
  15. private anim_btn_cash: cc.Animation = null!;
  16. onLoad() {
  17. }
  18. start() {
  19. this.initCashDesc();
  20. mk.audio.playEffect("pigBank",false);
  21. }
  22. update(dt) {
  23. if (gData.pigbank.init_data) {
  24. this.initCashDesc();
  25. }
  26. if (gData.pigbank.adData) {
  27. cc.log('存钱罐提现', gData.pigbank.adData)
  28. }
  29. }
  30. lateUpdate() {
  31. gData.pigbank.init_data = false;
  32. gData.pigbank.adData = null;
  33. }
  34. /**
  35. * 提现描述展示
  36. */
  37. private initCashDesc() {
  38. if (gData.pigbank.cash_enable) {
  39. this.lbl_get_desc.string = '直接提现';
  40. this.node_tip_anim.active = false;
  41. this.anim_btn_cash.play();
  42. } else {
  43. if (gData.pigbank.cur_cash_count >= gData.pigbank.cash_min_limit) {
  44. this.lbl_get_desc.string = '明日可提现';
  45. } else {
  46. this.lbl_get_desc.string = '满' + gData.pigbank.cash_min_limit + '元可提';
  47. }
  48. this.node_tip_anim.active = true;
  49. this.anim_btn_cash.stop();
  50. this.anim_btn_cash.node.scale = 1;
  51. }
  52. this.initDeposit()
  53. }
  54. /**
  55. * 初始化存钱罐金额
  56. * - 精确到分
  57. */
  58. private initDeposit() {
  59. const new_count = gData.pigbank.cur_cash_count.toFixed(2)
  60. this.lbl_deposit.string = new_count + '元';
  61. }
  62. /**
  63. * 提现操作
  64. */
  65. private clickCashOP() {
  66. if (!gData.pigbank.cash_enable) return;
  67. gData.pigbank.cashOP();
  68. mk.ui.closePanel(this.node.name);
  69. }
  70. /**
  71. * 打开帮助界面完成回调
  72. */
  73. private async clickOpenHelpCall() {
  74. let des = "1、游戏内观看任意视频,都会获得现金。\n\n2、存款达到0.3元后,次日登陆,可无门槛提现。\n\n3、提现后,存款清零,可重新开始。";
  75. gData.help.des = des;
  76. }
  77. }