refactor: move all scripts to Scripts folder

This commit is contained in:
2025-02-09 12:43:41 +01:00
parent 5766003c75
commit 78ab70e020
6 changed files with 0 additions and 0 deletions

View 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);
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 4c3543e79f987af40bbd4a51c0a334c3

View 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();
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a1cd6b406f139414086355a222af717e

View 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(?);
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 78914afaa50342f4fbc6b2f0d1a6c036