完善关卡逻辑
This commit is contained in:
@@ -12,10 +12,10 @@ export class UIManager extends Laya.Script {
|
||||
private static _instance: UIManager
|
||||
onAwake(): void {
|
||||
UIManager._instance = this
|
||||
}
|
||||
|
||||
StorageManager.getInstance().init()
|
||||
|
||||
this.loadHome()
|
||||
onStart(): void {
|
||||
this.loadHomeUI()
|
||||
}
|
||||
|
||||
public static getInstance(): UIManager {
|
||||
@@ -24,51 +24,49 @@ export class UIManager extends Laya.Script {
|
||||
|
||||
private stage: Stage
|
||||
|
||||
public loadHome(): void {
|
||||
|
||||
public getUIRoot(): Laya.Node {
|
||||
return this.owner
|
||||
}
|
||||
|
||||
public loadHomeUI(): void {
|
||||
Laya.loader.load(respath.home_ui_res).then((go)=>{
|
||||
var prefab = go.create()
|
||||
this.owner.addChild(prefab)
|
||||
this.getUIRoot().addChild(prefab)
|
||||
})
|
||||
}
|
||||
|
||||
public loadStage(stageID: string, clean: boolean=false): void {
|
||||
if (clean) {
|
||||
StorageManager.getInstance().cleanStage()
|
||||
}
|
||||
public loadStageUI(stageID: string): void {
|
||||
if (this.stage) {
|
||||
this.stage.onLoadStage(StorageManager.getInstance().loadStage(stageID))
|
||||
}
|
||||
else {
|
||||
Laya.loader.load(respath.stage_ui_res).then((go)=>{
|
||||
var prefab = go.create()
|
||||
this.stage = this.owner.addChild(prefab).getComponent(Stage)
|
||||
this.stage = this.getUIRoot().addChild(prefab).getComponent(Stage)
|
||||
this.stage.onLoadStage(StorageManager.getInstance().loadStage(stageID))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
public closeStage(): void {
|
||||
public closeStageUI(): void {
|
||||
if (this.stage) {
|
||||
this.stage.owner.destroy()
|
||||
this.stage = null
|
||||
}
|
||||
}
|
||||
|
||||
public loadGameOver(): void {
|
||||
public loadGameOverUI(): void {
|
||||
Laya.loader.load(respath.gameover_ui_res).then((go)=>{
|
||||
var prefab = go.create()
|
||||
this.owner.addChild(prefab)
|
||||
this.getUIRoot().addChild(prefab)
|
||||
})
|
||||
}
|
||||
public loadGameDone(): void {
|
||||
public loadGameDoneUI(): void {
|
||||
Laya.loader.load(respath.gamedone_ui_res).then((go)=>{
|
||||
var prefab = go.create()
|
||||
this.owner.addChild(prefab)
|
||||
this.getUIRoot().addChild(prefab)
|
||||
})
|
||||
}
|
||||
|
||||
onLateUpdate(): void {
|
||||
StorageManager.getInstance().saveStage()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user