PigBank.ts 3.2 KB

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