2025-05-28 18:47:51 +08:00
|
|
|
import type { DOStage } from "../models/DOStage"
|
|
|
|
|
import { config } from "../constants/config"
|
|
|
|
|
import { respath } from "../constants/respath"
|
2025-06-10 18:24:50 +08:00
|
|
|
import { ResourceManager } from "../models/ResourceManager"
|
2025-05-28 18:47:51 +08:00
|
|
|
import { StorageManager } from "../models/StorageManager"
|
|
|
|
|
import { UIManager } from "../models/UIManager"
|
|
|
|
|
import { Utility_ConvertSecondToString } from "../utils/utility"
|
|
|
|
|
import { Difficulty } from "./Difficulty"
|
2025-05-14 12:17:47 +08:00
|
|
|
|
2025-05-28 18:47:51 +08:00
|
|
|
const { regClass, property } = Laya
|
2025-05-14 12:17:47 +08:00
|
|
|
|
|
|
|
|
@regClass()
|
|
|
|
|
export class GameDone extends Laya.Script {
|
2025-05-28 18:47:51 +08:00
|
|
|
declare owner: Laya.Box
|
2025-05-14 12:17:47 +08:00
|
|
|
|
2025-06-09 20:00:33 +08:00
|
|
|
@property(Laya.Image)
|
|
|
|
|
public bg: Laya.Image
|
|
|
|
|
|
2025-05-29 19:03:29 +08:00
|
|
|
@property(Laya.Image)
|
|
|
|
|
public obj_light: Laya.Image
|
|
|
|
|
|
2025-06-12 17:29:23 +08:00
|
|
|
@property(Laya.Image)
|
|
|
|
|
public obj_top: Laya.Image
|
|
|
|
|
|
2025-05-29 19:03:29 +08:00
|
|
|
@property(Laya.Box)
|
2025-05-30 18:15:18 +08:00
|
|
|
public obj_panel: Laya.Box
|
2025-05-29 19:03:29 +08:00
|
|
|
|
|
|
|
|
@property(Laya.Image)
|
|
|
|
|
public star1: Laya.Image
|
|
|
|
|
|
|
|
|
|
@property(Laya.Image)
|
|
|
|
|
public star2: Laya.Image
|
|
|
|
|
|
2025-06-04 17:12:03 +08:00
|
|
|
@property(Laya.Image)
|
|
|
|
|
public star3: Laya.Image
|
|
|
|
|
|
2025-05-30 15:36:46 +08:00
|
|
|
@property(Laya.Image)
|
|
|
|
|
public star4: Laya.Image
|
|
|
|
|
|
2025-05-28 18:47:51 +08:00
|
|
|
@property(Laya.Label)
|
|
|
|
|
public label_diffucuty: Laya.Label
|
2025-05-20 17:41:43 +08:00
|
|
|
|
2025-05-28 18:47:51 +08:00
|
|
|
@property(Laya.Label)
|
|
|
|
|
public label_time: Laya.Label
|
2025-05-20 17:41:43 +08:00
|
|
|
|
2025-05-28 18:47:51 +08:00
|
|
|
@property(Laya.Label)
|
|
|
|
|
public label_score: Laya.Label
|
2025-05-20 17:41:43 +08:00
|
|
|
|
2025-05-28 18:47:51 +08:00
|
|
|
@property(Laya.Box)
|
|
|
|
|
public btn_new: Laya.Box
|
2025-05-26 19:57:17 +08:00
|
|
|
|
2025-05-28 18:47:51 +08:00
|
|
|
@property(Laya.Box)
|
|
|
|
|
public btn_home: Laya.Box
|
2025-05-26 19:57:17 +08:00
|
|
|
|
2025-05-28 18:47:51 +08:00
|
|
|
@property(Laya.Box)
|
|
|
|
|
public btn_continue: Laya.Box
|
2025-05-14 12:17:47 +08:00
|
|
|
|
2025-05-30 18:15:18 +08:00
|
|
|
onAwake(): void {
|
2025-06-09 20:00:33 +08:00
|
|
|
ResourceManager.getInstance().loadTexture(respath.bg_done, this.bg)
|
2025-06-13 18:13:16 +08:00
|
|
|
ResourceManager.getInstance().loadTexture(respath.bg_done_light, this.obj_light)
|
|
|
|
|
ResourceManager.getInstance().loadTexture(respath.bg_done_top, this.obj_top)
|
2025-06-11 20:19:10 +08:00
|
|
|
ResourceManager.getInstance().loadTexture(respath.icon_star2, this.star1)
|
|
|
|
|
ResourceManager.getInstance().loadTexture(respath.icon_star2, this.star2)
|
|
|
|
|
ResourceManager.getInstance().loadTexture(respath.icon_star2, this.star3)
|
|
|
|
|
ResourceManager.getInstance().loadTexture(respath.icon_star1, this.star4)
|
2025-06-10 18:24:50 +08:00
|
|
|
|
2025-05-29 19:03:29 +08:00
|
|
|
this.owner.x = 0
|
2025-05-30 19:00:27 +08:00
|
|
|
this.owner.y = 0
|
2025-05-29 19:03:29 +08:00
|
|
|
|
2025-05-30 18:15:18 +08:00
|
|
|
this.obj_panel.alpha = 0
|
|
|
|
|
this.obj_panel.scaleX = 0.8
|
|
|
|
|
this.obj_panel.scaleY = 0.8
|
2025-05-29 19:03:29 +08:00
|
|
|
|
|
|
|
|
this.star1.scaleX = 1.2
|
|
|
|
|
this.star1.scaleY = 1.2
|
2025-05-30 18:15:18 +08:00
|
|
|
|
|
|
|
|
this.star2.scaleX = 1.2
|
|
|
|
|
this.star2.scaleY = 1.2
|
|
|
|
|
|
2025-06-04 17:12:03 +08:00
|
|
|
this.star3.scaleX = 1.2
|
|
|
|
|
this.star3.scaleY = 1.2
|
|
|
|
|
|
2025-05-30 18:15:18 +08:00
|
|
|
this.star4.scaleX = 1.2
|
|
|
|
|
this.star4.scaleY = 1.2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onStart(): void {
|
2025-05-30 19:00:27 +08:00
|
|
|
// Laya.Tween.to(this.owner, { y: 0 }, 300, Laya.Ease.elasticOut)
|
2025-05-30 18:15:18 +08:00
|
|
|
|
|
|
|
|
Laya.Tween.to(this.obj_panel, { alpha: 1 }, 400, Laya.Ease.elasticOut, null, 100)
|
|
|
|
|
Laya.Tween.to(this.obj_panel, { scaleX: 1, scaleY: 1 }, 400, Laya.Ease.elasticOut, null, 100)
|
|
|
|
|
|
2025-05-29 19:15:32 +08:00
|
|
|
Laya.Tween.to(this.star1, { scaleX: 1, scaleY: 1 }, 300, Laya.Ease.elasticOut, null, 400)
|
2025-05-29 19:03:29 +08:00
|
|
|
const y1 = this.star1.y
|
|
|
|
|
this.star1.y = y1 - 10
|
2025-05-29 19:15:32 +08:00
|
|
|
Laya.Tween.to(this.star1, { y: y1 }, 300, Laya.Ease.elasticOut, null, 400)
|
2025-05-29 19:03:29 +08:00
|
|
|
|
2025-05-29 19:15:32 +08:00
|
|
|
Laya.Tween.to(this.star2, { scaleX: 1, scaleY: 1 }, 300, Laya.Ease.elasticOut, null, 600)
|
2025-05-29 19:03:29 +08:00
|
|
|
const y2 = this.star2.y
|
|
|
|
|
this.star2.y = y2 - 10
|
2025-05-29 19:15:32 +08:00
|
|
|
Laya.Tween.to(this.star2, { y: y2 }, 300, Laya.Ease.elasticOut, null, 600)
|
2025-05-29 19:03:29 +08:00
|
|
|
|
2025-06-04 17:12:03 +08:00
|
|
|
Laya.Tween.to(this.star3, { scaleX: 1, scaleY: 1 }, 300, Laya.Ease.elasticOut, null, 800)
|
|
|
|
|
const y3 = this.star3.y
|
|
|
|
|
this.star3.y = y3 - 10
|
|
|
|
|
Laya.Tween.to(this.star3, { y: y3 }, 300, Laya.Ease.elasticOut, null, 800)
|
|
|
|
|
|
2025-05-30 15:36:46 +08:00
|
|
|
Laya.Tween.to(this.star4, { scaleX: 1, scaleY: 1 }, 300, Laya.Ease.elasticOut, null, 600)
|
|
|
|
|
const y4 = this.star4.y
|
|
|
|
|
this.star4.y = y4 - 10
|
|
|
|
|
Laya.Tween.to(this.star4, { y: y4 }, 300, Laya.Ease.elasticOut, null, 600)
|
|
|
|
|
|
2025-05-29 19:03:29 +08:00
|
|
|
this.obj_light.alpha = 0
|
2025-06-04 17:12:03 +08:00
|
|
|
Laya.Tween.to(this.obj_light, { alpha: 0.2 }, 500, Laya.Ease.elasticOut, null, 1000)
|
2025-05-28 18:47:51 +08:00
|
|
|
|
2025-05-29 19:03:29 +08:00
|
|
|
this.btn_new.alpha = 0
|
2025-06-04 17:12:03 +08:00
|
|
|
Laya.Tween.to(this.btn_new, { alpha: 1 }, 300, Laya.Ease.elasticOut, null, 1200)
|
2025-05-28 18:47:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public onSetStageInfo(doStage: DOStage): void {
|
|
|
|
|
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-28 20:29:24 +08:00
|
|
|
this.btn_new.on(Laya.Event.CLICK, this, () => {
|
2025-05-28 18:47:51 +08:00
|
|
|
if (config.H_SCREEN) {
|
|
|
|
|
const user = StorageManager.getInstance().getUser()
|
|
|
|
|
user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex() + 1)// 主线关卡更新难度进度
|
|
|
|
|
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, doStage.get_difficulty(), doStage.get_difficulty())
|
|
|
|
|
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
|
|
|
|
|
this.owner.destroy()
|
|
|
|
|
} else {
|
2025-06-10 18:24:50 +08:00
|
|
|
ResourceManager.getInstance().loadPrefab(respath.difficulty_ui_res, (go: any) => {
|
2025-05-28 18:47:51 +08:00
|
|
|
const prefab = go.create()
|
|
|
|
|
const d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty)
|
|
|
|
|
d.onInit((value: string) => {
|
|
|
|
|
console.log("选择难度", value)
|
|
|
|
|
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value)
|
|
|
|
|
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
|
2025-05-20 17:41:43 +08:00
|
|
|
this.owner.destroy()
|
|
|
|
|
})
|
2025-05-28 18:47:51 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-05-20 17:41:43 +08:00
|
|
|
|
2025-05-28 20:29:24 +08:00
|
|
|
this.btn_continue.on(Laya.Event.CLICK, this, () => { // 这个按钮只有从DC来的会显示
|
2025-05-28 18:47:51 +08:00
|
|
|
UIManager.getInstance().loadDCUI()
|
|
|
|
|
UIManager.getInstance().closeStageUI()
|
|
|
|
|
this.owner.destroy()
|
|
|
|
|
})
|
2025-05-20 17:41:43 +08:00
|
|
|
|
2025-05-28 20:29:24 +08:00
|
|
|
this.btn_home.on(Laya.Event.CLICK, this, () => {
|
2025-05-28 18:47:51 +08:00
|
|
|
if (config.H_SCREEN) {
|
|
|
|
|
UIManager.getInstance().closeDCUI()
|
2025-05-28 19:15:32 +08:00
|
|
|
if (doStage.get_stageType() === config.STAGE_TYPE.MAIN) {
|
2025-05-28 18:47:51 +08:00
|
|
|
const user = StorageManager.getInstance().getUser()
|
|
|
|
|
user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex() + 1)// 主线关卡更新难度进度
|
|
|
|
|
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, doStage.get_difficulty(), doStage.get_difficulty())
|
|
|
|
|
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
|
2025-05-28 19:15:32 +08:00
|
|
|
} else if (doStage.get_stageType() === config.STAGE_TYPE.DC) {
|
2025-05-28 18:47:51 +08:00
|
|
|
UIManager.getInstance().setTopbarTo(true)
|
2025-05-26 19:57:17 +08:00
|
|
|
}
|
2025-05-28 18:47:51 +08:00
|
|
|
} else {
|
|
|
|
|
UIManager.getInstance().loadHomeUI()
|
|
|
|
|
UIManager.getInstance().closeStageUI()
|
|
|
|
|
}
|
|
|
|
|
this.owner.destroy()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|