This commit is contained in:
2025-05-26 20:56:15 +08:00
parent 468f40351d
commit 12b16320e6
10 changed files with 79 additions and 23 deletions

View File

@@ -5,14 +5,14 @@ Laya.addBeforeInitCallback((stageConfig) => {
console.log(`window innerWidth=${window.innerWidth} innerHeight=${window.innerHeight}`)
console.log(`stageConfig designWidth=${stageConfig.designWidth} designWidth=${stageConfig.designHeight}`)
if (window.innerWidth > window.innerHeight) {
stageConfig.designWidth = 1920
stageConfig.designHeight = 1080
stageConfig.scaleMode = "fixedwidth"
stageConfig.designWidth = config.DESIGN_HEIGHT
stageConfig.designHeight = config.DESIGN_WIDTH
stageConfig.scaleMode = "fixedauto"
config.H_SCREEN = true
}
else {
stageConfig.designWidth = 1080
stageConfig.designHeight = 1920
stageConfig.designWidth = config.DESIGN_WIDTH
stageConfig.designHeight = config.DESIGN_HEIGHT
stageConfig.scaleMode = "fixedheight"
config.H_SCREEN = false
}

View File

@@ -3,6 +3,8 @@
export const config = {
DESIGN_WIDTH: 1080,
DESIGN_HEIGHT: 1920,
H_SCREEN: false, // 是否横屏
DEBUG: false,

View File

@@ -103,6 +103,13 @@ export class StorageManager {
return null
}
public cleanStage(stageID: string): void {
if (this.stageMap.has(stageID)) {
this.stageMap.delete(stageID)
}
Laya.LocalStorage.removeItem(stageID)
}
public loadStage(stageID: string): DOStage {//载入关卡
var doStage = this.getStage(stageID)
if (doStage) {

View File

@@ -20,10 +20,36 @@ export class UIManager extends Laya.Script {
declare owner: Laya.Scene
private static _instance: UIManager
public static getInstance(): UIManager {
return UIManager._instance
}
onAwake(): void {
UIManager._instance = this
}
private UIRoot: Laya.Panel
public getUIRoot(): Laya.Node {
if (this.UIRoot == null) {
this.UIRoot = this.owner.getChildByName("UIRoot") as Laya.Panel
if (config.H_SCREEN) {
this.UIRoot.width = config.DESIGN_HEIGHT
this.UIRoot.height = config.DESIGN_WIDTH
}
else {
this.UIRoot.width = config.DESIGN_WIDTH
this.UIRoot.height = config.DESIGN_HEIGHT
}
}
return this.UIRoot
}
private stage: Stage
private dc_ui: DailyChallenge
private trophyRoom: TrophyRoom
onStart(): void {
if (config.H_SCREEN) {
this.loadTopBarUI()
@@ -33,18 +59,6 @@ export class UIManager extends Laya.Script {
}
}
public static getInstance(): UIManager {
return UIManager._instance
}
private stage: Stage
private dc_ui: DailyChallenge
private trophyRoom: TrophyRoom
public getUIRoot(): Laya.Node {
return this.owner
}
public loadHomeUI(): void {
Laya.loader.load(respath.home_ui_res).then((go)=>{

View File

@@ -187,6 +187,7 @@ export class Stage extends Laya.Script {
block.setBlockColor(config.BLOCK_COLOR.WHITE)
block.setBlock(doBlock)
block.setTipsBgColor(false)
block.setSelected(false)
}
this.onUpdateCandys()
this.onClickNote(null)

View File

@@ -84,7 +84,7 @@ export class DailyChallenge extends Laya.Script {
var stageID = `${year}-${month}-${dayNow}`
var doStage = StorageManager.getInstance().getStage(stageID)
console.log("play >>>>>>>>>>>>>>>>>>>>>>>", stageID, doStage)
if (!doStage) {
if (!doStage || doStage.get_mistake() >= config.MISTAKE_MAX) {
var stageName = `${config.MONTH_ABBRS[month-1]} ${dayNow}`
StorageManager.getInstance().newStage(stageID, config.STAGE_TYPE.DC, stageName)
}
@@ -190,6 +190,16 @@ export class DailyChallenge extends Laya.Script {
}
var stageID = `${info.year}-${info.month}-${day}`
var progress = user.get_done(stageID)
if (open && progress < 1) {//检查失败的关卡,如果失败了就重置
var doStage = StorageManager.getInstance().getStage(stageID)
if (doStage) {//有关卡数据
if (doStage.get_mistake() >= config.MISTAKE_MAX) {
progress = 0
user.update_stage_done(stageID, 0)
StorageManager.getInstance().cleanStage(stageID)
}
}
}
unit.setCalendarUnit(info.year, info.month, day, open, progress, this, this.onClickUnit)
if (info.year == nowYear && info.month == nowMonth && day == nowDay) {
this.selectedUnit = unit