mirror of
https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
synced 2025-06-10 22:20:40 +02:00
feat: sounds effects (click on button, win and death) (#67)
This commit is contained in:
@ -1,12 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class LevelHomeButton : MonoBehaviour
|
||||
{
|
||||
public AudioSource sfxSource;
|
||||
|
||||
public static IEnumerator PlaySoundAndLoadScene(AudioSource sfxSource, string scene)
|
||||
{
|
||||
yield return new WaitWhile(() => sfxSource.isPlaying);
|
||||
SceneManager.LoadScene(scene);
|
||||
}
|
||||
|
||||
public void GoToHome()
|
||||
{
|
||||
PlayerPrefs.SetInt("CreateMode", 0);
|
||||
PlayerPrefs.SetInt("EditMode", 0);
|
||||
SceneManager.LoadScene("HomeScene");
|
||||
|
||||
sfxSource.clip = Resources.Load<AudioClip>(Path.Combine("Sounds", "click"));
|
||||
sfxSource.Play();
|
||||
StartCoroutine(PlaySoundAndLoadScene(sfxSource, "HomeScene"));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
public class LevelNextButton : MonoBehaviour
|
||||
{
|
||||
public AudioSource sfxSource;
|
||||
public LevelsLoader levelsLoader;
|
||||
|
||||
public void Start()
|
||||
@ -20,5 +22,7 @@ public class LevelNextButton : MonoBehaviour
|
||||
public void NextLevel()
|
||||
{
|
||||
levelsLoader.NextLevel();
|
||||
sfxSource.clip = Resources.Load<AudioClip>(Path.Combine("Sounds", "click"));
|
||||
sfxSource.Play();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
public class LevelPreviousButton : MonoBehaviour
|
||||
{
|
||||
public AudioSource sfxSource;
|
||||
public LevelsLoader levelsLoader;
|
||||
|
||||
public void Start()
|
||||
@ -20,5 +22,7 @@ public class LevelPreviousButton : MonoBehaviour
|
||||
public void PreviousLevel()
|
||||
{
|
||||
levelsLoader.PreviousLevel();
|
||||
sfxSource.clip = Resources.Load<AudioClip>(Path.Combine("Sounds", "click"));
|
||||
sfxSource.Play();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user