コード例 #1
0
        public override void GenerateByte()
        {
            string            path = "E:/FantasyPark/src/trunk/Tools_SourceCode/ExcelToFlatBuffer/ExcelToFlatBuffer/ExcelToFlatBuffer/bin/Debug/CompileCShap/Script/AutoGenerate/Bytes/Table_Music.bytes";
            FlatBufferBuilder fbb  = new FlatBufferBuilder(1);

            Offset <DRMusic>[] offsets = new Offset <DRMusic> [3];

            offsets[0] = DRMusic.CreateDRMusic(fbb, 1, fbb.CreateString("登录背景音乐"), fbb.CreateString("Music_LoginIn"));
            offsets[1] = DRMusic.CreateDRMusic(fbb, 2, fbb.CreateString("选关背景音乐"), fbb.CreateString("Music_Menu"));
            offsets[2] = DRMusic.CreateDRMusic(fbb, 3, fbb.CreateString("游戏背景音乐"), fbb.CreateString("Music_Game"));

            VectorOffset dataOff   = Table_Music.CreateDataVector(fbb, offsets);
            var          configOff = Table_Music.CreateTable_Music(fbb, dataOff);

            Table_Music.FinishTable_MusicBuffer(fbb, configOff);
            using (var ms = new MemoryStream(fbb.DataBuffer.ToFullArray(), fbb.DataBuffer.Position, fbb.Offset))
            {
                try
                {
                    var data = ms.ToArray();
                    File.WriteAllBytes(path, data);
                    Console.WriteLine("已生成:" + path.ToString());
                }
                catch (Exception error)
                {
                    Console.WriteLine(error.ToString());
                }
            }
        }
コード例 #2
0
    /// <summary>
    /// 播放背景音乐
    /// </summary>
    /// <param name="soundComponent"></param>
    /// <param name="musicId"></param>
    /// <param name="userData"></param>
    /// <returns></returns>
    public static int?PlayMusic(this SoundComponent soundComponent, int musicId, object userData = null)
    {
        soundComponent.StopMusic();

        IDataTable <DRMusic> dtMusic = GameManager.DataTable.GetDataTable <DRMusic>();
        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.Asset), "Music", playSoundParams.Priority, playSoundParams, userData);
        return(s_MusicSerialId);
    }
コード例 #3
0
    public void ParseDataRow(string dataRowText)
    {
        DRMusic model = GameUtility.DeserializeObject <DRMusic>(dataRowText);

        Id    = model.Id;
        Name  = model.Name;
        Asset = model.Asset;
    }
コード例 #4
0
    public static int?PlayMusic(this SoundComponent soundComponent, int musicId, object userData = null)
    {
        soundComponent.StopMusic();

        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(null);
        }

        PlaySoundParams playSoundParams = PlaySoundParams.Create();

        playSoundParams.Priority           = 64;
        playSoundParams.Loop               = true;
        playSoundParams.VolumeInSoundGroup = 1f;
        playSoundParams.FadeInSeconds      = FadeVolumeDuration;
        playSoundParams.SpatialBlend       = 0f;
        s_MusicSerialId = soundComponent.PlaySound(AssetUtility.GetMusicAsset(drMusic.AssetName), "Music", Constant.AssetPriority.MusicAsset, playSoundParams, null, userData);
        return(s_MusicSerialId);
    }