UIRoot
This commit is contained in:
@@ -19,5 +19,18 @@
|
|||||||
"_$type": "cd70cd5e-b4cd-4277-ac0a-2224cfbe89ac",
|
"_$type": "cd70cd5e-b4cd-4277-ac0a-2224cfbe89ac",
|
||||||
"scriptPath": "../src/models/UIManager.ts"
|
"scriptPath": "../src/models/UIManager.ts"
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"_$child": [
|
||||||
|
{
|
||||||
|
"_$id": "4rxcl2w3",
|
||||||
|
"_$type": "Panel",
|
||||||
|
"name": "UIRoot",
|
||||||
|
"x": -420,
|
||||||
|
"y": 420,
|
||||||
|
"width": 1920,
|
||||||
|
"height": 1080,
|
||||||
|
"centerX": 0,
|
||||||
|
"centerY": 0
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"uuid": "c0e79324-cca6-4b1c-92fd-b0fb981a9766"
|
|
||||||
}
|
|
||||||
@@ -30,6 +30,20 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_$child": [
|
"_$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",
|
"_$id": "0a0ovv4z",
|
||||||
"_$type": "Box",
|
"_$type": "Box",
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
"name": "TopBar",
|
"name": "TopBar",
|
||||||
"width": 1920,
|
"width": 1920,
|
||||||
"height": 120,
|
"height": 120,
|
||||||
"left": 0,
|
|
||||||
"right": 0,
|
|
||||||
"top": 0,
|
"top": 0,
|
||||||
"_$comp": [
|
"_$comp": [
|
||||||
{
|
{
|
||||||
|
|||||||
10
src/Entry.ts
10
src/Entry.ts
@@ -5,14 +5,14 @@ Laya.addBeforeInitCallback((stageConfig) => {
|
|||||||
console.log(`window innerWidth=${window.innerWidth} innerHeight=${window.innerHeight}`)
|
console.log(`window innerWidth=${window.innerWidth} innerHeight=${window.innerHeight}`)
|
||||||
console.log(`stageConfig designWidth=${stageConfig.designWidth} designWidth=${stageConfig.designHeight}`)
|
console.log(`stageConfig designWidth=${stageConfig.designWidth} designWidth=${stageConfig.designHeight}`)
|
||||||
if (window.innerWidth > window.innerHeight) {
|
if (window.innerWidth > window.innerHeight) {
|
||||||
stageConfig.designWidth = 1920
|
stageConfig.designWidth = config.DESIGN_HEIGHT
|
||||||
stageConfig.designHeight = 1080
|
stageConfig.designHeight = config.DESIGN_WIDTH
|
||||||
stageConfig.scaleMode = "fixedwidth"
|
stageConfig.scaleMode = "fixedauto"
|
||||||
config.H_SCREEN = true
|
config.H_SCREEN = true
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stageConfig.designWidth = 1080
|
stageConfig.designWidth = config.DESIGN_WIDTH
|
||||||
stageConfig.designHeight = 1920
|
stageConfig.designHeight = config.DESIGN_HEIGHT
|
||||||
stageConfig.scaleMode = "fixedheight"
|
stageConfig.scaleMode = "fixedheight"
|
||||||
config.H_SCREEN = false
|
config.H_SCREEN = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
|
|
||||||
|
DESIGN_WIDTH: 1080,
|
||||||
|
DESIGN_HEIGHT: 1920,
|
||||||
H_SCREEN: false, // 是否横屏
|
H_SCREEN: false, // 是否横屏
|
||||||
|
|
||||||
DEBUG: false,
|
DEBUG: false,
|
||||||
|
|||||||
@@ -103,6 +103,13 @@ export class StorageManager {
|
|||||||
return null
|
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 {//载入关卡
|
public loadStage(stageID: string): DOStage {//载入关卡
|
||||||
var doStage = this.getStage(stageID)
|
var doStage = this.getStage(stageID)
|
||||||
if (doStage) {
|
if (doStage) {
|
||||||
|
|||||||
@@ -20,10 +20,36 @@ export class UIManager extends Laya.Script {
|
|||||||
declare owner: Laya.Scene
|
declare owner: Laya.Scene
|
||||||
|
|
||||||
private static _instance: UIManager
|
private static _instance: UIManager
|
||||||
|
public static getInstance(): UIManager {
|
||||||
|
return UIManager._instance
|
||||||
|
}
|
||||||
|
|
||||||
onAwake(): void {
|
onAwake(): void {
|
||||||
UIManager._instance = this
|
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 {
|
onStart(): void {
|
||||||
if (config.H_SCREEN) {
|
if (config.H_SCREEN) {
|
||||||
this.loadTopBarUI()
|
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 {
|
public loadHomeUI(): void {
|
||||||
Laya.loader.load(respath.home_ui_res).then((go)=>{
|
Laya.loader.load(respath.home_ui_res).then((go)=>{
|
||||||
|
|||||||
@@ -187,6 +187,7 @@ export class Stage extends Laya.Script {
|
|||||||
block.setBlockColor(config.BLOCK_COLOR.WHITE)
|
block.setBlockColor(config.BLOCK_COLOR.WHITE)
|
||||||
block.setBlock(doBlock)
|
block.setBlock(doBlock)
|
||||||
block.setTipsBgColor(false)
|
block.setTipsBgColor(false)
|
||||||
|
block.setSelected(false)
|
||||||
}
|
}
|
||||||
this.onUpdateCandys()
|
this.onUpdateCandys()
|
||||||
this.onClickNote(null)
|
this.onClickNote(null)
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export class DailyChallenge extends Laya.Script {
|
|||||||
var stageID = `${year}-${month}-${dayNow}`
|
var stageID = `${year}-${month}-${dayNow}`
|
||||||
var doStage = StorageManager.getInstance().getStage(stageID)
|
var doStage = StorageManager.getInstance().getStage(stageID)
|
||||||
console.log("play >>>>>>>>>>>>>>>>>>>>>>>", stageID, doStage)
|
console.log("play >>>>>>>>>>>>>>>>>>>>>>>", stageID, doStage)
|
||||||
if (!doStage) {
|
if (!doStage || doStage.get_mistake() >= config.MISTAKE_MAX) {
|
||||||
var stageName = `${config.MONTH_ABBRS[month-1]} ${dayNow}`
|
var stageName = `${config.MONTH_ABBRS[month-1]} ${dayNow}`
|
||||||
StorageManager.getInstance().newStage(stageID, config.STAGE_TYPE.DC, stageName)
|
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 stageID = `${info.year}-${info.month}-${day}`
|
||||||
var progress = user.get_done(stageID)
|
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)
|
unit.setCalendarUnit(info.year, info.month, day, open, progress, this, this.onClickUnit)
|
||||||
if (info.year == nowYear && info.month == nowMonth && day == nowDay) {
|
if (info.year == nowYear && info.month == nowMonth && day == nowDay) {
|
||||||
this.selectedUnit = unit
|
this.selectedUnit = unit
|
||||||
|
|||||||
Reference in New Issue
Block a user