public static int?PlayMusic(this SoundComponent soundComponent, int musicId, object userData = null)
        {
            soundComponent.StopMusic();

            IDataTable <DRMusic> dtMusic = GameEntry.DataTable.GetDataTable <DRMusic>();

            if (dtMusic == null)
            {
                Log.Warning("Music data is null", musicId.ToString());
                return(null);
            }

            DRMusic drMusic = dtMusic.GetDataRow(musicId);

            if (drMusic == null)
            {
                Log.Warning("Can not load music '{0}' from data table.", musicId.ToString());
                return(null);
            }

            PlaySoundParams playSoundParams = new PlaySoundParams
            {
                Priority           = 64,
                Loop               = true,
                VolumeInSoundGroup = 1f,
                FadeInSeconds      = FadeVolumeDuration,
                SpatialBlend       = 0f,
            };

            s_MusicSerialId = soundComponent.PlaySound(AssetUtility.GetMusicAsset(drMusic.AssetName), "Music", playSoundParams, null, userData);
            return(s_MusicSerialId);
        }
Exemplo n.º 2
0
        public static int PlayMusic(this SoundComponent soundComponent, int musicId, object userData = null)
        {
            IDataTable <DRMusic> dtMusic = GameEntry.DataTable.GetDataTable <DRMusic>();
            DRMusic drMusic = dtMusic.GetDataRow(musicId);

            if (drMusic == null)
            {
                Log.Warning("Can not load music '{0}' from data table.", musicId.ToString());
                return(-1);
            }

            PlaySoundParams playSoundParams = new PlaySoundParams
            {
                Priority           = 64,
                Loop               = true,
                VolumeInSoundGroup = 1f,
                SpatialBlend       = 0f,
            };

            return(soundComponent.PlaySound(AssetUtility.GetMusicAsset(drMusic.AssetName), "Music", playSoundParams, null, userData));
        }