96 lines
2.5 KiB
C#
96 lines
2.5 KiB
C#
using System.IO;
|
||
using System.Text;
|
||
using UnityEngine;
|
||
using UnityGameFramework.Runtime;
|
||
|
||
namespace DataTable
|
||
{
|
||
/// <summary>
|
||
/// 声音配置表。
|
||
/// </summary>
|
||
public class DRSE : DataRowBase
|
||
{
|
||
private int m_Id = 0;
|
||
|
||
/// <summary>
|
||
/// 获取声音编号。
|
||
/// </summary>
|
||
public override int Id
|
||
{
|
||
get
|
||
{
|
||
return m_Id;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取资源名称。
|
||
/// </summary>
|
||
public string AssetName
|
||
{
|
||
get;
|
||
private set;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取优先级(默认0,128最高,-128最低)。
|
||
/// </summary>
|
||
public int Priority
|
||
{
|
||
get;
|
||
private set;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取音量(0~1)。
|
||
/// </summary>
|
||
public float Volume
|
||
{
|
||
get;
|
||
private set;
|
||
}
|
||
|
||
public override bool ParseDataRow(string dataRowString, object userData)
|
||
{
|
||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||
for (int i = 0; i < columnStrings.Length; i++)
|
||
{
|
||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||
}
|
||
|
||
int index = 0;
|
||
index++;
|
||
m_Id = int.Parse(columnStrings[index++]);
|
||
index++;
|
||
AssetName = columnStrings[index++];
|
||
Priority = int.Parse(columnStrings[index++]);
|
||
Volume = float.Parse(columnStrings[index++]);
|
||
|
||
GeneratePropertyArray();
|
||
return true;
|
||
}
|
||
|
||
public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
|
||
{
|
||
using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))
|
||
{
|
||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||
{
|
||
m_Id = binaryReader.Read7BitEncodedInt32();
|
||
AssetName = binaryReader.ReadString();
|
||
Priority = binaryReader.Read7BitEncodedInt32();
|
||
Volume = binaryReader.ReadSingle();
|
||
}
|
||
}
|
||
|
||
GeneratePropertyArray();
|
||
return true;
|
||
}
|
||
|
||
private void GeneratePropertyArray()
|
||
{
|
||
|
||
}
|
||
}
|
||
}
|