mirror of
				https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
				synced 2025-06-27 11:58:51 +02:00 
			
		
		
		
	feat: try to load music dynamically from JSON (WIP)
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "Name": "Back on Track",
 | 
					  "Name": "Back on Track",
 | 
				
			||||||
  "MusicPath": "back-on-track.mp3",
 | 
					  "MusicPath": "Musics/BackOnTrack.mp3",
 | 
				
			||||||
  "TotalJumps": 0,
 | 
					  "TotalJumps": 0,
 | 
				
			||||||
  "TotalAttempts": 0,
 | 
					  "TotalAttempts": 0,
 | 
				
			||||||
  "KilledCount": 0,
 | 
					  "KilledCount": 0,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1229,7 +1229,7 @@ GameObject:
 | 
				
			|||||||
  - component: {fileID: 1170341696}
 | 
					  - component: {fileID: 1170341696}
 | 
				
			||||||
  m_Layer: 0
 | 
					  m_Layer: 0
 | 
				
			||||||
  m_Name: Main Camera
 | 
					  m_Name: Main Camera
 | 
				
			||||||
  m_TagString: MainCamera
 | 
					  m_TagString: LevelLoader
 | 
				
			||||||
  m_Icon: {fileID: 0}
 | 
					  m_Icon: {fileID: 0}
 | 
				
			||||||
  m_NavMeshLayer: 0
 | 
					  m_NavMeshLayer: 0
 | 
				
			||||||
  m_StaticEditorFlags: 0
 | 
					  m_StaticEditorFlags: 0
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,7 +6,7 @@ using UnityEngine.UI;
 | 
				
			|||||||
public class LevelLoader : MonoBehaviour
 | 
					public class LevelLoader : MonoBehaviour
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public Text levelNameText;
 | 
					    public Text levelNameText;
 | 
				
			||||||
    private Level level;
 | 
					    public Level level;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void Start()
 | 
					    void Start()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,11 +1,13 @@
 | 
				
			|||||||
using UnityEngine;
 | 
					using UnityEngine;
 | 
				
			||||||
using UnityEngine.SceneManagement;
 | 
					using UnityEngine.SceneManagement;
 | 
				
			||||||
 | 
					using System.IO;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Player : MonoBehaviour
 | 
					public class Player : MonoBehaviour
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public Rigidbody2D rigidBody;
 | 
					    public Rigidbody2D rigidBody;
 | 
				
			||||||
    public GameObject playerObject;
 | 
					    public GameObject playerObject;
 | 
				
			||||||
    public ParticleSystem particle;
 | 
					    public ParticleSystem particle;
 | 
				
			||||||
 | 
					    public LevelLoader levelLoader;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public bool isColliding = true;
 | 
					    public bool isColliding = true;
 | 
				
			||||||
    public AudioSource audioSource;
 | 
					    public AudioSource audioSource;
 | 
				
			||||||
@@ -15,10 +17,26 @@ public class Player : MonoBehaviour
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public void Start()
 | 
					    public void Start()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        // levelLoader = GameObject.FindGameObjectWithTag("LevelLoader").GetComponent<LevelLoader>();
 | 
				
			||||||
        var mainModule = particle.main;
 | 
					        var mainModule = particle.main;
 | 
				
			||||||
        mainModule.simulationSpace = ParticleSystemSimulationSpace.World;
 | 
					        mainModule.simulationSpace = ParticleSystemSimulationSpace.World;
 | 
				
			||||||
        particle.transform.parent = null;
 | 
					        particle.transform.parent = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // if (levelLoader.level != null)
 | 
				
			||||||
 | 
					        // {
 | 
				
			||||||
 | 
					        //     string musicPath = Path.Combine("Musics", Path.GetFileNameWithoutExtension(levelLoader.level.MusicPath));
 | 
				
			||||||
 | 
					        //     AudioClip clip = Resources.Load<AudioClip>(musicPath);
 | 
				
			||||||
 | 
					        //     if (clip != null)
 | 
				
			||||||
 | 
					        //     {
 | 
				
			||||||
 | 
					        //         audioSource.clip = clip;
 | 
				
			||||||
 | 
					        //         audioSource.Play();
 | 
				
			||||||
 | 
					        //     }
 | 
				
			||||||
 | 
					        //     else
 | 
				
			||||||
 | 
					        //     {
 | 
				
			||||||
 | 
					        //         Debug.LogError("Failed to load music: " + musicPath);
 | 
				
			||||||
 | 
					        //     }
 | 
				
			||||||
 | 
					        // }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Invoke(nameof(EnableInput), 0.1f);
 | 
					        Invoke(nameof(EnableInput), 0.1f);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,6 +6,7 @@ TagManager:
 | 
				
			|||||||
  tags:
 | 
					  tags:
 | 
				
			||||||
  - Kill
 | 
					  - Kill
 | 
				
			||||||
  - Win
 | 
					  - Win
 | 
				
			||||||
 | 
					  - LevelLoader
 | 
				
			||||||
  layers:
 | 
					  layers:
 | 
				
			||||||
  - Default
 | 
					  - Default
 | 
				
			||||||
  - TransparentFX
 | 
					  - TransparentFX
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user