refactor: improve save JSON

This commit is contained in:
Théo LUDWIG 2025-02-09 20:26:05 +01:00
parent 0dbc959c19
commit 3026ea5367
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B
12 changed files with 763 additions and 757 deletions

View File

@ -8,8 +8,9 @@ indent_style = space
end_of_line = lf end_of_line = lf
[*.{json,jsonc,asmdef}] [*.{json,jsonc,asmdef}]
indent_size = 2 indent_size = 4
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = true
[*.{yml,yaml,sh,puml,md}] [*.{yml,yaml,sh,puml,md}]
indent_size = 2 indent_size = 2

View File

@ -1,9 +1,9 @@
{ {
"recommendations": [ "recommendations": [
"editorconfig.editorconfig", "editorconfig.editorconfig",
"jebbs.plantuml", "jebbs.plantuml",
"visualstudiotoolsforunity.vstuc", "visualstudiotoolsforunity.vstuc",
"ms-dotnettools.csharp", "ms-dotnettools.csharp",
"ms-dotnettools.csdevkit" "ms-dotnettools.csdevkit"
] ]
} }

16
.vscode/launch.json vendored
View File

@ -1,10 +1,10 @@
{ {
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "Attach to Unity", "name": "Attach to Unity",
"type": "vstuc", "type": "vstuc",
"request": "attach" "request": "attach"
} }
] ]
} }

16
.vscode/settings.json vendored
View File

@ -1,10 +1,10 @@
{ {
"editor.bracketPairColorization.enabled": true, "editor.bracketPairColorization.enabled": true,
"editor.wordWrap": "on", "editor.wordWrap": "on",
"[csharp]": { "[csharp]": {
"editor.tabSize": 4, "editor.tabSize": 4,
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.formatOnType": true "editor.formatOnType": true
}, },
"omnisharp.useModernNet": false "omnisharp.useModernNet": false
} }

View File

@ -1,16 +1,16 @@
{ {
"name": "Back on Track", "name": "Back on Track",
"musicName": "BackOnTrack", "musicName": "BackOnTrack",
"totalJumps": 0, "totalJumps": 0,
"totalAttempts": 0, "totalAttempts": 0,
"order": 2, "order": 2,
"elements": [ "elements": [
{ {
"type": "Spike", "type": "Spike",
"position": { "position": {
"x": 0, "x": 0,
"y": 0 "y": 0
} }
} }
] ]
} }

View File

@ -1,16 +1,16 @@
{ {
"name": "Stereo Madness", "name": "Stereo Madness",
"musicName": "StereoMadness", "musicName": "StereoMadness",
"totalJumps": 0, "totalJumps": 0,
"totalAttempts": 0, "totalAttempts": 0,
"order": 1, "order": 1,
"elements": [ "elements": [
{ {
"type": "Spike", "type": "Spike",
"position": { "position": {
"x": 0, "x": 0,
"y": 0 "y": 0
} }
} }
] ]
} }

View File

@ -3,6 +3,8 @@ using UnityEngine;
[System.Serializable] [System.Serializable]
public class Level public class Level
{ {
public string JsonName { get; set; }
public string name; public string name;
public string musicName; public string musicName;
public int totalJumps; public int totalJumps;

View File

@ -19,16 +19,17 @@ public class LevelsLoader : MonoBehaviour
TextAsset[] levelFiles = Resources.LoadAll<TextAsset>("Levels"); TextAsset[] levelFiles = Resources.LoadAll<TextAsset>("Levels");
foreach (TextAsset jsonTextFile in levelFiles) foreach (TextAsset jsonTextFile in levelFiles)
{ {
Level loadedLevel = JsonUtility.FromJson<Level>(jsonTextFile.text); Level level = Level.CreateFromJSON(jsonTextFile.text);
levels.Add(loadedLevel); level.JsonName = jsonTextFile.name;
levels.Add(level);
} }
levels.Sort((x, y) => x.order.CompareTo(y.order)); levels.Sort((x, y) => x.order.CompareTo(y.order));
} }
private void SaveLevelCurrent() private void SaveLevelCurrent()
{ {
string json = JsonUtility.ToJson(levelCurrent, true); string json = JsonUtility.ToJson(levelCurrent, true) + "\n";
File.WriteAllText(Path.Combine(Application.dataPath, "Resources", "Levels", levelCurrent.name + ".json"), json); File.WriteAllText(Path.Combine(Application.dataPath, "Resources", "Levels", levelCurrent.JsonName + ".json"), json);
} }
public void NextLevel() public void NextLevel()

View File

@ -1,155 +1,157 @@
{"frames": [
{ {
"filename": "1f60a.png", "frames": [
"frame": {"x":0,"y":0,"w":128,"h":128}, {
"rotated": false, "filename": "1f60a.png",
"trimmed": false, "frame": { "x": 0, "y": 0, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "1f60b.png", },
"frame": {"x":128,"y":0,"w":128,"h":128}, {
"rotated": false, "filename": "1f60b.png",
"trimmed": false, "frame": { "x": 128, "y": 0, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "1f60d.png", },
"frame": {"x":256,"y":0,"w":128,"h":128}, {
"rotated": false, "filename": "1f60d.png",
"trimmed": false, "frame": { "x": 256, "y": 0, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "1f60e.png", },
"frame": {"x":384,"y":0,"w":128,"h":128}, {
"rotated": false, "filename": "1f60e.png",
"trimmed": false, "frame": { "x": 384, "y": 0, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "1f600.png", },
"frame": {"x":0,"y":128,"w":128,"h":128}, {
"rotated": false, "filename": "1f600.png",
"trimmed": false, "frame": { "x": 0, "y": 128, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "1f601.png", },
"frame": {"x":128,"y":128,"w":128,"h":128}, {
"rotated": false, "filename": "1f601.png",
"trimmed": false, "frame": { "x": 128, "y": 128, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "1f602.png", },
"frame": {"x":256,"y":128,"w":128,"h":128}, {
"rotated": false, "filename": "1f602.png",
"trimmed": false, "frame": { "x": 256, "y": 128, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "1f603.png", },
"frame": {"x":384,"y":128,"w":128,"h":128}, {
"rotated": false, "filename": "1f603.png",
"trimmed": false, "frame": { "x": 384, "y": 128, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "1f604.png", },
"frame": {"x":0,"y":256,"w":128,"h":128}, {
"rotated": false, "filename": "1f604.png",
"trimmed": false, "frame": { "x": 0, "y": 256, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "1f605.png", },
"frame": {"x":128,"y":256,"w":128,"h":128}, {
"rotated": false, "filename": "1f605.png",
"trimmed": false, "frame": { "x": 128, "y": 256, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "1f606.png", },
"frame": {"x":256,"y":256,"w":128,"h":128}, {
"rotated": false, "filename": "1f606.png",
"trimmed": false, "frame": { "x": 256, "y": 256, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "1f609.png", },
"frame": {"x":384,"y":256,"w":128,"h":128}, {
"rotated": false, "filename": "1f609.png",
"trimmed": false, "frame": { "x": 384, "y": 256, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "1f618.png", },
"frame": {"x":0,"y":384,"w":128,"h":128}, {
"rotated": false, "filename": "1f618.png",
"trimmed": false, "frame": { "x": 0, "y": 384, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "1f923.png", },
"frame": {"x":128,"y":384,"w":128,"h":128}, {
"rotated": false, "filename": "1f923.png",
"trimmed": false, "frame": { "x": 128, "y": 384, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "263a.png", },
"frame": {"x":256,"y":384,"w":128,"h":128}, {
"rotated": false, "filename": "263a.png",
"trimmed": false, "frame": { "x": 256, "y": 384, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}, "sourceSize": { "w": 128, "h": 128 },
{ "pivot": { "x": 0.5, "y": 0.5 }
"filename": "2639.png", },
"frame": {"x":384,"y":384,"w":128,"h":128}, {
"rotated": false, "filename": "2639.png",
"trimmed": false, "frame": { "x": 384, "y": 384, "w": 128, "h": 128 },
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128}, "rotated": false,
"sourceSize": {"w":128,"h":128}, "trimmed": false,
"pivot": {"x":0.5,"y":0.5} "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
}], "sourceSize": { "w": 128, "h": 128 },
"meta": { "pivot": { "x": 0.5, "y": 0.5 }
"app": "http://www.codeandweb.com/texturepacker", }
"version": "1.0", ],
"image": "EmojiOne.png", "meta": {
"format": "RGBA8888", "app": "http://www.codeandweb.com/texturepacker",
"size": {"w":512,"h":512}, "version": "1.0",
"scale": "1", "image": "EmojiOne.png",
"smartupdate": "$TexturePacker:SmartUpdate:196a26a2e149d875b91ffc8fa3581e76:fc928c7e275404b7e0649307410475cb:424723c3774975ddb2053fd5c4b85f6e$" "format": "RGBA8888",
} "size": { "w": 512, "h": 512 },
} "scale": "1",
"smartupdate": "$TexturePacker:SmartUpdate:196a26a2e149d875b91ffc8fa3581e76:fc928c7e275404b7e0649307410475cb:424723c3774975ddb2053fd5c4b85f6e$"
}
}

View File

@ -1,46 +1,46 @@
{ {
"dependencies": { "dependencies": {
"com.unity.collab-proxy": "2.6.0", "com.unity.collab-proxy": "2.6.0",
"com.unity.feature.2d": "2.0.1", "com.unity.feature.2d": "2.0.1",
"com.unity.ide.rider": "3.0.31", "com.unity.ide.rider": "3.0.31",
"com.unity.ide.visualstudio": "2.0.22", "com.unity.ide.visualstudio": "2.0.22",
"com.unity.inputsystem": "1.11.2", "com.unity.inputsystem": "1.11.2",
"com.unity.multiplayer.center": "1.0.0", "com.unity.multiplayer.center": "1.0.0",
"com.unity.test-framework": "1.4.5", "com.unity.test-framework": "1.4.5",
"com.unity.timeline": "1.8.7", "com.unity.timeline": "1.8.7",
"com.unity.ugui": "2.0.0", "com.unity.ugui": "2.0.0",
"com.unity.visualscripting": "1.9.4", "com.unity.visualscripting": "1.9.4",
"com.unity.modules.accessibility": "1.0.0", "com.unity.modules.accessibility": "1.0.0",
"com.unity.modules.ai": "1.0.0", "com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0", "com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0", "com.unity.modules.animation": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0", "com.unity.modules.assetbundle": "1.0.0",
"com.unity.modules.audio": "1.0.0", "com.unity.modules.audio": "1.0.0",
"com.unity.modules.cloth": "1.0.0", "com.unity.modules.cloth": "1.0.0",
"com.unity.modules.director": "1.0.0", "com.unity.modules.director": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0", "com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.imgui": "1.0.0", "com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0", "com.unity.modules.particlesystem": "1.0.0",
"com.unity.modules.physics": "1.0.0", "com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0", "com.unity.modules.physics2d": "1.0.0",
"com.unity.modules.screencapture": "1.0.0", "com.unity.modules.screencapture": "1.0.0",
"com.unity.modules.terrain": "1.0.0", "com.unity.modules.terrain": "1.0.0",
"com.unity.modules.terrainphysics": "1.0.0", "com.unity.modules.terrainphysics": "1.0.0",
"com.unity.modules.tilemap": "1.0.0", "com.unity.modules.tilemap": "1.0.0",
"com.unity.modules.ui": "1.0.0", "com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0", "com.unity.modules.uielements": "1.0.0",
"com.unity.modules.umbra": "1.0.0", "com.unity.modules.umbra": "1.0.0",
"com.unity.modules.unityanalytics": "1.0.0", "com.unity.modules.unityanalytics": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0", "com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0", "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0", "com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.unitywebrequesttexture": "1.0.0", "com.unity.modules.unitywebrequesttexture": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0", "com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.modules.vehicles": "1.0.0", "com.unity.modules.vehicles": "1.0.0",
"com.unity.modules.video": "1.0.0", "com.unity.modules.video": "1.0.0",
"com.unity.modules.vr": "1.0.0", "com.unity.modules.vr": "1.0.0",
"com.unity.modules.wind": "1.0.0", "com.unity.modules.wind": "1.0.0",
"com.unity.modules.xr": "1.0.0" "com.unity.modules.xr": "1.0.0"
} }
} }

File diff suppressed because it is too large Load Diff