格式化代码
This commit is contained in:
		| @@ -1,81 +1,76 @@ | ||||
| import { respath } from "../constants/respath"; | ||||
| import { config } from "../constants/config"; | ||||
| import { UIManager } from "../models/UIManager"; | ||||
| import { StorageManager } from "../models/StorageManager"; | ||||
| import { EventManager, EVENT_TYPES } from "../models/EventManager"; | ||||
| import { Difficulty } from "./Difficulty"; | ||||
| import { DOStage } from "../models/DOStage"; | ||||
| import type { DOStage } from "../models/DOStage" | ||||
| import { config } from "../constants/config" | ||||
| import { respath } from "../constants/respath" | ||||
| import { EVENT_TYPES, EventManager } from "../models/EventManager" | ||||
| import { StorageManager } from "../models/StorageManager" | ||||
| import { UIManager } from "../models/UIManager" | ||||
| import { Difficulty } from "./Difficulty" | ||||
|  | ||||
| const { regClass, property } = Laya; | ||||
| const { regClass, property } = Laya | ||||
|  | ||||
| @regClass() | ||||
| export class GameOver extends Laya.Script { | ||||
|     declare owner : Laya.Box; | ||||
|   declare owner: Laya.Box | ||||
|  | ||||
|   @property(Laya.Sprite) | ||||
|   public btn_second: Laya.Sprite | ||||
|  | ||||
|     @property(Laya.Sprite) | ||||
|     public btn_second: Laya.Sprite | ||||
|   @property(Laya.Sprite) | ||||
|   public btn_restart: Laya.Sprite | ||||
|  | ||||
|     @property(Laya.Sprite) | ||||
|     public btn_restart: Laya.Sprite | ||||
|   @property(Laya.Sprite) | ||||
|   public btn_newOrClose: Laya.Sprite | ||||
|  | ||||
|     @property(Laya.Sprite) | ||||
|     public btn_newOrClose: Laya.Sprite | ||||
|     @property(Laya.Label) | ||||
|     public label_newOrClose: Laya.Label | ||||
|      | ||||
|   @property(Laya.Label) | ||||
|   public label_newOrClose: Laya.Label | ||||
|  | ||||
|     public onSetStageInfo(doStage: DOStage): void { | ||||
|   public onSetStageInfo(doStage: DOStage): void { | ||||
|     this.btn_second.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { | ||||
|       doStage.set_mistake(doStage.get_mistake() - 1) | ||||
|       EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_MISTAKE) | ||||
|       this.owner.destroy() | ||||
|     }) | ||||
|  | ||||
|       this.btn_second.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { | ||||
|             doStage.set_mistake(doStage.get_mistake()-1) | ||||
|             EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_MISTAKE) | ||||
|             this.owner.destroy() | ||||
|     this.btn_restart.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { | ||||
|       const stageID = doStage.get_stageID() | ||||
|       const type = doStage.get_stageType() | ||||
|       const difficulty = doStage.get_difficulty() | ||||
|       StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty) | ||||
|       UIManager.getInstance().loadStageUI(stageID) | ||||
|       this.owner.destroy() | ||||
|     }) | ||||
|  | ||||
|     const type = doStage.get_stageType() | ||||
|     if (type == config.STAGE_TYPE.MAIN) { | ||||
|       this.label_newOrClose.text = "New Game" | ||||
|       this.btn_newOrClose.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { | ||||
|         if (config.H_SCREEN) { | ||||
|           const user = StorageManager.getInstance().getUser() | ||||
|           user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex() + 1)// 主线关卡更新难度进度 | ||||
|           const difficulty = doStage.get_difficulty() | ||||
|           StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty) | ||||
|           UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID) | ||||
|           this.owner.destroy() | ||||
|         } else { | ||||
|           Laya.loader.load(respath.difficulty_ui_res).then((go) => { | ||||
|             const prefab = go.create() | ||||
|             const d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty) | ||||
|             d.onInit((value: string) => { | ||||
|               console.log("选择难度", value) | ||||
|               StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value) | ||||
|               UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID) | ||||
|               this.owner.destroy() | ||||
|             }) | ||||
|           }) | ||||
|         } | ||||
|       }) | ||||
|  | ||||
|       this.btn_restart.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { | ||||
|         var stageID = doStage.get_stageID() | ||||
|         var type = doStage.get_stageType() | ||||
|         var difficulty = doStage.get_difficulty() | ||||
|         StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty) | ||||
|         UIManager.getInstance().loadStageUI(stageID); | ||||
|     } else { | ||||
|       this.label_newOrClose.text = "Close" | ||||
|       this.btn_newOrClose.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { | ||||
|         UIManager.getInstance().loadDCUI() | ||||
|         UIManager.getInstance().closeStageUI() | ||||
|         this.owner.destroy() | ||||
|       }) | ||||
|  | ||||
|       var type = doStage.get_stageType() | ||||
|       if (type == config.STAGE_TYPE.MAIN) { | ||||
|         this.label_newOrClose.text = "New Game" | ||||
|         this.btn_newOrClose.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { | ||||
|           if (config.H_SCREEN) { | ||||
|             var user = StorageManager.getInstance().getUser() | ||||
|             user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex()+1)//主线关卡更新难度进度 | ||||
|             var difficulty = doStage.get_difficulty() | ||||
|             StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty) | ||||
|             UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID); | ||||
|             this.owner.destroy() | ||||
|           } | ||||
|           else { | ||||
|             Laya.loader.load(respath.difficulty_ui_res).then((go)=>{ | ||||
|               var prefab = go.create() | ||||
|               var d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty) | ||||
|               d.onInit((value: string)=> { | ||||
|                 console.log("选择难度", value) | ||||
|                 StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value) | ||||
|                 UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID); | ||||
|                 this.owner.destroy() | ||||
|               }) | ||||
|             })  | ||||
|           } | ||||
|         }) | ||||
|       } | ||||
|       else { | ||||
|         this.label_newOrClose.text = "Close" | ||||
|         this.btn_newOrClose.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { | ||||
|           UIManager.getInstance().loadDCUI() | ||||
|           UIManager.getInstance().closeStageUI(); | ||||
|           this.owner.destroy() | ||||
|         }) | ||||
|       } | ||||
|  | ||||
|     } | ||||
| } | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user