1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- /*
- * @Author: your name
- * @Date: 2021-09-08 21:39:59
- * @LastEditTime: 2021-09-15 00:10:52
- * @LastEditors: Please set LastEditors
- * @Description: In User Settings Edit
- * @FilePath: \zombiefood\assets\script\ui\uiview\Interface\UIFailView.ts
- */
- import auto_failView from "../../../ui/uidata/Interface/auto_failView";
- import UIBase from "../../../framework/ui/UIBase";
- import UIHelp from "../../../framework/ui/UIHelp";
- import levelManager from "../../../manager/levelManager";
- import AccountModel from "../../../data/Account/AccountModel";
- import bundleManager from "../../../manager/bundleManager";
- import dungeonLogic from "../../../gameLogic/dungeonLogic";
- import UITopMenu from "./UITopMenu";
- import dungeonManager from "../../../manager/dungeonManager";
- import { USER } from "../../../constant/constant-user";
- const { ccclass, menu, property } = cc._decorator;
- @ccclass
- @menu("UI/Interface/UIFailView")
- export default class UIFailView extends UIBase {
- ui: auto_failView = null;
- protected static prefabUrl = "Interface/failView";
- protected static className = "UIFailView";
- bClick: boolean;
- onUILoad() {
- this.ui = this.node.addComponent(auto_failView);
- cc.director.getScene().getChildByName('Canvas').getChildByName('redWarn').active = false;
- zjSdk?.showGameOver();
- }
- onShow() {
- this.initFrames();
- }
- initFrames() {
- bundleManager.setBundleFrame('UI', 'main/level' + this.getNextLevel(), this.ui.target_img);
- }
- reStart() {
- if (this.bClick) {
- return;
- }
- this.bClick = true;
- AccountModel.getInstance().reliveNum = USER.reLiveNum;
- zjSdk?.hideGameOver();
- zjSdk?.gameBegin(() => {
- UITopMenu.getInstance().initData();
- this.removeDungeonView();
- levelManager.open(this.getNextLevel(), () => {
- AccountModel.getInstance().show_crazy_in_level = 0;
- cc.director.getScene().getChildByName('Canvas').getChildByName('maskNode').opacity = 0;
- UITopMenu.getInstance().node.active = true;
- dungeonManager.resetDungen();
- this.onClose();
- }, true);
- })
- }
- getNextLevel() {
- let curLevel = AccountModel.getInstance().curLevel;
- if (curLevel > 1) {
- curLevel = 2; //死亡后都从第二关开始
- }
- return curLevel;
- }
- removeDungeonView() {
- var cavans = cc.director.getScene().getChildByName('world').children;
- cavans.forEach((node) => {
- let com = node.getComponent(dungeonLogic);
- if (com) {
- node.destroy();
- return;
- }
- })
- }
- onClose() {
- UIHelp.CloseUI(UIFailView);
- }
- }
|