本文整理汇总了C#中System.Platform.GetOffsets方法的典型用法代码示例。如果您正苦于以下问题:C# Platform.GetOffsets方法的具体用法?C# Platform.GetOffsets怎么用?C# Platform.GetOffsets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Platform
的用法示例。
在下文中一共展示了Platform.GetOffsets方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateSoundBank
public static string GenerateSoundBank(string soundbankName, Stream audioStream, Stream outStream, float volume, Platform platform)
{
string eventName = PLAY + soundbankName;
string previewName = PLAY30SEC + soundbankName;
string bankName = SONG + soundbankName;
var id = RandomGenerator.NextInt();
byte[] soundbank = null;
switch (platform.version)
{
case GameVersion.RS2012:
switch (platform.platform)
{
case GamePlatform.Pc:
soundbank = Resources.PC_soundbank;
break;
case GamePlatform.XBox360:
case GamePlatform.PS3:
soundbank = Resources.Console_soundbank;
break;
default:
throw new InvalidOperationException("Unexpected game platform value");
}
break;
default:
throw new InvalidOperationException("Unexpected game version value");
}
var bitConverter = platform.GetBitConverter;
using (var bankStream = new MemoryStream(soundbank))
using (var bankReader = new EndianBinaryReader(bitConverter, bankStream))
{
var audioReader = new EndianBinaryReader(bitConverter, audioStream);
var bankWriter = new EndianBinaryWriter(bitConverter, outStream);
bankWriter.Write(bankReader.ReadBytes(platform.GetOffsets()[0]));
bankReader.ReadInt32();
bankWriter.Write(id);
bankWriter.Write(bankReader.ReadInt32());
int dataSize = bankReader.ReadInt32();
bankWriter.Write(dataSize);
bankWriter.Write(bankReader.ReadInt32());
bankWriter.Write(bankReader.ReadInt32());
bankWriter.Write(audioReader.ReadBytes(dataSize));
bankReader.BaseStream.Seek(dataSize, SeekOrigin.Current);
bankWriter.Write(bankReader.ReadBytes(platform.GetOffsets()[1]));
bankWriter.Write(id);
bankWriter.Write(id);
bankReader.BaseStream.Seek(8, SeekOrigin.Current);
bankWriter.Write(bankReader.ReadBytes(platform.GetOffsets()[2]));
bankWriter.Write((float)volume);
bankReader.ReadInt32();
bankWriter.Write(bankReader.ReadBytes(platform.GetOffsets()[3]));
bankReader.ReadInt32();
bankWriter.Write(HashString(eventName));
bankWriter.Write(bankReader.ReadBytes(platform.GetOffsets()[4]));
bankReader.ReadInt32();
bankWriter.Write(HashString(previewName));
bankWriter.Write(bankReader.ReadBytes(platform.GetOffsets()[5]));
bankWriter.Write(12 + bankName.Length + 1);
bankReader.ReadInt32();
bankWriter.Write(bankReader.ReadBytes(platform.GetOffsets()[6]));
bankWriter.Write((byte)bankName.Length);
bankWriter.Write(Encoding.ASCII.GetBytes(bankName));
bankWriter.Flush();
}
return id.ToString();
}