| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 | 
							- using System.Collections;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Runtime.InteropServices.WindowsRuntime;
 
- using UnityEngine;
 
- using UnityEngine.UIElements;
 
- public enum SoundCategory
 
- {
 
-     FruitSmash,
 
-     BombExplode,
 
-     ArrowFire,
 
-     CannonFire,
 
-     None,
 
-     GunFire,
 
- }
 
- // This class in instantiated on GameManager, storing all the audio related assets
 
- public class AudioManager : MonoBehaviour
 
- {
 
-     [SerializeField] private AudioClip[] FruitSmashSounds;
 
-     [SerializeField] private AudioClip[] BombExplodeSounds;
 
-     [SerializeField] private AudioClip[] ArrowFiringSounds;
 
-     [SerializeField] private AudioClip[] CannonFiringSounds;
 
-     [SerializeField] private AudioClip[] GunSounds;
 
-     [SerializeField] private AudioClip LooseLifeSound;
 
-     [SerializeField] private AudioClip BackgroundMusic;
 
-     [SerializeField] private AudioClip GameOverSound;
 
-     public AudioClip GetRandomSound(SoundCategory cat)
 
-     {
 
-         AudioClip[] clips;
 
-         switch (cat)
 
-         {
 
-             case SoundCategory.FruitSmash:
 
-                 clips = FruitSmashSounds;
 
-                 break;
 
-             case SoundCategory.BombExplode:
 
-                 clips = BombExplodeSounds;
 
-                 break;
 
-             case SoundCategory.ArrowFire:
 
-                 clips = ArrowFiringSounds;
 
-                 break;
 
-             case SoundCategory.CannonFire:
 
-                 clips = CannonFiringSounds;
 
-                 break;
 
-             case SoundCategory.GunFire:
 
-                 clips = GunSounds ;
 
-                 break;
 
-             default:
 
-                 clips = null;
 
-                 break;
 
-         }
 
-         Debug.Assert(clips.Length > 0);
 
-         return clips[Random.Range(0, clips.Length)];
 
-     }
 
-     public GameObject InstantiateTemprorarySound(SoundCategory cat, Transform parent, float delay_dstroy_s = 0f)
 
-     {
 
-         GameObject empty = new GameObject();     
 
-         GameObject instance = Instantiate(empty, parent);
 
-         AudioSource audio = instance.AddComponent<AudioSource>();
 
-         if (cat != SoundCategory.None)
 
-         {
 
-             AudioClip clip = GetRandomSound(cat);
 
-             audio.clip = clip;
 
-             if (UserSettings.ins.openEffect) audio.Play();
 
-         }
 
-         if (delay_dstroy_s > 0f)
 
-         {
 
-             GamingManager.DelayDestroy(this, instance, delay_dstroy_s);
 
-         }
 
-         Destroy(empty);
 
-         return instance;
 
-     }
 
-     public GameObject InstantiateTemprorarySound(SoundCategory cat, Vector3 position, float delay_dstroy_s = 0f)
 
-     {
 
-         GameObject empty = new GameObject();        
 
-         GameObject instance = Instantiate(empty, position, Quaternion.identity);
 
-         AudioSource audio = instance.AddComponent<AudioSource>();
 
-         if (cat != SoundCategory.None)
 
-         {
 
-             AudioClip clip = GetRandomSound(cat); 
 
-             audio.clip = clip;
 
-             if (UserSettings.ins.openEffect) audio.Play();
 
-         }
 
-         if (delay_dstroy_s > 0f)
 
-         {
 
-             GamingManager.DelayDestroy(this, instance, delay_dstroy_s);
 
-         }
 
-         Destroy(empty);
 
-         return instance;
 
-     }
 
-     public AudioClip GetBackgroundMusic()
 
-     {
 
-         return BackgroundMusic;
 
-     }
 
-     public AudioClip GetLooseLifeSound()
 
-     {
 
-         return LooseLifeSound;
 
-     }
 
-     public AudioClip GetGameOverSound()
 
-     {
 
-         return GameOverSound;
 
-     }
 
- }
 
 
  |