补充UI细节 添加每日挑战
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import { UIManager } from "../models/UIManager";
|
||||
import { StorageManager } from "../models/StorageManager";
|
||||
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";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
@@ -7,15 +12,80 @@ const { regClass, property } = Laya;
|
||||
export class GameDone extends Laya.Script {
|
||||
declare owner : Laya.Box;
|
||||
|
||||
@property(Laya.Button)
|
||||
public btn_new: Laya.Button
|
||||
@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()
|
||||
|
||||
//组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
|
||||
onAwake(): void {
|
||||
this.btn_new.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
||||
UIManager.getInstance().closeStage();
|
||||
UIManager.getInstance().loadHome();
|
||||
StorageManager.getInstance().cleanStage()
|
||||
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()
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
var index = user.get_progress(value)
|
||||
var levelStr = LevelManager.getInstance().getLevelStr(value, index)
|
||||
if (!levelStr || levelStr.length <= 0) {//说明当前难度已经打通了,所以给他从头开始
|
||||
user.update_progress(value, 0)
|
||||
}
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value, user.get_progress(value))
|
||||
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();
|
||||
this.owner.destroy()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user