예제 #1
0
        public Transform Play(
            Manager.Sound.Type type,
            string assetBundleName,
            string assetName,
            float delayTime       = 0.0f,
            float fadeTime        = 0.0f,
            bool isAssetEqualPlay = true,
            bool isAsync          = true,
            int settingNo         = -1,
            bool isBundleUnload   = true)
        {
            int       index     = (int)type;
            LoadSound loadSound = (LoadSound) new GameObject("Sound Loading").AddComponent <LoadSound>();

            loadSound.assetBundleName  = assetBundleName;
            loadSound.assetName        = assetName;
            loadSound.type             = type;
            loadSound.delayTime        = delayTime;
            loadSound.fadeTime         = fadeTime;
            loadSound.isAssetEqualPlay = isAssetEqualPlay;
            loadSound.isAsync          = isAsync;
            loadSound.settingNo        = settingNo;
            loadSound.isBundleUnload   = isBundleUnload;
            return(this.SetParent(this.typeObjects[index], (LoadAudioBase)loadSound, this.settingObjects[index]));
        }
예제 #2
0
            public static AudioSource Play(Manager.Sound.Type type, AudioClip clip, float fadeTime = 0.0f)
            {
                AudioSource audio = Singleton <Manager.Sound> .Instance.Play(type, clip, fadeTime);

                ObservableExtensions.Subscribe <Unit>(Observable.Take <Unit>(Observable.Where <Unit>((IObservable <M0>)ObservableTriggerExtensions.UpdateAsObservable((Component)audio), (Func <M0, bool>)(__ => !audio.get_isPlaying())), 1), (Action <M0>)(__ => Object.Destroy((Object)((Component)audio).get_gameObject())));
                return(audio);
            }
예제 #3
0
        public AudioSource CreateCache(
            Manager.Sound.Type type,
            string bundle,
            string asset,
            string manifest = null)
        {
            int key = (int)type;
            Dictionary <string, AudioSource> dictionary1;

            if (!this.dicASCache.TryGetValue(key, out dictionary1))
            {
                Dictionary <string, AudioSource> dictionary2 = new Dictionary <string, AudioSource>();
                this.dicASCache[key] = dictionary2;
                dictionary1          = dictionary2;
            }
            AudioSource audioSource;

            if (!dictionary1.TryGetValue(asset, out audioSource))
            {
                audioSource = this.Create(type, true);
                ((Object)audioSource).set_name(asset);
                audioSource.set_clip(new AssetBundleManifestData(bundle, asset, manifest).GetAsset <AudioClip>());
                this.Register(audioSource.get_clip());
                dictionary1.Add(asset, audioSource);
            }
            return(audioSource);
        }
예제 #4
0
 public static AudioSource Get(
     Manager.Sound.Type type,
     string bundle,
     string asset,
     string manifest = null)
 {
     return(!Singleton <Manager.Sound> .IsInstance() ? (AudioSource)null : Singleton <Manager.Sound> .Instance.CreateCache(type, bundle, asset, manifest));
 }
예제 #5
0
        public AudioSource Create(Manager.Sound.Type type, bool isCache = false)
        {
            int        index      = (int)type;
            GameObject gameObject = (GameObject)Object.Instantiate <GameObject>((M0)this.settingObjects[index], !isCache ? this.typeObjects[index] : this.ASCacheRoot, false);

            gameObject.SetActive(true);
            return((AudioSource)gameObject.GetComponent <AudioSource>());
        }
예제 #6
0
 public static void Remove(Manager.Sound.Type type, string bundle, string asset, string manifest = null)
 {
     if (!Singleton <Manager.Sound> .IsInstance())
     {
         return;
     }
     Singleton <Manager.Sound> .Instance.ReleaseCache(type, bundle, asset, manifest);
 }
예제 #7
0
        public AudioSource Play(Manager.Sound.Type type, AudioClip clip, float fadeTime = 0.0f)
        {
            AudioSource audioSource = this.Create(type, false);

            audioSource.set_clip(clip);
            ((Component)audioSource).GetOrAddComponent <FadePlayer>().SafeProc <FadePlayer>((Action <FadePlayer>)(p => p.Play(fadeTime)));
            return(audioSource);
        }
예제 #8
0
        public AudioSource Play(int key, Manager.Sound.Type soundType, float fadeTime = 0.0f)
        {
            List <SoundPack.Data3D> source;

            if (!this._actionSEDataTable.TryGetValue(key, out source))
            {
                return((AudioSource)null);
            }
            return(source.IsNullOrEmpty <SoundPack.Data3D>() ? (AudioSource)null : this.Play((SoundPack.IData)source[Random.Range(0, source.Count)], soundType, fadeTime));
        }
예제 #9
0
        public void Stop(Manager.Sound.Type type)
        {
            List <GameObject> gameObjectList = new List <GameObject>();
            Transform         typeObject     = this.typeObjects[(int)type];

            for (int index = 0; index < typeObject.get_childCount(); ++index)
            {
                gameObjectList.Add(((Component)typeObject.GetChild(index)).get_gameObject());
            }
            gameObjectList.ForEach((Action <GameObject>)(p => Object.Destroy((Object)p)));
        }
예제 #10
0
        public List <AudioSource> GetPlayingList(Manager.Sound.Type type)
        {
            List <AudioSource> audioSourceList = new List <AudioSource>();
            Transform          typeObject      = this.typeObjects[(int)type];

            for (int index = 0; index < typeObject.get_childCount(); ++index)
            {
                audioSourceList.Add((AudioSource)((Component)typeObject.GetChild(index)).GetComponent <AudioSource>());
            }
            return(audioSourceList);
        }
예제 #11
0
        public bool IsPlay(Manager.Sound.Type type, Transform trans)
        {
            Transform typeObject = this.typeObjects[(int)type];

            for (int index = 0; index < typeObject.get_childCount(); ++index)
            {
                if (Object.op_Equality((Object)typeObject.GetChild(index), (Object)trans))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #12
0
        public bool IsPlay(Manager.Sound.Type type, string playName = null)
        {
            Transform typeObject = this.typeObjects[(int)type];

            for (int index = 0; index < typeObject.get_childCount(); ++index)
            {
                if (playName.IsNullOrEmpty() || !(playName != ((Object)typeObject.GetChild(index)).get_name()))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #13
0
        public void Stop(Manager.Sound.Type type, Transform trans)
        {
            Transform typeObject = this.typeObjects[(int)type];

            for (int index = 0; index < typeObject.get_childCount(); ++index)
            {
                Transform child = typeObject.GetChild(index);
                if (Object.op_Equality((Object)child, (Object)trans))
                {
                    Object.Destroy((Object)((Component)child).get_gameObject());
                    break;
                }
            }
        }
예제 #14
0
        private void LoadSetting(Manager.Sound.Type type, int settingNo = -1)
        {
            string          self            = type.ToString();
            AssetBundleData assetBundleData = new AssetBundleData("sound/setting/object/00.unity3d", self.ToLower());
            GameObject      gameObject      = (GameObject)Object.Instantiate <GameObject>((M0)assetBundleData.GetAsset <GameObject>(), this.rootSetting, false);

            ((Object)gameObject).set_name(self + "_Setting");
            this.AudioSettingData((AudioSource)gameObject.GetComponent <AudioSource>(), settingNo);
            if (self.CompareParts("gamese", true))
            {
                ;
            }
            this.settingObjects[(int)type] = gameObject;
            assetBundleData.UnloadBundle(true, false);
        }
예제 #15
0
        public AudioSource Play(SoundPack.IData data, Manager.Sound.Type type, float fadeTime = 0.0f)
        {
            AudioClip clip = this.Load(data);

            if (Object.op_Equality((Object)clip, (Object)null))
            {
                return((AudioSource)null);
            }
            AudioSource audio = Illusion.Game.Utils.Sound.Play(type, clip, fadeTime);

            if (type == Manager.Sound.Type.GameSE3D && Object.op_Inequality((Object)audio, (Object)null))
            {
                this.PlayingAudioList.RemoveAll((Predicate <AudioSource>)(x => Object.op_Equality((Object)x, (Object)null) || Object.op_Equality((Object)((Component)x).get_gameObject(), (Object)null)));
                if (this._soundSystemInfo.Game3DMaxCount <= this.PlayingAudioList.Count)
                {
                    int                num             = this.PlayingAudioList.Count - this._soundSystemInfo.Game3DMaxCount + 1;
                    Transform          cameraT         = ((Component)Singleton <Manager.Map> .Instance.Player.CameraControl.CameraComponent).get_transform();
                    List <AudioSource> audioSourceList = ListPool <AudioSource> .Get();

                    audioSourceList.AddRange((IEnumerable <AudioSource>) this.PlayingAudioList);
                    audioSourceList.Sort((Comparison <AudioSource>)((a1, a2) => this.GetSqrDistanceSort(cameraT, ((Component)a2).get_transform(), ((Component)a1).get_transform())));
                    for (int index = 0; index < num; ++index)
                    {
                        AudioSource element = audioSourceList.GetElement <AudioSource>(index);
                        this.PlayingAudioList.Remove(element);
                        Object.Destroy((Object)((Component)element).get_gameObject());
                    }
                    ListPool <AudioSource> .Release(audioSourceList);
                }
                ObservableExtensions.Subscribe <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnDestroyAsObservable((Component)audio), (System.Action <M0>)(_ =>
                {
                    if (!Object.op_Inequality((Object)audio, (Object)null))
                    {
                        return;
                    }
                    this.PlayingAudioList.Remove(audio);
                }));
                this.PlayingAudioList.Add(audio);
            }
            if (data is SoundPack.Data3D data3D)
            {
                audio.set_minDistance(data3D.MinDistance);
                audio.set_maxDistance(data3D.MaxDistance);
            }
            return(audio);
        }
예제 #16
0
        public Transform FindAsset(Manager.Sound.Type type, string assetName, string assetBundleName = null)
        {
            if (this.typeObjects == null)
            {
                return((Transform)null);
            }
            Transform typeObject = this.typeObjects[(int)type];

            for (int index = 0; index < typeObject.get_childCount(); ++index)
            {
                Transform     child = typeObject.GetChild(index);
                LoadAudioBase componentInChildren = (LoadAudioBase)((Component)child).GetComponentInChildren <LoadAudioBase>();
                if (Object.op_Inequality((Object)componentInChildren, (Object)null) && Object.op_Inequality((Object)componentInChildren.clip, (Object)null) && componentInChildren.assetName == assetName && ((assetBundleName == null || componentInChildren.assetBundleName == assetBundleName) && (type != Manager.Sound.Type.BGM || Object.op_Inequality((Object)((Component)child).get_gameObject(), (Object)this.oldBGM))))
                {
                    return(child);
                }
            }
            return((Transform)null);
        }
예제 #17
0
 protected override void Awake()
 {
     if (!this.CheckInstance())
     {
         return;
     }
     Object.DontDestroyOnLoad((Object)((Component)this).get_gameObject());
     Manager.Sound.Mixer = new AssetBundleData("sound/data/mixer/00.unity3d", "master").GetAsset <AudioMixer>();
     this.rootSetting    = new GameObject("SettingObject").get_transform();
     this.rootSetting.SetParent(((Component)this).get_transform(), false);
     this.rootPlay = new GameObject("PlayObject").get_transform();
     this.rootPlay.SetParent(((Component)this).get_transform(), false);
     this.LoadSettingData();
     this.settingObjects = new GameObject[Illusion.Utils.Enum <Manager.Sound.Type> .Length];
     this.typeObjects    = new Transform[this.settingObjects.Length];
     for (int index = 0; index < this.settingObjects.Length; ++index)
     {
         Manager.Sound.Type type = (Manager.Sound.Type)index;
         this.LoadSetting(type, -1);
         Transform transform = new GameObject(type.ToString()).get_transform();
         transform.SetParent(this.rootPlay, false);
         this.typeObjects[index] = transform;
     }
     this.dicASCache  = new Dictionary <int, Dictionary <string, AudioSource> >();
     this.ASCacheRoot = new GameObject("AudioSourceCache").get_transform();
     this.ASCacheRoot.SetParent(this.rootPlay, false);
     this.listener = new GameObject("Listener", new System.Type[1]
     {
         typeof(AudioListener)
     }).get_transform();
     this.listener.SetParent(((Component)this).get_transform(), false);
     if (!Object.op_Inequality((Object)Camera.get_main(), (Object)null))
     {
         return;
     }
     this._listener = ((Component)Camera.get_main()).get_transform();
 }
예제 #18
0
        public void ReleaseCache(Manager.Sound.Type type, string bundle, string asset, string manifest = null)
        {
            int key = (int)type;
            Dictionary <string, AudioSource> dictionary;

            if (!this.dicASCache.TryGetValue(key, out dictionary))
            {
                return;
            }
            AudioSource audioSource;

            if (dictionary.TryGetValue(asset, out audioSource))
            {
                this.Remove(audioSource.get_clip());
                Object.Destroy((Object)((Component)audioSource).get_gameObject());
                dictionary.Remove(asset);
                AssetBundleManager.UnloadAssetBundle(bundle, false, manifest, false);
            }
            if (((IEnumerable <KeyValuePair <string, AudioSource> >)dictionary).Any <KeyValuePair <string, AudioSource> >())
            {
                return;
            }
            this.dicASCache.Remove(key);
        }
예제 #19
0
 public static AudioSource Get(Manager.Sound.Type type, AssetBundleManifestData data)
 {
     return(!Singleton <Manager.Sound> .IsInstance() ? (AudioSource)null : Singleton <Manager.Sound> .Instance.CreateCache(type, data));
 }
예제 #20
0
 public Stop(Manager.Sound.Type type)
 {
     this.type = type;
 }
예제 #21
0
 public Play(Manager.Sound.Type type)
 {
     this.type = type;
 }
예제 #22
0
 public void Cast(Manager.Sound.Type type)
 {
     this.type            = type;
     this.assetBundleName = Sound.SoundBasePath[this.type];
 }
예제 #23
0
 public Setting(Manager.Sound.Type type)
 {
     this.Cast(type);
 }
예제 #24
0
 public void SetParent(Manager.Sound.Type type, Transform t)
 {
     t.SetParent(this.typeObjects[(int)type], false);
 }
예제 #25
0
 public AudioSource CreateCache(Manager.Sound.Type type, AssetBundleManifestData data)
 {
     return(this.CreateCache(type, data.bundle, data.asset, data.manifest));
 }
예제 #26
0
 public AudioSource CreateCache(Manager.Sound.Type type, AssetBundleData data)
 {
     return(this.CreateCache(type, data.bundle, data.asset, (string)null));
 }