diff --git a/assets/Scene.ls b/assets/Scene.ls index 80dcc00..bde55f9 100644 --- a/assets/Scene.ls +++ b/assets/Scene.ls @@ -18,5 +18,69 @@ "_$type": "cd70cd5e-b4cd-4277-ac0a-2224cfbe89ac", "scriptPath": "../src/models/UIManager.ts" } + ], + "_$child": [ + { + "_$id": "w805s9t9", + "_$type": "Box", + "name": "Box", + "width": 1080, + "height": 1920, + "left": 0, + "right": 0, + "top": 0, + "bottom": 0, + "_$child": [ + { + "_$id": "c5b9d1x1", + "_$type": "Image", + "name": "bg", + "x": 118, + "y": 420, + "width": 844, + "height": 1080, + "centerX": 0, + "centerY": 0, + "skin": "res://6ad19646-ed7a-431c-a50e-65c2bcb40751", + "color": "#ffffff" + }, + { + "_$id": "md4ipd8a", + "_$type": "Image", + "name": "score", + "x": 300, + "y": 449, + "width": 240, + "height": 181, + "scaleX": 2, + "scaleY": 2, + "centerX": 0, + "centerY": -330, + "skin": "res://9e3eb0ac-c410-40a7-b8c3-ae1316d04cfb", + "useSourceSize": true, + "color": "#ffffff", + "_$child": [ + { + "_$id": "fkjymlk3", + "_$type": "Label", + "name": "Label", + "x": 20, + "y": 61, + "width": 200, + "height": 60, + "centerX": 0, + "centerY": 0, + "text": "99", + "font": "res://55f943ef-58d2-4b30-8498-271c4213cce4", + "fontSize": 60, + "color": "#FFFFFF", + "align": "center", + "valign": "middle", + "padding": "0,0,0,0" + } + ] + } + ] + } ] } \ No newline at end of file diff --git a/assets/atlas/comp/bg_common_white.png b/assets/atlas/comp/bg_common_white.png new file mode 100644 index 0000000..901f7c8 Binary files /dev/null and b/assets/atlas/comp/bg_common_white.png differ diff --git a/assets/atlas/comp/bg_common_white.png.meta b/assets/atlas/comp/bg_common_white.png.meta new file mode 100644 index 0000000..bd783d1 --- /dev/null +++ b/assets/atlas/comp/bg_common_white.png.meta @@ -0,0 +1,13 @@ +{ + "uuid": "6ad19646-ed7a-431c-a50e-65c2bcb40751", + "importer": { + "textureType": 2, + "sizeGrid": [ + 20, + 40, + 31, + 40, + 0 + ] + } +} \ No newline at end of file diff --git a/assets/atlas/comp/icon_fail.png b/assets/atlas/comp/icon_fail.png new file mode 100644 index 0000000..a12ddcb Binary files /dev/null and b/assets/atlas/comp/icon_fail.png differ diff --git a/assets/atlas/comp/icon_fail.png.meta b/assets/atlas/comp/icon_fail.png.meta new file mode 100644 index 0000000..c7a03f7 --- /dev/null +++ b/assets/atlas/comp/icon_fail.png.meta @@ -0,0 +1,6 @@ +{ + "uuid": "9e3eb0ac-c410-40a7-b8c3-ae1316d04cfb", + "importer": { + "textureType": 2 + } +} \ No newline at end of file diff --git a/assets/resources/Stage.lh b/assets/resources/Stage.lh index 9036610..d1b7f0b 100644 --- a/assets/resources/Stage.lh +++ b/assets/resources/Stage.lh @@ -102,8 +102,10 @@ "width": 400, "height": 64, "_mouseState": 2, - "left": 60, - "top": 60, + "left": null, + "top": null, + "centerX": -314, + "centerY": -888, "_$child": [ { "_$id": "l1ebdt6a", diff --git a/src/models/StorageManager.ts b/src/models/StorageManager.ts index 8718037..953d183 100644 --- a/src/models/StorageManager.ts +++ b/src/models/StorageManager.ts @@ -43,10 +43,13 @@ export class StorageManager { } + private changed = false + private stageID: string = ""; private stageMap: Map = new Map(); public init(): void { + this.changed = false } public loadStage(stageID: string): DOStage { @@ -66,14 +69,22 @@ export class StorageManager { this.stageMap.set(stageID, dataStage) } } - return new DOStage(dataStage) + var levelStr = "aBCeIGFhdEDFcAHBGIhigBdfecAgHDiFBCaeBEAGHCIdffcIdEAHbgcABfGEdiHIFHaCDGEBDGEHbiaFC" + return new DOStage(dataStage, levelStr) } public saveStage(): void { - if (this.stageMap.has(this.stageID)) { - var dataStage = this.stageMap.get(this.stageID) - var jsonStr = JSON.stringify(dataStage) - Laya.LocalStorage.setItem(this.stageID, jsonStr) + if (this.changed) { + this.changed = false + if (this.stageMap.has(this.stageID)) { + var dataStage = this.stageMap.get(this.stageID) + var jsonStr = JSON.stringify(dataStage) + Laya.LocalStorage.setItem(this.stageID, jsonStr) + } } } + + public onChanged(): void { + this.changed = true + } } \ No newline at end of file diff --git a/src/models/UIManager.ts b/src/models/UIManager.ts index 5ccbe2f..6a30791 100644 --- a/src/models/UIManager.ts +++ b/src/models/UIManager.ts @@ -37,4 +37,8 @@ export class UIManager extends Laya.Script { }) } + onLateUpdate(): void { + StorageManager.getInstance().saveStage() + } + } diff --git a/src/types/DOBlock.ts b/src/types/DOBlock.ts index 0fd2a1c..373809c 100644 --- a/src/types/DOBlock.ts +++ b/src/types/DOBlock.ts @@ -32,7 +32,7 @@ export class DOBlock { this.checked = true if (this.get_checked() || show == 0) this.clean_notes()//正确或者擦除 - StorageManager.getInstance().saveStage() + StorageManager.getInstance().onChanged() } public get_score(): number { @@ -40,7 +40,7 @@ export class DOBlock { } public set_score(score: number): void { this.data.score = score - StorageManager.getInstance().saveStage() + StorageManager.getInstance().onChanged() } public get_notes(): Array { @@ -50,7 +50,7 @@ export class DOBlock { var b = false if (this.data.notes.indexOf(noteNumber) < 0) { this.data.notes.push(noteNumber) - StorageManager.getInstance().saveStage() + StorageManager.getInstance().onChanged() b = true } return b @@ -58,7 +58,7 @@ export class DOBlock { public clean_notes(): void { if (this.data.notes.length > 0) { this.data.notes = new Array() - StorageManager.getInstance().saveStage() + StorageManager.getInstance().onChanged() } } //====================================持久化数据 diff --git a/src/types/DOCandy.ts b/src/types/DOCandy.ts index 7d5bfee..8f5bba0 100644 --- a/src/types/DOCandy.ts +++ b/src/types/DOCandy.ts @@ -19,7 +19,7 @@ export class DOCandy { } public set_left(left: number): void { this.data.left = left - StorageManager.getInstance().saveStage() + StorageManager.getInstance().onChanged() } //====================================持久化数据 diff --git a/src/types/DOStage.ts b/src/types/DOStage.ts index ffc8d79..d56bf67 100644 --- a/src/types/DOStage.ts +++ b/src/types/DOStage.ts @@ -14,7 +14,7 @@ export class DOStage { private letterToNumber: any; private numberToLetter: any; - constructor(dataStage: any) { + constructor(dataStage: any, levelStr: string) { this.data = dataStage this.letterToNumber = new Map(); @@ -44,7 +44,7 @@ export class DOStage { var dataBlock = this.data.blocks[i] blockMap.set(dataBlock.index, dataBlock) } - var levelStr = "aBCeIGFhdEDFcAHBGIhigBdfecAgHDiFBCaeBEAGHCIdffcIdEAHbgcABfGEdiHIFHaCDGEBDGEHbiaFC" + if (levelStr.length != 81) { console.log("levelStr error", levelStr.length) } @@ -105,7 +105,7 @@ export class DOStage { } public set_mistake(mistake: number): void { this.data.mistake = mistake - StorageManager.getInstance().saveStage() + StorageManager.getInstance().onChanged() } public get_difficulty(): number { @@ -117,7 +117,7 @@ export class DOStage { } public set_duration(duration: number): void {//关卡计时 this.data.duration = duration - // StorageManager.getInstance().saveStage() + // StorageManager.getInstance().onChanged() } public get_note_open(): boolean { @@ -125,7 +125,7 @@ export class DOStage { } public set_note_open(note_open: boolean): void { this.data.note_open = note_open - StorageManager.getInstance().saveStage() + StorageManager.getInstance().onChanged() } //====================================持久化数据