Files
sudoku/src/views/GameDone.ts

86 lines
2.9 KiB
TypeScript
Raw Normal View History

2025-05-14 12:17:47 +08:00
import { UIManager } from "../models/UIManager";
import { StorageManager } from "../models/StorageManager";
2025-05-20 17:41:43 +08:00
import { Utility_ConvertSecondToString } from "../utils/utility";
import { respath } from "../constants/respath";
import { Difficulty } from "./Difficulty";
import { LevelManager } from "../models/LevelManager";
import { config } from "../constants/config";
2025-05-14 12:17:47 +08:00
const { regClass, property } = Laya;
@regClass()
export class GameDone extends Laya.Script {
declare owner : Laya.Box;
2025-05-20 17:41:43 +08:00
@property(Laya.Box)
public obj_top: Laya.Box
@property(Laya.Box)
public obj_stars: Laya.Box
@property(Laya.Image)
public obj_star: Laya.Image
@property(Laya.Label)
public label_diffucuty: Laya.Label
@property(Laya.Label)
public label_time: Laya.Label
@property(Laya.Label)
public label_score: Laya.Label
@property(Laya.Box)
public btn_new: Laya.Box
@property(Laya.Box)
public btn_home: Laya.Box
@property(Laya.Box)
public btn_continue: Laya.Box
onStart(): void {
var doStage = StorageManager.getInstance().getStage()
var type = doStage.get_stageType()
if (type == config.STAGE_TYPE.MAIN) {
this.obj_top.y = 356
this.obj_stars.visible = true
this.obj_star.visible = false
this.btn_new.visible = true
this.btn_home.visible = true
this.btn_continue.visible = false
}
else {
this.obj_top.y = 456
this.obj_stars.visible = false
this.obj_star.visible = true
this.btn_new.visible = false
this.btn_home.visible = false
this.btn_continue.visible = true
}
this.label_diffucuty.text = doStage.get_difficulty()
this.label_time.text = Utility_ConvertSecondToString(doStage.get_duration())
this.label_score.text = doStage.get_score().toString()
2025-05-14 12:17:47 +08:00
this.btn_new.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
2025-05-20 17:41:43 +08:00
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().cleanStage()
2025-05-22 19:12:00 +08:00
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value)
2025-05-20 17:41:43 +08:00
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID);
this.owner.destroy()
})
})
})
this.btn_home.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
UIManager.getInstance().loadHomeUI()
UIManager.getInstance().closeStageUI();
this.owner.destroy()
})
this.btn_continue.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
UIManager.getInstance().loadDCUI()
UIManager.getInstance().closeStageUI();
2025-05-14 12:17:47 +08:00
this.owner.destroy()
})
}
}