Exemple #1
0
    public int PlaySE_Ex(string path)
    {
        int num = -1;

        for (int i = 0; i < this.audioSEList.Count; i++)
        {
            if (!this.audioSEList[i].ads.isPlaying)
            {
                num = i;
                break;
            }
        }
        if (num == -1)
        {
            global::Debug.LogError("CAN NOT PLAY SE");
        }
        else
        {
            AudioClip clip     = this.LoadAudio(path);
            SoundCtr  soundCtr = this.audioSEList[num];
            soundCtr.value      = 0f;
            soundCtr.seName     = path;
            soundCtr.autoDel    = true;
            soundCtr.time       = 0f;
            soundCtr.act        = null;
            soundCtr.ads.clip   = clip;
            soundCtr.ads.loop   = false;
            soundCtr.ads.pitch  = 1f;
            soundCtr.selfVolume = -1;
            soundCtr.Play(true);
        }
        return(num);
    }
Exemple #2
0
    public void PlayTimeScaleSE(string path, float time = 0f, bool loop = false, bool isAutoDel = true, Action <int> act = null, int selfVolume = -1)
    {
        AudioClip clip = this.LoadAudio(path);
        int       i;

        for (i = this.SE_MAX; i < this.audioSEList.Count; i++)
        {
            if (this.audioSEList[i].seName == string.Empty)
            {
                break;
            }
        }
        if (i < this.SE_MAX || i >= this.audioSEList.Count)
        {
            global::Debug.LogWarning("<color=red>======================SoundMng::PlaySE ファイル </color>" + path + "<color=red> SE OVER</color>");
            return;
        }
        SoundCtr soundCtr = this.audioSEList[i];

        soundCtr.value      = 0f;
        soundCtr.seName     = path;
        soundCtr.autoDel    = isAutoDel;
        soundCtr.time       = time;
        soundCtr.act        = act;
        soundCtr.ads.clip   = clip;
        soundCtr.ads.loop   = loop;
        soundCtr.ads.pitch  = 1f;
        soundCtr.selfVolume = selfVolume;
        soundCtr.Play(true);
    }
Exemple #3
0
 public void StopAllSE(float time = 0f)
 {
     for (int i = 0; i < this.audioSEList.Count; i++)
     {
         if (this.audioSEList[i].seName != string.Empty)
         {
             SoundCtr soundCtr = this.audioSEList[i];
             soundCtr.time = time;
             soundCtr.act  = null;
             soundCtr.Play(false);
         }
     }
 }
Exemple #4
0
 public void StopSE_Ex(int handle)
 {
     if (this.audioSEList.Count <= handle)
     {
         global::Debug.LogErrorFormat("INVALID HANDLE : {0}", new object[]
         {
             handle
         });
         return;
     }
     if (this.audioSEList[handle].ads.isPlaying)
     {
         SoundCtr soundCtr = this.audioSEList[handle];
         soundCtr.time = 0f;
         soundCtr.act  = null;
         soundCtr.Stop();
     }
 }
Exemple #5
0
    public void StopSE(string path, float time = 0f, Action <int> act = null)
    {
        int i;

        for (i = 0; i < this.audioSEList.Count; i++)
        {
            if (this.audioSEList[i].seName == path)
            {
                break;
            }
        }
        if (i == this.audioSEList.Count)
        {
            global::Debug.Log("======================SoundMng::PlaySE 番号 " + path + " NOT PLAYING SE");
            return;
        }
        SoundCtr soundCtr = this.audioSEList[i];

        soundCtr.time = time;
        soundCtr.act  = act;
        soundCtr.Play(false);
    }
Exemple #6
0
 protected virtual void Awake()
 {
     if (this.isInitialized)
     {
         return;
     }
     SoundMng.instance      = this;
     this.previousTimeScale = Time.timeScale;
     this.audioSEList       = new List <SoundCtr>();
     if (this.mixer == null)
     {
         AudioMixer audioMixer = Resources.Load <AudioMixer>("AudioMixer/default");
         this.mixer = audioMixer.FindMatchingGroups("Master")[0];
     }
     if (this.goSE == null)
     {
         this.goSE = new GameObject();
         this.goSE.AddComponent <AudioSource>();
         this.goSE.AddComponent <SoundCtr>();
     }
     for (int i = 0; i < this.SE_MAX + this.TS_SE_MAX; i++)
     {
         GameObject gameObject = (i <= 0) ? this.goSE : UnityEngine.Object.Instantiate <GameObject>(this.goSE);
         gameObject.transform.SetParent(base.transform);
         gameObject.transform.localPosition = Vector3.zero;
         gameObject.transform.localScale    = Vector2.one;
         AudioSource component  = gameObject.GetComponent <AudioSource>();
         SoundCtr    component2 = gameObject.GetComponent <SoundCtr>();
         if (i >= this.SE_MAX)
         {
             gameObject.name = "R_TSSE" + i.ToString();
             component.outputAudioMixerGroup = this.mixer;
         }
         else
         {
             gameObject.name = "R_SE" + i.ToString();
         }
         component2.seName  = string.Empty;
         component2.go      = gameObject;
         component2.ads     = component;
         component2.value   = 0f;
         component2.autoDel = false;
         component2.time    = 0f;
         component2.act     = null;
         component.volume   = 0f;
         this.audioSEList.Add(component2);
     }
     this.bgmValue      = 0f;
     this.audioBGM_List = new List <AudioSource>();
     if (this.goAudioBGM_List == null || this.goAudioBGM_List.Count == 0)
     {
         this.goAudioBGM_List = new List <GameObject>();
         for (int i = 0; i < 2; i++)
         {
             GameObject gameObject2 = new GameObject();
             gameObject2.name                    = "R_BGM" + i.ToString();
             gameObject2.transform.parent        = base.transform;
             gameObject2.transform.localPosition = new Vector3(0f, 0f, 0f);
             gameObject2.transform.localScale    = new Vector3(1f, 1f, 1f);
             gameObject2.AddComponent <AudioSource>();
             this.goAudioBGM_List.Add(gameObject2);
             AudioSource component = this.goAudioBGM_List[i].GetComponent <AudioSource>();
             component.volume = 0f;
             this.audioBGM_List.Add(component);
             this.goAudioBGM_List[i].SetActive(false);
         }
     }
     else
     {
         for (int i = 0; i < this.goAudioBGM_List.Count; i++)
         {
             AudioSource component = this.goAudioBGM_List[i].GetComponent <AudioSource>();
             component.outputAudioMixerGroup = this.mixer;
             component.volume = 0f;
             this.audioBGM_List.Add(component);
             this.goAudioBGM_List[i].SetActive(false);
         }
     }
     this.ReleaseAudio();
     if (AssetDataMng.Instance() == null)
     {
         AssetDataMng assetDataMng = base.gameObject.AddComponent <AssetDataMng>();
         assetDataMng.Initialize();
     }
     OptionSetting.LoadSoundVolume();
     this.isInitialized = true;
 }