TipPanel.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**
  2. * 代码描述
  3. */
  4. import { Audio } from "../../common/src/Audio";
  5. import { GameDataCenter } from "../../common/src/GameDataCenter";
  6. import { UIManager } from "../../common/src/UIManager";
  7. import { Utils } from "../../common/src/Utils";
  8. const { ccclass, property } = cc._decorator;
  9. @ccclass
  10. export class TipPanel extends cc.Component {
  11. @property({ type: cc.Node, tooltip: '面板1' })
  12. panel1: cc.Node = null;
  13. @property({ type: cc.Node, tooltip: '面板2' })
  14. panel2: cc.Node = null;
  15. private insufficient: boolean = true;
  16. onEnable() {
  17. this.panel1.getChildByName('closeButton').on('click', this.onClose, this);
  18. this.panel1.getChildByName('ice').getChildByName('button').on('click', this.onClose, this);
  19. this.panel1.getChildByName('insufficient').getChildByName('button').on('click', this.onGet, this);
  20. this.panel2.getChildByName('closeButton').on('click', this.onClose, this);
  21. this.panel2.getChildByName('button').on('click', this.onDoubleGet, this);
  22. //type: 0.没有泡泡,1.泡泡不多了,2.冰球提示,3.炸弹使用提示
  23. switch (GameDataCenter.tipType) {
  24. case 0:
  25. this.panel1.active = true;
  26. let node = this.panel1.getChildByName('insufficient');
  27. node.active = true;
  28. node.getChildByName('label').getComponent(cc.Label).string = '泡泡用完了';
  29. node.getChildByName('buduile').active = false;
  30. node.getChildByName('yongwanle').active = true;
  31. node.getChildByName('tip').getComponent(cc.Label).string = '获得10个泡泡+激光炮';
  32. let item = node.getChildByName('picture').getChildByName('item');
  33. item.getChildByName('add').active = true;
  34. item.getChildByName('bubble').active = true;
  35. this.insufficient = false;
  36. Utils.btnTween(this.panel1.getChildByName('insufficient').getChildByName('button'));
  37. break;
  38. case 1:
  39. this.panel1.active = true;
  40. this.panel1.getChildByName('insufficient').active = true;
  41. Utils.btnTween(this.panel1.getChildByName('insufficient').getChildByName('button'));
  42. break;
  43. case 2:
  44. this.panel1.active = true;
  45. this.panel1.getChildByName('ice').active = true;
  46. if (GameDataCenter.gameLevel == 31) {
  47. this.panel1.getChildByName('ice').getChildByName('ice').active = true;
  48. }
  49. if (GameDataCenter.gameLevel == 11) {
  50. this.panel1.getChildByName('ice').getChildByName('shitou').active = true;
  51. }
  52. if (GameDataCenter.gameLevel == 12) {
  53. this.panel1.getChildByName('ice').getChildByName('caihong').active = true;
  54. }
  55. break;
  56. case 3:
  57. this.panel2.active = true;
  58. this.panel2.getChildByName('tips').active = true;
  59. Utils.btnTween(this.panel2.getChildByName('button'));
  60. cc.tween(this.panel2.getChildByName('bg'))
  61. .by(0.05, { angle: 1 })
  62. .repeatForever()
  63. .start();
  64. break;
  65. case 4:
  66. this.panel2.active = true;
  67. this.panel2.getChildByName('online').active = true;
  68. this.panel2.getChildByName('button').children[0].getChildByName('label').getComponent(cc.Label).string = '领取';
  69. Utils.btnTween(this.panel2.getChildByName('button'));
  70. cc.tween(this.panel2.getChildByName('bg'))
  71. .by(0.05, { angle: 1 })
  72. .repeatForever()
  73. .start();
  74. }
  75. Utils.openPanel(this.node.getChildByName('panel'));
  76. }
  77. /**关闭 */
  78. private onClose(): void {
  79. Audio.playSoundByPath('tip:res/snd/click');
  80. if (GameDataCenter.tipType == 0) {
  81. UIManager.open('fail:FailPanel');
  82. }
  83. if (GameDataCenter.tipType == 1) {
  84. cc.systemEvent.emit('showTenButton', true);
  85. }
  86. this.node.destroy();
  87. }
  88. /**领取 */
  89. private onGet(): void {
  90. Audio.playSoundByPath('tip:res/snd/click');
  91. this.get();
  92. }
  93. private get(): void {
  94. cc.systemEvent.emit('updateBubble', 10);
  95. if (!this.insufficient) {
  96. cc.systemEvent.emit('updateUI', 'special2', 1);
  97. }
  98. UIManager.close('tip:TipPanel', true);
  99. }
  100. /**双倍领取 */
  101. private onDoubleGet(): void {
  102. Audio.playSoundByPath('tip:res/snd/click');
  103. this.doubleGet();
  104. }
  105. /**双倍领取 */
  106. private doubleGet(): void {
  107. if (GameDataCenter.tipType == 3) {
  108. cc.systemEvent.emit('updateUI', 'special1', 2);
  109. }
  110. else if (GameDataCenter.tipType == 4) {
  111. GameDataCenter.rewarded = [`${Math.floor(Math.random() * 4)}:1`, '4:80'];
  112. UIManager.open('rewarded:RewardedPanel');
  113. cc.systemEvent.emit('startTimer');
  114. }
  115. UIManager.close('tip:TipPanel', true);
  116. }
  117. }