mirror of
https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
synced 2025-06-27 11:58:51 +02:00
refactor: improve save JSON
This commit is contained in:
@ -1,16 +1,16 @@
|
||||
{
|
||||
"name": "Back on Track",
|
||||
"musicName": "BackOnTrack",
|
||||
"totalJumps": 0,
|
||||
"totalAttempts": 0,
|
||||
"order": 2,
|
||||
"elements": [
|
||||
{
|
||||
"type": "Spike",
|
||||
"position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
"name": "Back on Track",
|
||||
"musicName": "BackOnTrack",
|
||||
"totalJumps": 0,
|
||||
"totalAttempts": 0,
|
||||
"order": 2,
|
||||
"elements": [
|
||||
{
|
||||
"type": "Spike",
|
||||
"position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
{
|
||||
"name": "Stereo Madness",
|
||||
"musicName": "StereoMadness",
|
||||
"totalJumps": 0,
|
||||
"totalAttempts": 0,
|
||||
"order": 1,
|
||||
"elements": [
|
||||
{
|
||||
"type": "Spike",
|
||||
"position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
"name": "Stereo Madness",
|
||||
"musicName": "StereoMadness",
|
||||
"totalJumps": 0,
|
||||
"totalAttempts": 0,
|
||||
"order": 1,
|
||||
"elements": [
|
||||
{
|
||||
"type": "Spike",
|
||||
"position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ using UnityEngine;
|
||||
[System.Serializable]
|
||||
public class Level
|
||||
{
|
||||
public string JsonName { get; set; }
|
||||
|
||||
public string name;
|
||||
public string musicName;
|
||||
public int totalJumps;
|
||||
|
@ -19,16 +19,17 @@ public class LevelsLoader : MonoBehaviour
|
||||
TextAsset[] levelFiles = Resources.LoadAll<TextAsset>("Levels");
|
||||
foreach (TextAsset jsonTextFile in levelFiles)
|
||||
{
|
||||
Level loadedLevel = JsonUtility.FromJson<Level>(jsonTextFile.text);
|
||||
levels.Add(loadedLevel);
|
||||
Level level = Level.CreateFromJSON(jsonTextFile.text);
|
||||
level.JsonName = jsonTextFile.name;
|
||||
levels.Add(level);
|
||||
}
|
||||
levels.Sort((x, y) => x.order.CompareTo(y.order));
|
||||
}
|
||||
|
||||
private void SaveLevelCurrent()
|
||||
{
|
||||
string json = JsonUtility.ToJson(levelCurrent, true);
|
||||
File.WriteAllText(Path.Combine(Application.dataPath, "Resources", "Levels", levelCurrent.name + ".json"), json);
|
||||
string json = JsonUtility.ToJson(levelCurrent, true) + "\n";
|
||||
File.WriteAllText(Path.Combine(Application.dataPath, "Resources", "Levels", levelCurrent.JsonName + ".json"), json);
|
||||
}
|
||||
|
||||
public void NextLevel()
|
||||
|
@ -1,155 +1,157 @@
|
||||
{"frames": [
|
||||
{
|
||||
"filename": "1f60a.png",
|
||||
"frame": {"x":0,"y":0,"w":128,"h":128},
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
|
||||
"sourceSize": {"w":128,"h":128},
|
||||
"pivot": {"x":0.5,"y":0.5}
|
||||
}],
|
||||
"meta": {
|
||||
"app": "http://www.codeandweb.com/texturepacker",
|
||||
"version": "1.0",
|
||||
"image": "EmojiOne.png",
|
||||
"format": "RGBA8888",
|
||||
"size": {"w":512,"h":512},
|
||||
"scale": "1",
|
||||
"smartupdate": "$TexturePacker:SmartUpdate:196a26a2e149d875b91ffc8fa3581e76:fc928c7e275404b7e0649307410475cb:424723c3774975ddb2053fd5c4b85f6e$"
|
||||
}
|
||||
}
|
||||
"frames": [
|
||||
{
|
||||
"filename": "1f60a.png",
|
||||
"frame": { "x": 0, "y": 0, "w": 128, "h": 128 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"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,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
|
||||
"sourceSize": { "w": 128, "h": 128 },
|
||||
"pivot": { "x": 0.5, "y": 0.5 }
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"app": "http://www.codeandweb.com/texturepacker",
|
||||
"version": "1.0",
|
||||
"image": "EmojiOne.png",
|
||||
"format": "RGBA8888",
|
||||
"size": { "w": 512, "h": 512 },
|
||||
"scale": "1",
|
||||
"smartupdate": "$TexturePacker:SmartUpdate:196a26a2e149d875b91ffc8fa3581e76:fc928c7e275404b7e0649307410475cb:424723c3774975ddb2053fd5c4b85f6e$"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user