2025-05-12 22:06:04 +08:00
|
|
|
import { respath } from "../constants/respath"
|
2025-05-13 20:31:44 +08:00
|
|
|
import { StorageManager } from "./StorageManager"
|
2025-05-09 19:10:40 +08:00
|
|
|
import { Stage } from "../views/Stage"
|
2025-05-21 10:15:23 +08:00
|
|
|
import { DailyChallenge } from "../views/DailyChallenge"
|
2025-05-22 14:54:48 +08:00
|
|
|
import { TrophyRecord } from "../types/global"
|
|
|
|
|
import { TrophyClaim } from "../views/TrophyClaim"
|
|
|
|
|
import { TrophyShow } from "../views/TrophyShow"
|
2025-05-09 19:10:40 +08:00
|
|
|
|
2025-05-13 20:31:44 +08:00
|
|
|
|
2025-05-09 19:10:40 +08:00
|
|
|
const { regClass, property } = Laya
|
|
|
|
|
|
|
|
|
|
@regClass()
|
|
|
|
|
export class UIManager extends Laya.Script {
|
2025-05-12 22:06:04 +08:00
|
|
|
declare owner: Laya.Scene
|
2025-05-09 19:10:40 +08:00
|
|
|
|
|
|
|
|
private static _instance: UIManager
|
|
|
|
|
onAwake(): void {
|
|
|
|
|
UIManager._instance = this
|
2025-05-19 19:51:17 +08:00
|
|
|
}
|
2025-05-13 20:31:44 +08:00
|
|
|
|
2025-05-19 19:51:17 +08:00
|
|
|
onStart(): void {
|
|
|
|
|
this.loadHomeUI()
|
2025-05-09 19:10:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static getInstance(): UIManager {
|
|
|
|
|
return UIManager._instance
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-14 12:17:47 +08:00
|
|
|
private stage: Stage
|
|
|
|
|
|
2025-05-19 19:51:17 +08:00
|
|
|
|
|
|
|
|
public getUIRoot(): Laya.Node {
|
|
|
|
|
return this.owner
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public loadHomeUI(): void {
|
2025-05-12 22:06:04 +08:00
|
|
|
Laya.loader.load(respath.home_ui_res).then((go)=>{
|
|
|
|
|
var prefab = go.create()
|
2025-05-19 19:51:17 +08:00
|
|
|
this.getUIRoot().addChild(prefab)
|
2025-05-12 22:06:04 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-20 17:41:43 +08:00
|
|
|
public loadDCUI(): void {
|
|
|
|
|
Laya.loader.load(respath.dc_ui_res).then((go)=>{
|
|
|
|
|
var prefab = go.create()
|
2025-05-21 10:15:23 +08:00
|
|
|
var dc = this.getUIRoot().addChild(prefab).getComponent(DailyChallenge)
|
|
|
|
|
dc.loadWithMonth()
|
2025-05-20 17:41:43 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-22 14:54:48 +08:00
|
|
|
public loadTrophyClaimUI(record: TrophyRecord): void {
|
|
|
|
|
Laya.loader.load(respath.trophy_claim_ui_res).then((go)=>{
|
|
|
|
|
var prefab = go.create()
|
|
|
|
|
var obj = this.getUIRoot().addChild(prefab).getComponent(TrophyClaim)
|
|
|
|
|
obj.onSetShow(record)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-20 21:05:30 +08:00
|
|
|
public loadTrophyUI(): void {
|
|
|
|
|
Laya.loader.load(respath.trophy_ui_res).then((go)=>{
|
|
|
|
|
var prefab = go.create()
|
|
|
|
|
this.getUIRoot().addChild(prefab)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-22 14:54:48 +08:00
|
|
|
public loadTrophyShowUI(record: TrophyRecord): void {
|
|
|
|
|
Laya.loader.load(respath.trophy_show_ui_res).then((go)=>{
|
|
|
|
|
var prefab = go.create()
|
|
|
|
|
var obj = this.getUIRoot().addChild(prefab).getComponent(TrophyShow)
|
|
|
|
|
obj.onSetShow(record)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-19 19:51:17 +08:00
|
|
|
public loadStageUI(stageID: string): void {
|
2025-05-14 12:17:47 +08:00
|
|
|
if (this.stage) {
|
|
|
|
|
this.stage.onLoadStage(StorageManager.getInstance().loadStage(stageID))
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Laya.loader.load(respath.stage_ui_res).then((go)=>{
|
|
|
|
|
var prefab = go.create()
|
2025-05-19 19:51:17 +08:00
|
|
|
this.stage = this.getUIRoot().addChild(prefab).getComponent(Stage)
|
2025-05-14 12:17:47 +08:00
|
|
|
this.stage.onLoadStage(StorageManager.getInstance().loadStage(stageID))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-19 19:51:17 +08:00
|
|
|
public closeStageUI(): void {
|
2025-05-14 12:17:47 +08:00
|
|
|
if (this.stage) {
|
|
|
|
|
this.stage.owner.destroy()
|
|
|
|
|
this.stage = null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-19 19:51:17 +08:00
|
|
|
public loadGameOverUI(): void {
|
2025-05-14 12:17:47 +08:00
|
|
|
Laya.loader.load(respath.gameover_ui_res).then((go)=>{
|
2025-05-12 22:06:04 +08:00
|
|
|
var prefab = go.create()
|
2025-05-19 19:51:17 +08:00
|
|
|
this.getUIRoot().addChild(prefab)
|
2025-05-14 12:17:47 +08:00
|
|
|
})
|
|
|
|
|
}
|
2025-05-19 19:51:17 +08:00
|
|
|
public loadGameDoneUI(): void {
|
2025-05-14 12:17:47 +08:00
|
|
|
Laya.loader.load(respath.gamedone_ui_res).then((go)=>{
|
|
|
|
|
var prefab = go.create()
|
2025-05-19 19:51:17 +08:00
|
|
|
this.getUIRoot().addChild(prefab)
|
2025-05-12 22:06:04 +08:00
|
|
|
})
|
2025-05-09 19:10:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|