UIFailView.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-09-08 21:39:59
  4. * @LastEditTime: 2021-09-15 00:10:52
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: \zombiefood\assets\script\ui\uiview\Interface\UIFailView.ts
  8. */
  9. import auto_failView from "../../../ui/uidata/Interface/auto_failView";
  10. import UIBase from "../../../framework/ui/UIBase";
  11. import UIHelp from "../../../framework/ui/UIHelp";
  12. import levelManager from "../../../manager/levelManager";
  13. import AccountModel from "../../../data/Account/AccountModel";
  14. import bundleManager from "../../../manager/bundleManager";
  15. import dungeonLogic from "../../../gameLogic/dungeonLogic";
  16. import UITopMenu from "./UITopMenu";
  17. import dungeonManager from "../../../manager/dungeonManager";
  18. import { USER } from "../../../constant/constant-user";
  19. const { ccclass, menu, property } = cc._decorator;
  20. @ccclass
  21. @menu("UI/Interface/UIFailView")
  22. export default class UIFailView extends UIBase {
  23. ui: auto_failView = null;
  24. protected static prefabUrl = "Interface/failView";
  25. protected static className = "UIFailView";
  26. bClick: boolean;
  27. onUILoad() {
  28. this.ui = this.node.addComponent(auto_failView);
  29. cc.director.getScene().getChildByName('Canvas').getChildByName('redWarn').active = false;
  30. zjSdk?.showGameOver();
  31. }
  32. onShow() {
  33. this.initFrames();
  34. }
  35. initFrames() {
  36. bundleManager.setBundleFrame('UI', 'main/level' + this.getNextLevel(), this.ui.target_img);
  37. }
  38. reStart() {
  39. if (this.bClick) {
  40. return;
  41. }
  42. this.bClick = true;
  43. AccountModel.getInstance().reliveNum = USER.reLiveNum;
  44. zjSdk?.hideGameOver();
  45. zjSdk?.gameBegin(() => {
  46. UITopMenu.getInstance().initData();
  47. this.removeDungeonView();
  48. levelManager.open(this.getNextLevel(), () => {
  49. AccountModel.getInstance().show_crazy_in_level = 0;
  50. cc.director.getScene().getChildByName('Canvas').getChildByName('maskNode').opacity = 0;
  51. UITopMenu.getInstance().node.active = true;
  52. dungeonManager.resetDungen();
  53. this.onClose();
  54. }, true);
  55. })
  56. }
  57. getNextLevel() {
  58. let curLevel = AccountModel.getInstance().curLevel;
  59. if (curLevel > 1) {
  60. curLevel = 2; //死亡后都从第二关开始
  61. }
  62. return curLevel;
  63. }
  64. removeDungeonView() {
  65. var cavans = cc.director.getScene().getChildByName('world').children;
  66. cavans.forEach((node) => {
  67. let com = node.getComponent(dungeonLogic);
  68. if (com) {
  69. node.destroy();
  70. return;
  71. }
  72. })
  73. }
  74. onClose() {
  75. UIHelp.CloseUI(UIFailView);
  76. }
  77. }