本文整理汇总了C#中BinaryReader.ReadInt32方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryReader.ReadInt32方法的具体用法?C# BinaryReader.ReadInt32怎么用?C# BinaryReader.ReadInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryReader
的用法示例。
在下文中一共展示了BinaryReader.ReadInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: loadImage
void loadImage(string name)
{
using (BinaryReader b = new BinaryReader(File.Open(name, FileMode.Open,FileAccess.Read,FileShare.Read)))
{
// 2.
// Position and length variables.
int i = 0;
// Use BaseStream.
int length = (int)b.BaseStream.Length;
int w= b.ReadInt32(),h= b.ReadInt32(),format = b.ReadInt32();
texture = new Texture2D (w,h,TextureFormat.RFloat,false);
byte[] data = b.ReadBytes(w*h*format*4);
Debug.Log("Read Ima "+data.Length);
texture.LoadRawTextureData(data);
texture.Apply();
Debug.Log ("Channels "+texture.format);
ccc.callbackLoadImage(w,h);
}
GetComponent<Renderer> ().material.mainTexture = texture;
// GetComponent<Renderer> ().material.SetTexture (2, texture);
Debug.Log ("Channels "+texture.format);
}
示例2: Load
// 바이너리 로드
public void Load(TextAsset kTa_)
{
//FileStream fs = new FileStream("Assets\\Resources\\SkillDB.bytes", FileMode.Open);
//BinaryReader br = new BinaryReader(fs);
Stream kStream = new MemoryStream (kTa_.bytes);
BinaryReader br = new BinaryReader(kStream);
// *주의
// 바이너리 세이브 순서와 로드 순서가 같아야된다. [5/13/2012 JK]
// 바이너리 리드
int iCount = br.ReadInt32(); // 갯수 읽기
for (int i = 0; i < iCount; ++i)
{
StSkillInfo Info = new StSkillInfo();
Info.m_nSkillCode = br.ReadInt32(); // 스킬 고유 코드
Info.m_strName = br.ReadString(); // 스킬 이름
Info.m_fRange = br.ReadSingle(); // 스킬 적용 범위
Info.m_nDamage = br.ReadInt32(); // 스킬 데미지량
Info.m_nHeal = br.ReadInt32(); // 스킬 힐량
Info.m_fContinueTime = br.ReadSingle(); // 스킬 적용되는 시간
Info.m_strPrefab = br.ReadString(); // 스킬 사용시 사용할 Prefab
m_tmSkill.Add(Info.m_nSkillCode, Info);
}
//fs.Close();
br.Close();
kStream.Close();
}
示例3: Load
// 바이너리 로드
public void Load()
{
FileStream fs = new FileStream("StageDB.bin", FileMode.Open);
BinaryReader br = new BinaryReader(fs);
// *주의
// 바이너리 세이브 순서와 로드 순서가 같아야된다. [5/13/2012 JK]
// 바이너리 리드
int iCount = br.ReadInt32(); // 갯수 읽기
for (int i = 0; i < iCount; ++i)
{
CStateInfo kInfo = new CStateInfo();
kInfo.m_nStageIndex = br.ReadInt32(); // 캐릭터 코드
for (int k = 0; k < 4; ++k)
{
kInfo.m_anCharCode[k] = br.ReadInt32(); // 스테이지 별로 나오는 캐릭터
}
kInfo.m_fTermTime = br.ReadSingle();
m_tmStage.Add(kInfo.m_nStageIndex, kInfo);
}
fs.Close();
br.Close();
}
示例4: Load
// 바이너리 로드
public void Load()
{
FileStream fs = new FileStream("CharDB.bin", FileMode.Open);
BinaryReader br = new BinaryReader(fs);
// *주의
// 바이너리 세이브 순서와 로드 순서가 같아야된다. [5/13/2012 JK]
// 바이너리 리드
int iCount = br.ReadInt32(); // 갯수 읽기
for (int i = 0; i < iCount; ++i )
{
CCharInfo charInfo = new CCharInfo();
charInfo.m_nCode = br.ReadInt32(); // 캐릭터 코드
charInfo.m_strName = br.ReadString(); // 캐릭터 이름
charInfo.m_strPrefab = br.ReadString(); // Assets 안에 있는 Prefab 텍스트명
charInfo.m_nCharType = br.ReadInt32(); // 캐릭터 타입 0:플레이어 1:몬스터
charInfo.m_nNowHP = br.ReadInt32(); // 현재 체력
charInfo.m_nMaxHP = br.ReadInt32(); // 최대 체력
charInfo.m_nCharWidth = br.ReadInt32(); // 캐릭터 넓이
charInfo.m_fMoveSpeed = br.ReadSingle(); // 이동 속도(s) 목표지점까지 몇초만에 도착하는지
charInfo.m_nAttackDamage = br.ReadInt32(); // 공격 데미지
charInfo.m_nAttackRange = br.ReadInt32(); // 캐릭터 기본 사거리
charInfo.m_fAttackSpeed = br.ReadSingle(); // 캐릭터 공격 속도 1: 1초에 한번
charInfo.m_nExp = br.ReadInt32(); // 캐릭터가 죽었을시 제공되는 경험치
charInfo.m_fAfterAttackIdleTermTime = br.ReadSingle(); // 공격후 Idle 유지 시간
charInfo.m_nPay = br.ReadInt32(); // 보상(돈)
m_mapCharacter.Add(charInfo.m_nCode, charInfo);
}
fs.Close();
br.Close();
}
示例5: Load
public static void Load()
{
if (!File.Exists("Settings.dat"))
{
var a = Screen.resolutions[Screen.resolutions.Length - 1];
windowWidth = a.width;
windowHeight = a.height;
refreshRate = a.refreshRate;
Screen.SetResolution(windowWidth, windowHeight, true, refreshRate);
Save();
return;
}
BinaryReader br = new BinaryReader(new FileStream("Settings.dat", FileMode.Open));
try
{
windowWidth = br.ReadInt32();
windowHeight = br.ReadInt32();
refreshRate = br.ReadInt32();
isFullscreen = br.ReadBoolean();
Screen.SetResolution(windowWidth, windowHeight, isFullscreen, refreshRate);
highscore = br.ReadInt32();
}
catch { }
br.Close();
}
示例6: ReadBinary
public void ReadBinary(BinaryReader reader)
{
maxHealth = reader.ReadInt32();
maxMana = reader.ReadInt32();
str = reader.ReadInt32();
mag = reader.ReadInt32();
dex = reader.ReadInt32();
agi = reader.ReadInt32();
def = reader.ReadInt32();
weight = reader.ReadInt32();
moveRange = reader.ReadInt32();
moveSpeed = reader.ReadSingle();
lobRange = reader.ReadInt32();
string affStr = reader.ReadString();
affinity = (AFFINITY) Enum.Parse(typeof(AFFINITY), affStr, true);
soul = reader.ReadInt32();
float cr = reader.ReadSingle();
float cg = reader.ReadSingle();
float cb = reader.ReadSingle();
float ca = reader.ReadSingle();
soulColor = new Color(cr, cg, cb, ca);
}
示例7: Load
// 바이너리 로드
public void Load()
{
FileStream fs = new FileStream("SkillDB.bin", FileMode.Open);
BinaryReader br = new BinaryReader(fs);
// *주의
// 바이너리 세이브 순서와 로드 순서가 같아야된다. [5/13/2012 JK]
// 바이너리 리드
int iCount = br.ReadInt32(); // 갯수 읽기
for (int i = 0; i < iCount; ++i)
{
CSkillInfo Info = new CSkillInfo();
Info.m_nSkillCode = br.ReadInt32(); // 스킬 고유 코드
Info.m_strName = br.ReadString(); // 스킬 이름
Info.m_fRange = br.ReadSingle(); // 스킬 적용 범위
Info.m_nDamage = br.ReadInt32(); // 스킬 데미지량
Info.m_nHeal = br.ReadInt32(); // 스킬 힐량
Info.m_fContinueTime = br.ReadSingle(); // 스킬 적용되는 시간
Info.m_strPrefab = br.ReadString(); // 스킬 사용시 사용할 Prefab
m_tmSkill.Add(Info.m_nSkillCode, Info);
}
fs.Close();
br.Close();
}
示例8: Load
// 바이너리 로드
public void Load(TextAsset kTa_)
{
//FileStream fs = new FileStream("Assets\\Resources\\StageDB.bytes", FileMode.Open);
//BinaryReader br = new BinaryReader(fs);
Stream kStream = new MemoryStream (kTa_.bytes);
BinaryReader br = new BinaryReader(kStream);
// *주의
// 바이너리 세이브 순서와 로드 순서가 같아야된다. [5/13/2012 JK]
// 바이너리 리드
int iCount = br.ReadInt32(); // 갯수 읽기
for (int i = 0; i < iCount; ++i)
{
StStateInfo kInfo = new StStateInfo();
kInfo.m_nStageIndex = br.ReadInt32(); // 캐릭터 코드
// 스테이지 별로 나오는 캐릭터
kInfo.m_anCharCode = new int[(int)EStageDetail.Count];
for (int k = 0; k < (int)EStageDetail.Count; ++k)
{
kInfo.m_anCharCode[k] = br.ReadInt32();
}
kInfo.m_fTermTime = br.ReadSingle();
m_tmStage.Add(kInfo.m_nStageIndex, kInfo);
}
//fs.Close();
br.Close();
kStream.Close();
}
示例9: Parse
public static NetworkResponse Parse(MemoryStream dataStream)
{
ResponseConvergePriorAttempt response = new ResponseConvergePriorAttempt();
using (BinaryReader br = new BinaryReader(dataStream, Encoding.UTF8)) {
int playerId = br.ReadInt32 ();
int ecosystemId = br.ReadInt32 ();
int attemptId = br.ReadInt32 ();
bool allowHints = br.ReadBoolean ();
int hintId = br.ReadInt32 ();
short fldSize = br.ReadInt16 ();
String config = System.Text.Encoding.UTF8.GetString (br.ReadBytes (fldSize));
fldSize = br.ReadInt16 ();
String csv = System.Text.Encoding.UTF8.GetString (br.ReadBytes (fldSize));
ConvergeAttempt attempt = new ConvergeAttempt (playerId,
ecosystemId,
attemptId,
allowHints,
hintId,
config,
csv
//null
);
response.attempt = attempt;
}
return response;
}
示例10: GetFiles
public static ZipDirHeader[] GetFiles(BinaryReader br, Func<ZipDirHeader, bool> f)
{
var list = new List<ZipDirHeader>();
var fs = br.BaseStream;
if (fs.Length < 22)
throw new Exception("ファイルが小さ過ぎます。");
fs.Position = fs.Length - 22;
if (br.ReadInt32() != 0x06054b50)
throw new Exception("ヘッダが見付かりません。");
fs.Position += 6;
int count = br.ReadUInt16();
var dir_len = br.ReadUInt32();
var dir_start = br.ReadUInt32();
fs.Position = dir_start;
for (int i = 0; i < count; i++)
{
if (br.ReadInt32() != 0x02014b50)
throw new Exception("ファイルが壊れています。");
var zipdh = new ZipDirHeader(br);
if (f(zipdh)) list.Add(zipdh);
}
return list.ToArray();
}
示例11: Tbl_PetScript_Record
public Tbl_PetScript_Record(BinaryReader br)
{
m_GroupID = br.ReadInt32();
m_PersonName = br.ReadInt32();
int temp = 0;
for(int i=1; i<=AsTableManager.sPetScriptCount; ++i)
{
temp = br.ReadInt32(); if(temp != int.MaxValue) m_listLoginString.Add(temp);
}
for(int i=1; i<=AsTableManager.sPetScriptCount; ++i)
{
temp = br.ReadInt32(); if(temp != int.MaxValue) m_listEatString.Add(temp);
}
for(int i=1; i<=AsTableManager.sPetScriptCount; ++i)
{
temp = br.ReadInt32(); if(temp != int.MaxValue) m_listDeadString.Add(temp);
}
for(int i=1; i<=AsTableManager.sPetScriptCount; ++i)
{
temp = br.ReadInt32(); if(temp != int.MaxValue) m_listIdleString.Add(temp);
}
for(int i=1; i<=AsTableManager.sPetScriptCount; ++i)
{
temp = br.ReadInt32(); if(temp != int.MaxValue) m_listBattleString.Add(temp);
}
for(int i=1; i<=AsTableManager.sPetScriptCount; ++i)
{
temp = br.ReadInt32(); if(temp != int.MaxValue) m_listHungryString.Add(temp);
}
m_HungryPush = br.ReadInt32();
}
示例12: LoadGameSave
public static GameDataContainer LoadGameSave()
{
GameDataContainer data = new GameDataContainer ();
// Ensure that the file exists, else returns
if (!File.Exists ("Data/SaveGame.dat"))
return data;
using (BinaryReader br = new BinaryReader(File.OpenRead("Data/SaveGame.dat")))
{
br.ReadBytes(10); // Header
int moneyBytes = br.ReadInt32(); // sizeof (money)
data.Money = new BigInteger(Encoding.ASCII.GetString(br.ReadBytes(moneyBytes))); // money
// Loop for product data
for (int i = 0; i < (int)Products.Max; i++)
{
int level;
level = br.ReadInt32();
data.ProdList[i] = level;
}
int upgradeCount = br.ReadInt32();
for (int i = 0; i < upgradeCount; i++) {
int upId = br.ReadInt32();
data.AcquiredUpgrades.Add(upId);
}
}
return data;
}
示例13: GetBagType
//caller will use this to determine the right class and then
//construct it himself
public static Type GetBagType(string path)
{
BagType type;
Type bagClass = null;
FileStream idx;
string idxPath = path.Replace(".bag",".idx");
if (File.Exists(idxPath))
idx = File.Open(idxPath, FileMode.OpenOrCreate);
else
idx = File.Open(path, FileMode.OpenOrCreate);
BinaryReader rdr = new BinaryReader(idx);
type = (BagType) rdr.ReadInt32();
if (type == BagType.GABA)
type = (BagType) rdr.ReadInt32();
rdr.Close();
//only support GABA2 and VIDEO for now
switch (type)
{
//HACK: these can break if namespace or class names change, FIXME
case BagType.VIDEO:
bagClass = Type.GetType("NoxBagTool.VideoBag");
break;
case BagType.GABA2:
bagClass = Type.GetType("NoxBagTool.Gaba2Bag");
break;
}
return bagClass;
}
示例14: VoxelData
public VoxelData(string name, Material[] materials)
{
TextAsset asset = (TextAsset)Resources.Load("Meta/" + name);
MemoryStream ms = new MemoryStream(asset.bytes);
BinaryReader reader = new BinaryReader(ms);
x_size = reader.ReadUInt32();
z_size = reader.ReadUInt32();
y_size = reader.ReadUInt32();
x_offset = reader.ReadInt32();
z_offset = reader.ReadInt32();
y_offset = reader.ReadInt32();
data = reader.ReadBytes((int)(x_size * y_size * z_size));
byte[] raw_palette = reader.ReadBytes(256*3);
palette = new Material[256];
for (int i = 0; i < 256; i++) {
float r = raw_palette[i*3] / 255.0f;
float g = raw_palette[i*3+1] / 255.0f;
float b = raw_palette[i*3+2] / 255.0f;
Material result = null;
foreach (Material mat in materials) {
if (mat.color.r == r && mat.color.g == g && mat.color.b == b) {
result = mat;
break;
}
}
palette[i] = result;
}
}
示例15: Load
public void Load(BinaryReader Stream)
{
ID = Stream.ReadInt32();
Name = Stream.ReadStringNull();
int Length = Stream.ReadInt32();
Data = Stream.ReadInt32Array(Length);
}