feat: sounds effects (click on button, win and death) (#67)

This commit is contained in:
2025-05-16 19:27:38 +02:00
committed by GitHub
parent 2c7a420f90
commit 0b32ce7036
28 changed files with 1265 additions and 63 deletions

View File

@ -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"));
}
}

View File

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

View File

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