Example #1
0
        internal AudioSource GetAudioSource(string label)
        {
            SoundAudioPlayer player = GetPlayer(label);

            if (player == null)
            {
                return(null);
            }
            return(player.Audio.AudioSource);
        }
Example #2
0
        internal float GetSamplesVolume(string label)
        {
            SoundAudioPlayer player = GetPlayer(label);

            if (player == null)
            {
                return(0);
            }
            return(player.GetSamplesVolume());
        }
Example #3
0
        internal void Stop(string label, float fadeTime)
        {
            SoundAudioPlayer player = GetPlayer(label);

            if (player == null)
            {
                return;
            }
            player.Stop(fadeTime);
        }
Example #4
0
        internal bool IsPlayingLoop(string label)
        {
            SoundAudioPlayer player = GetPlayer(label);

            if (player == null)
            {
                return(false);
            }
            return(player.IsPlayingLoop());
        }
Example #5
0
        SoundAudioPlayer GetPlayerOrCreateIfMissing(string label)
        {
            SoundAudioPlayer player = GetPlayer(label);

            if (player == null)
            {
                player = this.transform.AddChildGameObjectComponent <SoundAudioPlayer>(label);
                player.Init(label, this);
                PlayerList.Add(label, player);
            }
            return(player);
        }
Example #6
0
        SoundAudioPlayer GetOnlyOnePlayer(string label, float fadeOutTime)
        {
            SoundAudioPlayer player = GetPlayerOrCreateIfMissing(label);

            if (PlayerList.Count > 1)
            {
                foreach (var keyValue in PlayerList)
                {
                    if (keyValue.Value != player)
                    {
                        keyValue.Value.Stop(fadeOutTime);
                    }
                }
            }
            return(player);
        }
Example #7
0
        //初期化
        public void Init(SoundAudioPlayer player, SoundData soundData)
        {
            this.Player        = player;
            this.Data          = soundData;
            this.Audio0        = this.gameObject.AddComponent <AudioSource>();
            Audio0.playOnAwake = false;
            if (Data.EnableIntroLoop)
            {
                Audio1             = this.gameObject.AddComponent <AudioSource>();
                Audio1.playOnAwake = false;
                Audio1.clip        = Data.Clip;
                Audio1.loop        = false;
            }
            AudioSource = Audio0;

            AudioSource.clip = Data.Clip;
            AudioSource.loop = Data.IsLoop && !Data.EnableIntroLoop;
            if (Data.File != null)
            {
                Data.File.AddReferenceComponent(this.gameObject);
            }
        }
Example #8
0
        //セーブデータ用のバイナリ読み込み
        internal void Read(BinaryReader reader)
        {
            int version = reader.ReadInt32();

            if (version <= Version)
            {
                if (version > Version0)
                {
                    GroupVolume = reader.ReadSingle();
                }
                int playerCount = reader.ReadInt32();
                for (int i = 0; i < playerCount; ++i)
                {
                    string           label  = reader.ReadString();
                    SoundAudioPlayer player = GetPlayerOrCreateIfMissing(label);
                    reader.ReadBuffer(player.Read);
                }
            }
            else
            {
                Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.UnknownVersion, version));
            }
        }
Example #9
0
        internal void Play(string label, SoundData data, float fadeInTime, float fadeOutTime)
        {
            SoundAudioPlayer player = (MultiPlay) ? GetPlayerOrCreateIfMissing(label) : GetOnlyOnePlayer(label, fadeOutTime);

            player.Play(data, fadeInTime, fadeOutTime);
        }