PigBank.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. // let target_node = gData.gameData.gameStyle.icon_hb;
  22. // const end_world_pos = target_node.parent.convertToWorldSpaceAR(target_node.getPosition());
  23. // const end_node_pos = gData.gameData.gameStyle.node.parent.convertToNodeSpaceAR(end_world_pos);
  24. // let start_node_pos = new cc.Vec2(0, -300);
  25. // mk.fly.PlayCoinAnim(1, 10, start_node_pos, end_node_pos, () => {
  26. // if (!gData.gameData.init_coin) gData.gameData.gameData.redMoney = 1234
  27. // });
  28. }
  29. update(dt) {
  30. if (gData.pigbank.init_data) {
  31. this.initCashDesc();
  32. }
  33. if (gData.pigbank.adData) {
  34. cc.log('存钱罐提现', gData.pigbank.adData)
  35. }
  36. }
  37. lateUpdate() {
  38. gData.pigbank.init_data = false;
  39. gData.pigbank.adData = null;
  40. }
  41. /**
  42. * 提现描述展示
  43. */
  44. private initCashDesc() {
  45. if (gData.gameData.gameData.isWithdrawable) {
  46. this.lbl_get_desc.string = '直接提现';
  47. this.node_tip_anim.active = false;
  48. this.anim_btn_cash.play();
  49. } else {
  50. if (gData.gameData.gameData.piggyBank >= gData.pigbank.cash_min_limit) {
  51. this.lbl_get_desc.string = '明日可提现';
  52. } else {
  53. this.lbl_get_desc.string = '满' + gData.pigbank.cash_min_limit + '元可提';
  54. }
  55. this.node_tip_anim.active = true;
  56. this.anim_btn_cash.stop();
  57. this.anim_btn_cash.node.scale = 1;
  58. }
  59. this.initDeposit()
  60. }
  61. /**
  62. * 初始化存钱罐金额
  63. * - 精确到分
  64. */
  65. private initDeposit() {
  66. const new_count = gData.gameData.gameData.piggyBank.toFixed(2)
  67. this.lbl_deposit.string = new_count + '元';
  68. }
  69. /**
  70. * 提现操作
  71. */
  72. private clickCashOP() {
  73. mk.audio.playEffect("button");
  74. if (!gData.gameData.gameData.isWithdrawable) {
  75. mk.tip.pop('明日可提现')
  76. return;
  77. } else if (gData.gameData.gameData.piggyBank < gData.pigbank.cash_min_limit) {
  78. mk.tip.pop('满' + gData.pigbank.cash_min_limit + '元可提现')
  79. return;
  80. }
  81. gData.pigbank.cashOP();
  82. mk.ui.closePanel(this.node.name);
  83. }
  84. /**
  85. * 打开帮助界面完成回调
  86. */
  87. private async clickOpenHelpCall() {
  88. let des = "1、游戏内观看任意视频,都会获得现金。\n\n2、存款达到0.3元后,次日登陆,可无门槛提现。\n\n3、提现后,存款清零,可重新开始。";
  89. gData.help.des = des;
  90. }
  91. }