OutOfBoxLayer.ts 2.4 KB

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