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