优化存档逻辑
This commit is contained in:
@@ -18,5 +18,69 @@
|
|||||||
"_$type": "cd70cd5e-b4cd-4277-ac0a-2224cfbe89ac",
|
"_$type": "cd70cd5e-b4cd-4277-ac0a-2224cfbe89ac",
|
||||||
"scriptPath": "../src/models/UIManager.ts"
|
"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
BIN
assets/atlas/comp/bg_common_white.png
Normal file
BIN
assets/atlas/comp/bg_common_white.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.0 KiB |
13
assets/atlas/comp/bg_common_white.png.meta
Normal file
13
assets/atlas/comp/bg_common_white.png.meta
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"uuid": "6ad19646-ed7a-431c-a50e-65c2bcb40751",
|
||||||
|
"importer": {
|
||||||
|
"textureType": 2,
|
||||||
|
"sizeGrid": [
|
||||||
|
20,
|
||||||
|
40,
|
||||||
|
31,
|
||||||
|
40,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
assets/atlas/comp/icon_fail.png
Normal file
BIN
assets/atlas/comp/icon_fail.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
6
assets/atlas/comp/icon_fail.png.meta
Normal file
6
assets/atlas/comp/icon_fail.png.meta
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"uuid": "9e3eb0ac-c410-40a7-b8c3-ae1316d04cfb",
|
||||||
|
"importer": {
|
||||||
|
"textureType": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -102,8 +102,10 @@
|
|||||||
"width": 400,
|
"width": 400,
|
||||||
"height": 64,
|
"height": 64,
|
||||||
"_mouseState": 2,
|
"_mouseState": 2,
|
||||||
"left": 60,
|
"left": null,
|
||||||
"top": 60,
|
"top": null,
|
||||||
|
"centerX": -314,
|
||||||
|
"centerY": -888,
|
||||||
"_$child": [
|
"_$child": [
|
||||||
{
|
{
|
||||||
"_$id": "l1ebdt6a",
|
"_$id": "l1ebdt6a",
|
||||||
|
|||||||
@@ -43,10 +43,13 @@ export class StorageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private changed = false
|
||||||
|
|
||||||
private stageID: string = "";
|
private stageID: string = "";
|
||||||
private stageMap: Map<string, any> = new Map();
|
private stageMap: Map<string, any> = new Map();
|
||||||
|
|
||||||
public init(): void {
|
public init(): void {
|
||||||
|
this.changed = false
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadStage(stageID: string): DOStage {
|
public loadStage(stageID: string): DOStage {
|
||||||
@@ -66,14 +69,22 @@ export class StorageManager {
|
|||||||
this.stageMap.set(stageID, dataStage)
|
this.stageMap.set(stageID, dataStage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new DOStage(dataStage)
|
var levelStr = "aBCeIGFhdEDFcAHBGIhigBdfecAgHDiFBCaeBEAGHCIdffcIdEAHbgcABfGEdiHIFHaCDGEBDGEHbiaFC"
|
||||||
|
return new DOStage(dataStage, levelStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
public saveStage(): void {
|
public saveStage(): void {
|
||||||
if (this.stageMap.has(this.stageID)) {
|
if (this.changed) {
|
||||||
var dataStage = this.stageMap.get(this.stageID)
|
this.changed = false
|
||||||
var jsonStr = JSON.stringify(dataStage)
|
if (this.stageMap.has(this.stageID)) {
|
||||||
Laya.LocalStorage.setItem(this.stageID, jsonStr)
|
var dataStage = this.stageMap.get(this.stageID)
|
||||||
|
var jsonStr = JSON.stringify(dataStage)
|
||||||
|
Laya.LocalStorage.setItem(this.stageID, jsonStr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public onChanged(): void {
|
||||||
|
this.changed = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -37,4 +37,8 @@ export class UIManager extends Laya.Script {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onLateUpdate(): void {
|
||||||
|
StorageManager.getInstance().saveStage()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export class DOBlock {
|
|||||||
this.checked = true
|
this.checked = true
|
||||||
if (this.get_checked() || show == 0)
|
if (this.get_checked() || show == 0)
|
||||||
this.clean_notes()//正确或者擦除
|
this.clean_notes()//正确或者擦除
|
||||||
StorageManager.getInstance().saveStage()
|
StorageManager.getInstance().onChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
public get_score(): number {
|
public get_score(): number {
|
||||||
@@ -40,7 +40,7 @@ export class DOBlock {
|
|||||||
}
|
}
|
||||||
public set_score(score: number): void {
|
public set_score(score: number): void {
|
||||||
this.data.score = score
|
this.data.score = score
|
||||||
StorageManager.getInstance().saveStage()
|
StorageManager.getInstance().onChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
public get_notes(): Array<number> {
|
public get_notes(): Array<number> {
|
||||||
@@ -50,7 +50,7 @@ export class DOBlock {
|
|||||||
var b = false
|
var b = false
|
||||||
if (this.data.notes.indexOf(noteNumber) < 0) {
|
if (this.data.notes.indexOf(noteNumber) < 0) {
|
||||||
this.data.notes.push(noteNumber)
|
this.data.notes.push(noteNumber)
|
||||||
StorageManager.getInstance().saveStage()
|
StorageManager.getInstance().onChanged()
|
||||||
b = true
|
b = true
|
||||||
}
|
}
|
||||||
return b
|
return b
|
||||||
@@ -58,7 +58,7 @@ export class DOBlock {
|
|||||||
public clean_notes(): void {
|
public clean_notes(): void {
|
||||||
if (this.data.notes.length > 0) {
|
if (this.data.notes.length > 0) {
|
||||||
this.data.notes = new Array()
|
this.data.notes = new Array()
|
||||||
StorageManager.getInstance().saveStage()
|
StorageManager.getInstance().onChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//====================================持久化数据
|
//====================================持久化数据
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export class DOCandy {
|
|||||||
}
|
}
|
||||||
public set_left(left: number): void {
|
public set_left(left: number): void {
|
||||||
this.data.left = left
|
this.data.left = left
|
||||||
StorageManager.getInstance().saveStage()
|
StorageManager.getInstance().onChanged()
|
||||||
}
|
}
|
||||||
//====================================持久化数据
|
//====================================持久化数据
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export class DOStage {
|
|||||||
private letterToNumber: any;
|
private letterToNumber: any;
|
||||||
private numberToLetter: any;
|
private numberToLetter: any;
|
||||||
|
|
||||||
constructor(dataStage: any) {
|
constructor(dataStage: any, levelStr: string) {
|
||||||
this.data = dataStage
|
this.data = dataStage
|
||||||
|
|
||||||
this.letterToNumber = new Map();
|
this.letterToNumber = new Map();
|
||||||
@@ -44,7 +44,7 @@ export class DOStage {
|
|||||||
var dataBlock = this.data.blocks[i]
|
var dataBlock = this.data.blocks[i]
|
||||||
blockMap.set(dataBlock.index, dataBlock)
|
blockMap.set(dataBlock.index, dataBlock)
|
||||||
}
|
}
|
||||||
var levelStr = "aBCeIGFhdEDFcAHBGIhigBdfecAgHDiFBCaeBEAGHCIdffcIdEAHbgcABfGEdiHIFHaCDGEBDGEHbiaFC"
|
|
||||||
if (levelStr.length != 81) {
|
if (levelStr.length != 81) {
|
||||||
console.log("levelStr error", levelStr.length)
|
console.log("levelStr error", levelStr.length)
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ export class DOStage {
|
|||||||
}
|
}
|
||||||
public set_mistake(mistake: number): void {
|
public set_mistake(mistake: number): void {
|
||||||
this.data.mistake = mistake
|
this.data.mistake = mistake
|
||||||
StorageManager.getInstance().saveStage()
|
StorageManager.getInstance().onChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
public get_difficulty(): number {
|
public get_difficulty(): number {
|
||||||
@@ -117,7 +117,7 @@ export class DOStage {
|
|||||||
}
|
}
|
||||||
public set_duration(duration: number): void {//关卡计时
|
public set_duration(duration: number): void {//关卡计时
|
||||||
this.data.duration = duration
|
this.data.duration = duration
|
||||||
// StorageManager.getInstance().saveStage()
|
// StorageManager.getInstance().onChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
public get_note_open(): boolean {
|
public get_note_open(): boolean {
|
||||||
@@ -125,7 +125,7 @@ export class DOStage {
|
|||||||
}
|
}
|
||||||
public set_note_open(note_open: boolean): void {
|
public set_note_open(note_open: boolean): void {
|
||||||
this.data.note_open = note_open
|
this.data.note_open = note_open
|
||||||
StorageManager.getInstance().saveStage()
|
StorageManager.getInstance().onChanged()
|
||||||
}
|
}
|
||||||
//====================================持久化数据
|
//====================================持久化数据
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user