补充UI细节 添加每日挑战

This commit is contained in:
2025-05-20 17:41:43 +08:00
parent b6c1e58f35
commit 18785e7387
53 changed files with 8836 additions and 212 deletions

View File

@@ -22,7 +22,7 @@ export class Stage extends Laya.Script {
@property(Laya.Label)
public label_mistake: Laya.Label;
@property(Laya.Label)
public label_diff: Laya.Label;
public label_name: Laya.Label;
@property(Laya.Label)
public label_time: Laya.Label;
@@ -59,8 +59,14 @@ export class Stage extends Laya.Script {
onAwake(): void {
Stage._instance = this
this.btn_back.on(Laya.Event.CLICK, this, ()=>{
UIManager.getInstance().loadHomeUI();
UIManager.getInstance().closeStageUI();
if (this.data.get_stageType() == config.STAGE_TYPE.MAIN) {
UIManager.getInstance().loadHomeUI();
UIManager.getInstance().closeStageUI();
}
else {
UIManager.getInstance().loadDCUI();
UIManager.getInstance().closeStageUI();
}
})
for (var i=0; i<this.obj_blocks.numChildren; i++) {
var hbox = this.obj_blocks.getChildAt(i);
@@ -116,7 +122,7 @@ export class Stage extends Laya.Script {
this.data = doStage
this.onUpdateScore()
this.label_diff.text = this.data.get_difficulty()
this.label_name.text = this.data.get_stageName()
this.onUpdateMistake()
var begin = Date.now()
Laya.timer.loop(1000, this, ()=>{
@@ -143,13 +149,14 @@ export class Stage extends Laya.Script {
this.onApplyBlock(this.selectedBlock)
}
onUpdateScore(): void {
onUpdateScore(): number {
var score = 0
var blocks = this.data.get_blocks()
for (var i=0; i<blocks.length; i++) {
score += blocks[i].get_score()
}
this.label_score.text = `Score: ${score}`
return score
}
onUpdateMistake(): void {
@@ -341,20 +348,28 @@ export class Stage extends Laya.Script {
}
else {
var b = this.selectedBlock.setShowNumber(showNumber)
this.onUpdateScore()
var score = this.onUpdateScore()
this.onSetBlock(this.selectedBlock, true)
if (b) {
var user = StorageManager.getInstance().getUser()
var all = 0
var finished = 0
var blocks = this.data.get_blocks()
for (var i=0; i<blocks.length; i++) {
if (blocks[i].get_preset() == false) {
all ++
if (blocks[i].get_checked()) {
finished ++
}
}
}
user.update_stage_done(this.data.get_stageID(), finished/all)//更新关卡完成进度
if (this.getIsComplete()) {
console.log("完成关卡")
StorageManager.getInstance().cleanStage(this.data.get_stageID())//完成关卡清除关卡数据
var user = StorageManager.getInstance().getUser()
if (this.data.get_stageType() == config.STAGE_TYPE.MAIN) {
user.set_isCompletedMain(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)
}
else if (this.data.get_stageType() == config.STAGE_TYPE.DC) {
user.add_done(this.data.get_stageID())
}
UIManager.getInstance().loadGameDoneUI()
}
}