OutOfBoxLayer.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { _decorator, Component, Node, tween, v3 } from 'cc';
  2. import BasePanel from '../../../core/component/BasePanel';
  3. import WindowManager from '../../../core/manager/WindowManager';
  4. import GameConst from '../../../core/common/GameConst';
  5. import { Main } from '../Main';
  6. import platformSystem from 'db://assets/platform/platformSystem';
  7. import { constants } from 'db://assets/data/constants';
  8. import audioManager from 'db://assets/manager/audioManager';
  9. const { ccclass, property } = _decorator;
  10. @ccclass('OutOfBoxLayer')
  11. export class OutOfBoxLayer extends BasePanel {
  12. start() {
  13. let btn_clear = this.GetGameObject("btn_clear");
  14. tween(btn_clear).sequence(tween(btn_clear).to(1, { scale: v3(0.8, 0.8, 0.8) }), tween(btn_clear).to(1, { scale: v3(1, 1, 1) })).repeatForever().start()
  15. this.SetText("lbl_coll_star", Main.Instance()._GameUI.star + "");
  16. this.GetGameObject("one-more-chance-bg").active = false;
  17. Main.Instance()._GameUI.pasue = true;
  18. audioManager.playOneShot(constants.audios.softFail);
  19. }
  20. onDestroy() {
  21. super.onDestroy();
  22. Main.Instance()._GameUI.pasue = false;
  23. }
  24. onBtnClicked(event: any, customEventData: any) {
  25. audioManager.playOneShot(constants.audios.btnclick);
  26. var btnName = event.target.name;
  27. switch (btnName) {
  28. case "btn_close":
  29. if (this.GetGameObject("one-more-chance-bg").active == false && Main.Instance()._GameUI.star > 0) {
  30. this.GetGameObject("one-more-chance-bg").active = true;
  31. tween(this.GetGameObject("one-more-chance-bg")).to(1, { position: v3(0, 372, 0) }).start();
  32. return
  33. }
  34. this.close();
  35. WindowManager.ins.open("FailLayer");
  36. break;
  37. case "btn_clear":
  38. platformSystem.platform.showRewardVideo((b) => {
  39. if (b == 0) {
  40. this.dispatch(GameConst.CLEAR_ALL_BOX);
  41. this.close();
  42. } else if (b == -2) {
  43. platformSystem.platform.shareAppMessage((bol) => {
  44. if (bol) {
  45. this.dispatch(GameConst.CLEAR_ALL_BOX);
  46. this.close();
  47. }
  48. })
  49. }
  50. })
  51. break;
  52. }
  53. }
  54. }