puase
This commit is contained in:
@@ -55,6 +55,7 @@ export class Stage extends Laya.Script {
|
||||
|
||||
private data: DOStage;
|
||||
private selectedBlock: Block;
|
||||
private paused: boolean
|
||||
|
||||
private static _instance: Stage
|
||||
onAwake(): void {
|
||||
@@ -122,16 +123,20 @@ export class Stage extends Laya.Script {
|
||||
|
||||
public onLoadStage(doStage: DOStage): void {
|
||||
this.data = doStage
|
||||
|
||||
this.paused = false
|
||||
|
||||
this.onUpdateScore()
|
||||
this.label_name.text = this.data.get_stageName()
|
||||
this.onUpdateMistake()
|
||||
var begin = Date.now()
|
||||
|
||||
this.label_time.text = Utility_ConvertSecondToString(this.data.get_duration())
|
||||
Laya.timer.loop(1000, this, ()=>{
|
||||
var now = Date.now()
|
||||
this.data.set_duration(this.data.get_duration() + Math.floor((now-begin)/1000))
|
||||
begin = now
|
||||
if (this.paused) {
|
||||
return
|
||||
}
|
||||
var last = this.data.get_duration()
|
||||
last ++
|
||||
this.data.set_duration(last)
|
||||
this.label_time.text = Utility_ConvertSecondToString(last)
|
||||
})
|
||||
|
||||
@@ -369,6 +374,7 @@ export class Stage extends Laya.Script {
|
||||
user.update_stage_done(this.data.get_stageID(), finished/all)//更新关卡完成进度
|
||||
if (this.getIsComplete()) {
|
||||
console.log("完成关卡")
|
||||
this.paused = true
|
||||
this.data.set_score(score)
|
||||
if (this.data.get_stageType() == config.STAGE_TYPE.MAIN) {//主线关卡更新难度进度
|
||||
user.update_progress(this.data.get_difficulty(), this.data.get_stageIndex()+1)
|
||||
@@ -381,6 +387,7 @@ export class Stage extends Laya.Script {
|
||||
this.onUpdateMistake()
|
||||
if (this.data.get_mistake() >= config.MISTAKE_MAX) {
|
||||
console.log("关卡失败")
|
||||
this.paused = true
|
||||
UIManager.getInstance().loadGameOverUI()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user