Example #1
0
        public static void Main()//Main_8_4_1
        {
            MusicType mt = MusicType.Jazz;

            Console.WriteLine(mt.ToString());
            Console.WriteLine(mt.ToString("D"));
            Console.WriteLine(mt.ToString("G"));
        }
Example #2
0
    public void PlayUIMusic(MusicType type, bool useFadeOut = true)
    {
        var track = tracks?.Find(s => s.type == type);
        var clip  = track?.clip;

        if (clip == null)
        {
            Debug.Log($"Can't find clip with type \"{type.ToString()}\" in UISoundManager");
            return;
        }

        if (_currentMusic != null && _currentMusic == track)
        {
            return;
        }

        _currentMusic = track;

        if (useFadeOut && UIMusicPlayer.isPlaying)
        {
            _isFadingOut = true;
            return;
        }

        _isFadingOut = false;
        StartUIMusic();
    }
Example #3
0
        internal void PlayMusic(MusicType audioName)
        {
            if (audioName == MusicType.Mute)
            {
                musicSource.Type = audioName;
                musicSource.Source.Stop();
                return;
            }

            if (musics.TryGetValue(audioName.ToString(), out AudioClip clip))
            {
                Debug.Log($"Play Music {audioName}!");
                if (musicSource.Type == audioName && musicSource.Source.isPlaying)
                {
                    return;
                }

                musicSource.Type        = audioName;
                musicSource.Source.clip = clip;
                musicSource.Source.loop = true;
                musicSource.Source.Play();
            }
            else
            {
                Debug.LogWarning($"Music {audioName} not found!");
            }
        }
Example #4
0
    private void Start()
    {
        audioSouce  = GameObject.FindWithTag(musicType.ToString()).GetComponentsInChildren <AudioSource>();
        gameManager = GameManager.gameManager;
        slider      = GetComponentInChildren <Slider>();
        toggle      = GetComponentInChildren <Toggle>();

        slider.value = gameManager.soundVolume[musicType];
        toggle.isOn  = !gameManager.soundMute[musicType];
    }
Example #5
0
        public bool PlayNext(MusicType mt)
        {
            if (!isInitialized)
            {
                return(false);
            }

            List <FMOD.Sound> tracks = music[(short)mt];

            if (tracks.Count == 0)
            {
                return(false);
            }

            musicType = mt;

            short index = indices[(short)mt] = (short)((indices[(short)mt] + 1) % tracks.Count);

            InfoLog.WriteInfo(DateTime.Now.ToString() + "  - Changed track to: " + index + ", Music Type: " + mt.ToString(), EPrefix.AudioEngine);

            return(this.Play(tracks[index]));
        }