mirror of
https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
synced 2025-04-17 18:56:18 +02:00
feat: json loader (Work In Progress)
This commit is contained in:
parent
51404e5cc6
commit
ed5d3cd222
38
Assets/LevelLoader.cs
Normal file
38
Assets/LevelLoader.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
public class LevelLoader : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField]
|
||||||
|
public Text levelNameText;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
levelNameText.text = "Coucou";
|
||||||
|
string filePath = "level.json";
|
||||||
|
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
string json = File.ReadAllText(filePath);
|
||||||
|
Level level = JsonSerializer.Deserialize<Level>(json, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||||
|
|
||||||
|
Console.WriteLine($"Name: {level.Name}");
|
||||||
|
Console.WriteLine($"MusicPath: {level.MusicPath}");
|
||||||
|
Console.WriteLine($"TotalJumps: {level.TotalJumps}");
|
||||||
|
Console.WriteLine($"TotalAttempts: {level.TotalAttempts}");
|
||||||
|
Console.WriteLine($"KilledCount: {level.KilledCount}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("JSON file not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
2
Assets/LevelLoader.cs.meta
Normal file
2
Assets/LevelLoader.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4c3543e79f987af40bbd4a51c0a334c3
|
8
Assets/Levels.meta
Normal file
8
Assets/Levels.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8a276afa778b9651581567c4c5bd8c7c
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
13
Assets/Levels/back-on-track.json
Normal file
13
Assets/Levels/back-on-track.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "Back on Track",
|
||||||
|
"music": "",
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"type": "Spike",
|
||||||
|
"position": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
7
Assets/Levels/back-on-track.json.meta
Normal file
7
Assets/Levels/back-on-track.json.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f32c76b542365930aa0e19dff76d20c7
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -613,9 +613,10 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 954359121}
|
- component: {fileID: 954359121}
|
||||||
- component: {fileID: 954359123}
|
- component: {fileID: 954359123}
|
||||||
- component: {fileID: 954359122}
|
- component: {fileID: 954359125}
|
||||||
|
- component: {fileID: 954359124}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Text (TMP)
|
m_Name: Text
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
@ -640,97 +641,6 @@ RectTransform:
|
|||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
m_SizeDelta: {x: 0, y: 0}
|
m_SizeDelta: {x: 0, y: 0}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &954359122
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 954359120}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
|
||||||
m_RaycastTarget: 1
|
|
||||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
m_Maskable: 1
|
|
||||||
m_OnCullStateChanged:
|
|
||||||
m_PersistentCalls:
|
|
||||||
m_Calls: []
|
|
||||||
m_text: Level
|
|
||||||
m_isRightToLeft: 0
|
|
||||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
|
||||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
|
||||||
m_fontSharedMaterials: []
|
|
||||||
m_fontMaterial: {fileID: 0}
|
|
||||||
m_fontMaterials: []
|
|
||||||
m_fontColor32:
|
|
||||||
serializedVersion: 2
|
|
||||||
rgba: 4281479730
|
|
||||||
m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
|
||||||
m_enableVertexGradient: 0
|
|
||||||
m_colorMode: 3
|
|
||||||
m_fontColorGradient:
|
|
||||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
|
||||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
|
||||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
|
||||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
|
||||||
m_fontColorGradientPreset: {fileID: 0}
|
|
||||||
m_spriteAsset: {fileID: 0}
|
|
||||||
m_tintAllSprites: 0
|
|
||||||
m_StyleSheet: {fileID: 0}
|
|
||||||
m_TextStyleHashCode: -1183493901
|
|
||||||
m_overrideHtmlColors: 0
|
|
||||||
m_faceColor:
|
|
||||||
serializedVersion: 2
|
|
||||||
rgba: 4294967295
|
|
||||||
m_fontSize: 24
|
|
||||||
m_fontSizeBase: 24
|
|
||||||
m_fontWeight: 400
|
|
||||||
m_enableAutoSizing: 0
|
|
||||||
m_fontSizeMin: 18
|
|
||||||
m_fontSizeMax: 72
|
|
||||||
m_fontStyle: 0
|
|
||||||
m_HorizontalAlignment: 2
|
|
||||||
m_VerticalAlignment: 512
|
|
||||||
m_textAlignment: 65535
|
|
||||||
m_characterSpacing: 0
|
|
||||||
m_wordSpacing: 0
|
|
||||||
m_lineSpacing: 0
|
|
||||||
m_lineSpacingMax: 0
|
|
||||||
m_paragraphSpacing: 0
|
|
||||||
m_charWidthMaxAdj: 0
|
|
||||||
m_TextWrappingMode: 1
|
|
||||||
m_wordWrappingRatios: 0.4
|
|
||||||
m_overflowMode: 0
|
|
||||||
m_linkedTextComponent: {fileID: 0}
|
|
||||||
parentLinkedComponent: {fileID: 0}
|
|
||||||
m_enableKerning: 0
|
|
||||||
m_ActiveFontFeatures: 6e72656b
|
|
||||||
m_enableExtraPadding: 0
|
|
||||||
checkPaddingRequired: 0
|
|
||||||
m_isRichText: 1
|
|
||||||
m_EmojiFallbackSupport: 1
|
|
||||||
m_parseCtrlCharacters: 1
|
|
||||||
m_isOrthographic: 1
|
|
||||||
m_isCullingEnabled: 0
|
|
||||||
m_horizontalMapping: 0
|
|
||||||
m_verticalMapping: 0
|
|
||||||
m_uvLineOffset: 0
|
|
||||||
m_geometrySortingOrder: 0
|
|
||||||
m_IsTextObjectScaleStatic: 0
|
|
||||||
m_VertexBufferAutoSizeReduction: 0
|
|
||||||
m_useMaxVisibleDescender: 1
|
|
||||||
m_pageToDisplay: 1
|
|
||||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
m_isUsingLegacyAnimationComponent: 0
|
|
||||||
m_isVolumetricText: 0
|
|
||||||
m_hasFontAssetChanged: 0
|
|
||||||
m_baseMaterial: {fileID: 0}
|
|
||||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
--- !u!222 &954359123
|
--- !u!222 &954359123
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -739,6 +649,53 @@ CanvasRenderer:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 954359120}
|
m_GameObject: {fileID: 954359120}
|
||||||
m_CullTransparentMesh: 1
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!114 &954359124
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 954359120}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 0, g: 0, b: 0, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_FontData:
|
||||||
|
m_Font: {fileID: 12800000, guid: e3265ab4bf004d28a9537516768c1c75, type: 3}
|
||||||
|
m_FontSize: 32
|
||||||
|
m_FontStyle: 0
|
||||||
|
m_BestFit: 0
|
||||||
|
m_MinSize: 0
|
||||||
|
m_MaxSize: 40
|
||||||
|
m_Alignment: 4
|
||||||
|
m_AlignByGeometry: 0
|
||||||
|
m_RichText: 1
|
||||||
|
m_HorizontalOverflow: 0
|
||||||
|
m_VerticalOverflow: 0
|
||||||
|
m_LineSpacing: 1
|
||||||
|
m_Text: Level
|
||||||
|
--- !u!114 &954359125
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 954359120}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 4c3543e79f987af40bbd4a51c0a334c3, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
levelNameText: {fileID: 954359124}
|
||||||
--- !u!1 &976210033
|
--- !u!1 &976210033
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1148,6 +1105,7 @@ GameObject:
|
|||||||
- component: {fileID: 1153106992}
|
- component: {fileID: 1153106992}
|
||||||
- component: {fileID: 1153106991}
|
- component: {fileID: 1153106991}
|
||||||
- component: {fileID: 1153106990}
|
- component: {fileID: 1153106990}
|
||||||
|
- component: {fileID: 1153106993}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Canvas
|
m_Name: Canvas
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -1244,6 +1202,19 @@ Canvas:
|
|||||||
m_SortingLayerID: 0
|
m_SortingLayerID: 0
|
||||||
m_SortingOrder: 0
|
m_SortingOrder: 0
|
||||||
m_TargetDisplay: 0
|
m_TargetDisplay: 0
|
||||||
|
--- !u!114 &1153106993
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1153106988}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 78914afaa50342f4fbc6b2f0d1a6c036, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
levelNameText: {fileID: 0}
|
||||||
--- !u!1 &1170341692
|
--- !u!1 &1170341692
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1350,6 +1321,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 78914afaa50342f4fbc6b2f0d1a6c036, type: 3}
|
m_Script: {fileID: 11500000, guid: 78914afaa50342f4fbc6b2f0d1a6c036, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
levelNameText: {fileID: 0}
|
||||||
--- !u!1 &1174740937
|
--- !u!1 &1174740937
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
16
Assets/Scripts/Level.cs
Normal file
16
Assets/Scripts/Level.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
[DataContract]
|
||||||
|
public class Level
|
||||||
|
{
|
||||||
|
[DataMember]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public string MusicPath { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public int TotalJumps { get; set; }
|
||||||
|
public int TotalAttempts { get; set; }
|
||||||
|
public int KilledCount { get; set; }
|
||||||
|
}
|
2
Assets/Scripts/Level.cs.meta
Normal file
2
Assets/Scripts/Level.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d646b99f5a21a91c88669a5e4d774f06
|
@ -1,8 +1,11 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
public class SelectLevelMenu : MonoBehaviour
|
public class SelectLevelMenu : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public Text levelNameText;
|
||||||
|
|
||||||
public void PlayLevel()
|
public void PlayLevel()
|
||||||
{
|
{
|
||||||
SceneManager.LoadScene("LevelScene");
|
SceneManager.LoadScene("LevelScene");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user