mirror of
				https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
				synced 2025-06-27 11:58:51 +02:00 
			
		
		
		
	refactor: move all scripts to Scripts folder
This commit is contained in:
		
							
								
								
									
										41
									
								
								Assets/Scripts/LevelLoader.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								Assets/Scripts/LevelLoader.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
using System.IO;
 | 
			
		||||
using System.Runtime.Serialization.Json;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using UnityEngine.UI;
 | 
			
		||||
 | 
			
		||||
public class LevelLoader : MonoBehaviour
 | 
			
		||||
{
 | 
			
		||||
    public Text levelNameText;
 | 
			
		||||
    private Level level;
 | 
			
		||||
 | 
			
		||||
    void Start()
 | 
			
		||||
    {
 | 
			
		||||
        LoadLevel();
 | 
			
		||||
        if (level != null)
 | 
			
		||||
        {
 | 
			
		||||
            levelNameText.text = level.Name;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            levelNameText.text = "Failed to Load Level";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void LoadLevel()
 | 
			
		||||
    {
 | 
			
		||||
        string path = Path.Combine(Application.dataPath, "Levels", "back-on-track.json");
 | 
			
		||||
        if (File.Exists(path))
 | 
			
		||||
        {
 | 
			
		||||
            string json = File.ReadAllText(path);
 | 
			
		||||
            using (MemoryStream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(json)))
 | 
			
		||||
            {
 | 
			
		||||
                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Level));
 | 
			
		||||
                level = (Level)serializer.ReadObject(stream);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            Debug.LogError("Level file not found: " + path);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										2
									
								
								Assets/Scripts/LevelLoader.cs.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								Assets/Scripts/LevelLoader.cs.meta
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: 4c3543e79f987af40bbd4a51c0a334c3
 | 
			
		||||
							
								
								
									
										20
									
								
								Assets/Scripts/MainMenu.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								Assets/Scripts/MainMenu.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using UnityEngine.SceneManagement;
 | 
			
		||||
 | 
			
		||||
public class MainMenu : MonoBehaviour
 | 
			
		||||
{
 | 
			
		||||
    public void LaunchGame()
 | 
			
		||||
    {
 | 
			
		||||
        SceneManager.LoadSceneAsync("SelectLevelScene");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void OpenSettings()
 | 
			
		||||
    {
 | 
			
		||||
        // SceneManager.LoadSceneAsync(?);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void QuitGame()
 | 
			
		||||
    {
 | 
			
		||||
        Application.Quit();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										2
									
								
								Assets/Scripts/MainMenu.cs.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								Assets/Scripts/MainMenu.cs.meta
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: a1cd6b406f139414086355a222af717e
 | 
			
		||||
							
								
								
									
										33
									
								
								Assets/Scripts/SelectLevelMenu.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								Assets/Scripts/SelectLevelMenu.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using UnityEngine.UI;
 | 
			
		||||
using UnityEngine.SceneManagement;
 | 
			
		||||
 | 
			
		||||
public class SelectLevelMenu : MonoBehaviour
 | 
			
		||||
{
 | 
			
		||||
    public Text levelNameText;
 | 
			
		||||
 | 
			
		||||
    public void PlayLevel()
 | 
			
		||||
    {
 | 
			
		||||
        SceneManager.LoadScene("LevelScene");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void BackBtn()
 | 
			
		||||
    {
 | 
			
		||||
        SceneManager.LoadScene("HomeScene");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void LastLevel()
 | 
			
		||||
    {
 | 
			
		||||
        // TODO
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void NextLevel()
 | 
			
		||||
    {
 | 
			
		||||
        // TODO
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void LevelStatsBtn()
 | 
			
		||||
    {
 | 
			
		||||
        // SceneManager.LoadSceneAsync(?);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										2
									
								
								Assets/Scripts/SelectLevelMenu.cs.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								Assets/Scripts/SelectLevelMenu.cs.meta
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: 78914afaa50342f4fbc6b2f0d1a6c036
 | 
			
		||||
		Reference in New Issue
	
	Block a user