游戏结束

This commit is contained in:
2025-05-14 12:17:47 +08:00
parent 2cc01c5570
commit 830bf2bb29
27 changed files with 405 additions and 113 deletions

View File

@@ -73,6 +73,16 @@ export class StorageManager {
return new DOStage(dataStage, levelStr)
}
public cleanStage(): void {
if (this.stageID && this.stageID.length > 0) {
if (this.stageMap.has(this.stageID)) {
this.stageMap.delete(this.stageID)
}
Laya.LocalStorage.removeItem(this.stageID)
this.stageID = ""
}
}
public saveStage(): void {
if (this.changed) {
this.changed = false

View File

@@ -22,6 +22,8 @@ export class UIManager extends Laya.Script {
return UIManager._instance
}
private stage: Stage
public loadHome(): void {
Laya.loader.load(respath.home_ui_res).then((go)=>{
var prefab = go.create()
@@ -29,11 +31,39 @@ export class UIManager extends Laya.Script {
})
}
public loadStage(): void {
Laya.loader.load(respath.stage_ui_res).then((go)=>{
public loadStage(stageID: string, clean: boolean=false): void {
if (clean) {
StorageManager.getInstance().cleanStage()
}
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.onLoadStage(StorageManager.getInstance().loadStage(stageID))
})
}
}
public closeStage(): void {
if (this.stage) {
this.stage.owner.destroy()
this.stage = null
}
}
public loadGameOver(): void {
Laya.loader.load(respath.gameover_ui_res).then((go)=>{
var prefab = go.create()
var stage = this.owner.addChild(prefab).getComponent(Stage)
stage.onLoadStage(StorageManager.getInstance().loadStage("first"))
this.owner.addChild(prefab)
})
}
public loadGameDone(): void {
Laya.loader.load(respath.gamedone_ui_res).then((go)=>{
var prefab = go.create()
this.owner.addChild(prefab)
})
}