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

@@ -19,5 +19,18 @@
"_$type": "cd70cd5e-b4cd-4277-ac0a-2224cfbe89ac",
"scriptPath": "../src/models/UIManager.ts"
}
],
"_$child": [
{
"_$id": "4rxcl2w3",
"_$type": "Panel",
"name": "UIRoot",
"x": -420,
"y": 420,
"width": 1920,
"height": 1080,
"centerX": 0,
"centerY": 0
}
]
}

View File

@@ -1,3 +0,0 @@
{
"uuid": "c0e79324-cca6-4b1c-92fd-b0fb981a9766"
}

View File

@@ -30,6 +30,20 @@
}
],
"_$child": [
{
"_$id": "unwnutvo",
"_$type": "Image",
"name": "Image",
"width": 1080,
"height": 1920,
"alpha": 0.6,
"left": 0,
"right": 0,
"top": 0,
"bottom": 0,
"skin": "res://a98f334e-ce04-4cd0-8fc5-bbdf9b048609",
"color": "#000000"
},
{
"_$id": "0a0ovv4z",
"_$type": "Box",

View File

@@ -5,8 +5,6 @@
"name": "TopBar",
"width": 1920,
"height": 120,
"left": 0,
"right": 0,
"top": 0,
"_$comp": [
{

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