public void MODPlayVoiceLS(string filename, int channel, float volume, int character)
        {
            MODTextController.MODCurrentVoiceLayerDetect = channel;
            AudioLayerUnity item = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, channel)];

            if (currentAudio[AudioType.Voice].ContainsKey(channel))
            {
                currentAudio[AudioType.Voice].Remove(channel);
            }
            currentAudio[AudioType.Voice].Add(channel, new AudioInfo(volume, filename));
            if (item.IsPlaying())
            {
                item.StopAudio();
            }
            item.PlayAudio(filename, AudioType.Voice, volume);
            if (MODSystem.instance.modSceneController.MODLipSyncBoolCheck(character))
            {
                GameSystem.Instance.SceneController.MODLipSyncStart(character, channel, filename);
            }
            if (GameSystem.Instance.IsAuto)
            {
                item.OnLoadCallback(delegate
                {
                    GameSystem.Instance.AddWait(new Wait(item.GetRemainingPlayTime(), WaitTypes.WaitForVoice, null));
                });
            }
        }
示例#2
0
        public void PlayVoice(string filename, int channel, float volume)
        {
            string text = filename.Substring(0, 4);

            if (0 == 0)
            {
                AudioLayerUnity audio = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, channel)];
                if (currentAudio[AudioType.Voice].ContainsKey(channel))
                {
                    currentAudio[AudioType.Voice].Remove(channel);
                }
                currentAudio[AudioType.Voice].Add(channel, new AudioInfo(volume, filename));
                if (audio.IsPlaying())
                {
                    audio.StopAudio();
                }
                audio.PlayAudio(filename, AudioType.Voice, volume);
                if (GameSystem.Instance.IsAuto)
                {
                    audio.OnLoadCallback(delegate
                    {
                        GameSystem.Instance.AddWait(new Wait(audio.GetRemainingPlayTime(), WaitTypes.WaitForVoice, null));
                    });
                }
            }
        }
 public void StopAllAudio()
 {
     for (int i = 0; i < 6; i++)
     {
         AudioLayerUnity audioLayerUnity = channelDictionary[GetChannelByTypeChannel(AudioType.BGM, i)];
         if (audioLayerUnity.IsPlaying())
         {
             audioLayerUnity.StopAudio();
         }
     }
     for (int j = 0; j < 8; j++)
     {
         AudioLayerUnity audioLayerUnity2 = channelDictionary[GetChannelByTypeChannel(AudioType.SE, j)];
         if (audioLayerUnity2.IsPlaying())
         {
             audioLayerUnity2.StopAudio();
         }
     }
     for (int k = 0; k < 8; k++)
     {
         AudioLayerUnity audioLayerUnity3 = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, k)];
         if (audioLayerUnity3.IsPlaying())
         {
             audioLayerUnity3.StopAudio();
         }
     }
 }
        public void PlayAudio(string filename, AudioType type, int channel, float volume, float fadeintime = 0)
        {
            float startvolume = volume;

            if (fadeintime > 0f)
            {
                fadeintime /= 1000f;
                startvolume = 0f;
            }
            AudioLayerUnity audioLayerUnity = channelDictionary[GetChannelByTypeChannel(type, channel)];

            if (audioLayerUnity.IsPlaying())
            {
                audioLayerUnity.StopAudio();
            }
            bool loop = type == AudioType.BGM;

            if (type == AudioType.BGM)
            {
                if (currentAudio[AudioType.BGM].ContainsKey(channel))
                {
                    currentAudio[AudioType.BGM].Remove(channel);
                }
                currentAudio[AudioType.BGM].Add(channel, new AudioInfo(volume, filename));
            }
            audioLayerUnity.PlayAudio(filename, type, startvolume, loop);
            if (fadeintime > 0.05f)
            {
                audioLayerUnity.StartVolumeFade(volume, fadeintime);
            }
        }
        public void StopVoice(int channel)
        {
            AudioLayerUnity audioLayerUnity = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, channel)];

            audioLayerUnity.StopAudio();
            if (currentAudio[AudioType.Voice].ContainsKey(channel))
            {
                currentAudio[AudioType.Voice].Remove(channel);
            }
        }
        public void StopBGM(int channel)
        {
            AudioLayerUnity audioLayerUnity = channelDictionary[channel];

            audioLayerUnity.StopAudio();
            if (currentAudio[AudioType.BGM].ContainsKey(channel))
            {
                currentAudio[AudioType.BGM].Remove(channel);
            }
        }
        public void PlaySE(string filename, int channel, float volume, float pan)
        {
            AudioLayerUnity audioLayerUnity = channelDictionary[GetChannelByTypeChannel(AudioType.SE, channel)];

            if (audioLayerUnity.IsPlaying())
            {
                audioLayerUnity.StopAudio();
            }
            audioLayerUnity.PlayAudio(filename, AudioType.SE, volume);
        }
 public void StopAllVoice()
 {
     for (int i = 0; i < 8; i++)
     {
         AudioLayerUnity audioLayerUnity = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, i)];
         if (audioLayerUnity.IsPlaying())
         {
             audioLayerUnity.StopAudio();
         }
     }
 }
        public void FadeOutSE(int channel, float time, bool waitForFade)
        {
            float           num = time / 1000f;
            int             channelByTypeChannel = GetChannelByTypeChannel(AudioType.SE, channel);
            AudioLayerUnity audioLayerUnity      = channelDictionary[channelByTypeChannel];

            audioLayerUnity.FadeOut(num);
            if (waitForFade)
            {
                GameSystem.Instance.AddWait(new Wait(num, WaitTypes.WaitForAudio, audioLayerUnity.StopAudio));
            }
        }
        public AudioController()
        {
            GameSystem.Instance.AudioController = this;
            currentAudio.Add(AudioType.BGM, new Dictionary <int, AudioInfo>());
            currentAudio.Add(AudioType.Voice, new Dictionary <int, AudioInfo>());
            audioParent = new GameObject("AudioLayers");
            int num = 0;

            for (int i = 0; i < 6; i++)
            {
                GameObject      gameObject      = new GameObject("BGM Channel " + i.ToString("D2"));
                AudioLayerUnity audioLayerUnity = gameObject.AddComponent <AudioLayerUnity>();
                gameObject.transform.parent = audioParent.transform;
                audioLayerUnity.Prepare(num);
                channelDictionary.Add(num, audioLayerUnity);
                num++;
            }
            for (int j = 0; j < 8; j++)
            {
                GameObject      gameObject2      = new GameObject("Voice Channel " + j.ToString("D2"));
                AudioLayerUnity audioLayerUnity2 = gameObject2.AddComponent <AudioLayerUnity>();
                gameObject2.transform.parent = audioParent.transform;
                audioLayerUnity2.Prepare(num);
                channelDictionary.Add(num, audioLayerUnity2);
                num++;
            }
            for (int k = 0; k < 8; k++)
            {
                GameObject      gameObject3      = new GameObject("SE Channel " + k.ToString("D2"));
                AudioLayerUnity audioLayerUnity3 = gameObject3.AddComponent <AudioLayerUnity>();
                gameObject3.transform.parent = audioParent.transform;
                audioLayerUnity3.Prepare(num);
                channelDictionary.Add(num, audioLayerUnity3);
                num++;
            }
            for (int l = 0; l < 2; l++)
            {
                GameObject      gameObject4      = new GameObject("System Channel " + l.ToString("D2"));
                AudioLayerUnity audioLayerUnity4 = gameObject4.AddComponent <AudioLayerUnity>();
                gameObject4.transform.parent = audioParent.transform;
                audioLayerUnity4.Prepare(num);
                channelDictionary.Add(num, audioLayerUnity4);
                num++;
            }
            AudioConfiguration configuration = AudioSettings.GetConfiguration();

            configuration.sampleRate = 44100;
            AudioSettings.Reset(configuration);
        }
        public void FadeOutBGM(int channel, int time, bool waitForFade)
        {
            float           num = (float)time / 1000f;
            int             channelByTypeChannel = GetChannelByTypeChannel(AudioType.BGM, channel);
            AudioLayerUnity audioLayerUnity      = channelDictionary[channelByTypeChannel];

            audioLayerUnity.FadeOut(num);
            if (waitForFade)
            {
                GameSystem.Instance.AddWait(new Wait(num, WaitTypes.WaitForAudio, audioLayerUnity.StopAudio));
            }
            if (currentAudio[AudioType.BGM].ContainsKey(channel))
            {
                currentAudio[AudioType.BGM].Remove(channel);
            }
        }
        public void ChangeVolumeOfBGM(int channel, float volume, float time)
        {
            int             channelByTypeChannel = GetChannelByTypeChannel(AudioType.BGM, channel);
            float           time2           = time / 1000f;
            AudioLayerUnity audioLayerUnity = channelDictionary[channelByTypeChannel];

            if (currentAudio[AudioType.BGM].ContainsKey(channel))
            {
                currentAudio[AudioType.BGM][channel].Volume = volume;
            }
            else
            {
                Debug.LogWarning("ChangeVolumeOfBGM could not find existing currentAudio for channel!");
            }
            audioLayerUnity.StartVolumeFade(volume, time2);
        }
 public void RefreshLayerVolumes()
 {
     for (int i = 0; i < 6; i++)
     {
         AudioLayerUnity audioLayerUnity = channelDictionary[GetChannelByTypeChannel(AudioType.BGM, i)];
         audioLayerUnity.SetBaseVolume(BGMVolume * GlobalVolume);
     }
     for (int j = 0; j < 8; j++)
     {
         AudioLayerUnity audioLayerUnity2 = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, j)];
         audioLayerUnity2.SetBaseVolume(VoiceVolume * GlobalVolume);
     }
     for (int k = 0; k < 8; k++)
     {
         AudioLayerUnity audioLayerUnity3 = channelDictionary[GetChannelByTypeChannel(AudioType.SE, k)];
         audioLayerUnity3.SetBaseVolume(SoundVolume * GlobalVolume);
     }
     for (int l = 0; l < 2; l++)
     {
         AudioLayerUnity audioLayerUnity4 = channelDictionary[GetChannelByTypeChannel(AudioType.System, l)];
         audioLayerUnity4.SetBaseVolume(SystemVolume * GlobalVolume);
     }
 }
        public void StopSE(int channel)
        {
            AudioLayerUnity audioLayerUnity = channelDictionary[GetChannelByTypeChannel(AudioType.SE, channel)];

            audioLayerUnity.StopAudio();
        }
        public void PlayVoice(string filename, int channel, float volume)
        {
            string text = filename.Substring(0, 4);
            bool   flag = false;

            switch (text)
            {
            case "chie":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVChie").BoolValue();
                break;

            case "eiji":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVEiji").BoolValue();
                break;

            case "kana":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVKana").BoolValue();
                break;

            case "kira":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVKira").BoolValue();
                break;

            case "mast":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVMast").BoolValue();
                break;

            case "mura":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVMura").BoolValue();
                break;

            case "riho":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVRiho").BoolValue();
                break;

            case "rmn_":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVRmn_").BoolValue();
                break;

            case "sari":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVSari").BoolValue();
                break;

            case "tika":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVTika").BoolValue();
                break;

            case "yayo":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVYayo").BoolValue();
                break;

            default:
                flag = BurikoMemory.Instance.GetGlobalFlag("GVOther").BoolValue();
                break;
            }
            if (!flag)
            {
                AudioLayerUnity audio = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, channel)];
                if (currentAudio[AudioType.Voice].ContainsKey(channel))
                {
                    currentAudio[AudioType.Voice].Remove(channel);
                }
                currentAudio[AudioType.Voice].Add(channel, new AudioInfo(volume, filename));
                if (audio.IsPlaying())
                {
                    audio.StopAudio();
                }
                audio.PlayAudio(filename, AudioType.Voice, volume);
                if (GameSystem.Instance.IsAuto)
                {
                    audio.OnLoadCallback(delegate
                    {
                        GameSystem.Instance.AddWait(new Wait(audio.GetRemainingPlayTime(), WaitTypes.WaitForVoice, null));
                    });
                }
            }
        }
        public float GetRemainingVoicePlayTime(int channel)
        {
            AudioLayerUnity audioLayerUnity = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, channel)];

            return(audioLayerUnity.GetRemainingPlayTime());
        }
        public void AddVoiceFinishCallback(int channel, AudioFinishCallback callback)
        {
            AudioLayerUnity audioLayerUnity = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, channel)];

            audioLayerUnity.RegisterCallback(callback);
        }
        public bool IsVoicePlaying(int channel)
        {
            AudioLayerUnity audioLayerUnity = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, channel)];

            return(audioLayerUnity.IsPlaying());
        }