本文整理汇总了C#中IniFile.GetSection方法的典型用法代码示例。如果您正苦于以下问题:C# IniFile.GetSection方法的具体用法?C# IniFile.GetSection怎么用?C# IniFile.GetSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IniFile
的用法示例。
在下文中一共展示了IniFile.GetSection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FixTimestamps
/// <summary>
/// Sets the timestamps inside a UDK*.ini file's [IniVersion] section to match the file timestamps of the corresponding Default*.ini files and their base files.
/// Optionally this can be limited to files where the timestamp is off by exactly one hour to fix the timestamps for the current daylight saving time.
/// </summary>
/// <param name="daylightSavingCorrectionOnly">Only fix timestamps when they are off by exactly 1 hour due to daylight saving changes</param>
public void FixTimestamps(bool daylightSavingCorrectionOnly)
{
foreach (var udkIniFilePath in Directory.GetFiles(configFolder, "UDK*.ini"))
{
string defaultIniFilePath = Path.Combine(configFolder, "Default" + Path.GetFileName(udkIniFilePath).Substring(3));
if (!File.Exists(defaultIniFilePath))
continue;
var ini = new IniFile(udkIniFilePath);
var sec = ini.GetSection("IniVersion");
if (sec == null)
continue;
bool saveFile = true;
List<long> timestamps = new List<long>();
CollectDefaultIniTimestamps(defaultIniFilePath, timestamps);
for (int i = 0; i < timestamps.Count; i++)
{
var newTimestamp = timestamps[i];
if (daylightSavingCorrectionOnly)
{
var oldTimestamp = (long) sec.GetDecimal(i.ToString());
if (oldTimestamp != 0 && oldTimestamp != newTimestamp && Math.Abs(oldTimestamp - newTimestamp) != 3600)
{
saveFile = false;
break;
}
}
sec.Set(i.ToString(), newTimestamp.ToString());
}
if (saveFile)
ini.Save();
}
}
示例2: SetMapPlayers
public static void SetMapPlayers(string section, string faction, string color, IniFile file, List<string> players, MapPlayers mapPlayers)
{
var pr = new PlayerReference
{
Name = section,
OwnsWorld = section == "Neutral",
NonCombatant = section == "Neutral",
Faction = faction,
Color = namedColorMapping[color]
};
var neutral = new[] { "Neutral" };
foreach (var s in file.GetSection(section, true))
{
switch (s.Key)
{
case "Allies":
pr.Allies = s.Value.Split(',').Intersect(players).Except(neutral).ToArray();
pr.Enemies = s.Value.Split(',').SymmetricDifference(players).Except(neutral).ToArray();
break;
default:
Console.WriteLine("Ignoring unknown {0}={1} for player {2}", s.Key, s.Value, pr.Name);
break;
}
}
// Overwrite default player definitions if needed
if (!mapPlayers.Players.ContainsKey(section))
mapPlayers.Players.Add(section, pr);
else
mapPlayers.Players[section] = pr;
}
示例3: Map
public Map(string filename)
{
IniFile file = new IniFile(FileSystem.Open(filename));
IniSection basic = file.GetSection("Basic");
Title = basic.GetValue("Name", "(null)");
INIFormat = int.Parse(basic.GetValue("NewINIFormat", "0"));
IniSection map = file.GetSection("Map");
Theater = Truncate(map.GetValue("Theater", "TEMPERAT"), 8);
XOffset = int.Parse(map.GetValue("X", "0"));
YOffset = int.Parse(map.GetValue("Y", "0"));
Width = int.Parse(map.GetValue("Width", "0"));
Height = int.Parse(map.GetValue("Height", "0"));
MapSize = (INIFormat == 3) ? 128 : 64;
MapTiles = new TileReference[ MapSize, MapSize ];
for (int j = 0; j < MapSize; j++)
for (int i = 0; i < MapSize; i++)
MapTiles[i, j] = new TileReference();
if (INIFormat == 3) // RA map
{
UnpackRATileData(ReadPackedSection(file.GetSection("MapPack")));
UnpackRAOverlayData(ReadPackedSection(file.GetSection("OverlayPack")));
ReadRATrees(file);
}
else // CNC
{
UnpackCncTileData(FileSystem.Open(filename.Substring(0,filename.Length-4)+".bin"));
ReadCncOverlay(file);
ReadCncTrees(file);
}
LoadActors(file, "STRUCTURES");
LoadActors(file, "UNITS");
LoadActors(file, "INFANTRY");
SpawnPoints = file.GetSection("Waypoints")
.Where(kv => int.Parse(kv.Value) > 0)
.Select(kv => Pair.New(int.Parse(kv.Key), new int2(int.Parse(kv.Value) % MapSize, int.Parse(kv.Value) / MapSize)))
.Where(a => a.First < 8)
.Select(a => a.Second)
.ToArray();
}
示例4: IniFile
void IUtilityCommand.Run(Utility utility, string[] args)
{
// HACK: The engine code assumes that Game.modData is set.
Game.ModData = utility.ModData;
rulesIni = new IniFile(File.Open(args[1], FileMode.Open));
artIni = new IniFile(File.Open(args[2], FileMode.Open));
var buildings = rulesIni.GetSection("BuildingTypes").Select(b => b.Value).Distinct();
Console.WriteLine("# Buildings");
Console.WriteLine();
ImportStructures(buildings);
var terrainObjects = rulesIni.GetSection("TerrainTypes").Select(b => b.Value).Distinct();
Console.WriteLine("# Terrain Objects");
Console.WriteLine();
ImportStructures(terrainObjects, true);
}
示例5: cnc
enum IniMapFormat { RedAlert = 3 } // otherwise, cnc (2 variants exist, we don't care to differentiate)
public void ConvertIniMap(string iniFile)
{
using (var stream = GlobalFileSystem.Open(iniFile))
{
var file = new IniFile(stream);
var basic = file.GetSection("Basic");
var mapSection = file.GetSection("Map");
var legacyMapFormat = (IniMapFormat)Exts.ParseIntegerInvariant(basic.GetValue("NewINIFormat", "0"));
var offsetX = Exts.ParseIntegerInvariant(mapSection.GetValue("X", "0"));
var offsetY = Exts.ParseIntegerInvariant(mapSection.GetValue("Y", "0"));
var width = Exts.ParseIntegerInvariant(mapSection.GetValue("Width", "0"));
var height = Exts.ParseIntegerInvariant(mapSection.GetValue("Height", "0"));
mapSize = (legacyMapFormat == IniMapFormat.RedAlert) ? 128 : 64;
var tileset = Truncate(mapSection.GetValue("Theater", "TEMPERAT"), 8);
map = new Map(rules.TileSets[tileset], mapSize, mapSize)
{
Title = basic.GetValue("Name", Path.GetFileNameWithoutExtension(iniFile)),
Author = "Westwood Studios"
};
var tl = new PPos(offsetX, offsetY);
var br = new PPos(offsetX + width - 1, offsetY + height - 1);
map.SetBounds(tl, br);
if (legacyMapFormat == IniMapFormat.RedAlert)
{
UnpackRATileData(ReadPackedSection(file.GetSection("MapPack")));
UnpackRAOverlayData(ReadPackedSection(file.GetSection("OverlayPack")));
ReadRATrees(file);
}
else
{
// CnC
using (var s = GlobalFileSystem.Open(iniFile.Substring(0, iniFile.Length - 4) + ".bin"))
UnpackCncTileData(s);
ReadCncOverlay(file);
ReadCncTrees(file);
}
LoadVideos(file, "BASIC");
LoadActors(file, "STRUCTURES");
LoadActors(file, "UNITS");
LoadActors(file, "INFANTRY");
LoadActors(file, "SHIPS");
LoadSmudges(file, "SMUDGE");
var wps = file.GetSection("Waypoints")
.Where(kv => Exts.ParseIntegerInvariant(kv.Value) > 0)
.Select(kv => Pair.New(Exts.ParseIntegerInvariant(kv.Key),
LocationFromMapOffset(Exts.ParseIntegerInvariant(kv.Value), mapSize)));
// Add waypoint actors
foreach (var kv in wps)
{
if (kv.First <= 7)
{
var ar = new ActorReference("mpspawn")
{
new LocationInit((CPos)kv.Second),
new OwnerInit("Neutral")
};
map.ActorDefinitions.Add(new MiniYamlNode("Actor" + actorCount++, ar.Save()));
}
else
{
var ar = new ActorReference("waypoint")
{
new LocationInit((CPos)kv.Second),
new OwnerInit("Neutral")
};
map.ActorDefinitions.Add(new MiniYamlNode("waypoint" + kv.First, ar.Save()));
}
}
// Create default player definitions only if there are no players to import
mapPlayers = new MapPlayers(map.Rules, (players.Count == 0) ? map.SpawnPoints.Value.Length : 0);
foreach (var p in players)
LoadPlayer(file, p, legacyMapFormat == IniMapFormat.RedAlert);
map.PlayerDefinitions = mapPlayers.ToMiniYaml();
}
}
示例6: ReadPacks
public override void ReadPacks(IniFile file, string filename)
{
UnpackTileData(ReadPackedSection(file.GetSection("MapPack")));
UnpackOverlayData(ReadPackedSection(file.GetSection("OverlayPack")));
}
示例7: ReadIni
private void ReadIni(string iniFile)
{
if (String.IsNullOrEmpty(iniFile))
{
iniFile = "fnrouter.ini";
}
if (!File.Exists(iniFile)) return;
IniFile ini = new IniFile();
ini.Load(iniFile);
// Чтение настроек почты
MailSrv.MailSrv = ini.GetKeyValue("Mail", "MailSrv");
MailSrv.MailUser = ini.GetKeyValue("Mail", "MailUser");
MailSrv.MailPass = ini.GetKeyValue("Mail", "MailPass");
MailSrv.SetPort(ini.GetKeyValue("Mail", "MailPort"));
MailSrv.MailFrom = ini.GetKeyValue("Mail", "MailFrom");
MailToErrors = ini.GetKeyValue("Mail", "MailToErrors");
// Чтение переменных
IniFile.IniSection OptSect = ini.GetSection("Vars");
if (OptSect == null) return;
foreach (IniFile.IniSection.IniKey k in OptSect.Keys)
{
Options.Add(k.Name, k.Value);
}
ExpandOptions();
}
示例8: LoadPlayer
void LoadPlayer(IniFile file, string section, bool isRA)
{
string c;
string race;
switch (section)
{
case "Spain":
c = "gold";
race = "allies";
break;
case "England":
c = "green";
race = "allies";
break;
case "Ukraine":
c = "orange";
race = "soviet";
break;
case "Germany":
c = "black";
race = "allies";
break;
case "France":
c = "teal";
race = "allies";
break;
case "Turkey":
c = "salmon";
race = "allies";
break;
case "Greece":
case "GoodGuy":
c = isRA? "blue" : "gold";
race = isRA ? "allies" : "gdi";
break;
case "USSR":
case "BadGuy":
c = "red";
race = isRA ? "soviet" : "nod";
break;
case "Special":
case "Neutral":
default:
c = "neutral";
race = isRA ? "allies" : "gdi";
break;
}
var color = namedColorMapping[c];
var pr = new PlayerReference
{
Name = section,
OwnsWorld = section == "Neutral",
NonCombatant = section == "Neutral",
Race = race,
ColorRamp = new ColorRamp(
(byte)((color.First.GetHue() / 360.0f) * 255),
(byte)(color.First.GetSaturation() * 255),
(byte)(color.First.GetBrightness() * 255),
(byte)(color.Second.GetBrightness() * 255))
};
var neutral = new [] {"Neutral"};
foreach (var s in file.GetSection(section, true))
{
Console.WriteLine(s.Key);
switch(s.Key)
{
case "Credits":
pr.InitialCash = int.Parse(s.Value);
break;
case "Allies":
pr.Allies = s.Value.Split(',').Intersect(Players).Except(neutral).ToArray();
pr.Enemies = s.Value.Split(',').SymmetricDifference(Players).Except(neutral).ToArray();
break;
}
}
Map.Players.Add(section, pr);
}
示例9: ConvertIniMap
public void ConvertIniMap(string iniFile)
{
var file = new IniFile(FileSystem.Open(iniFile));
var basic = file.GetSection("Basic");
var map = file.GetSection("Map");
var legacyMapFormat = (IniMapFormat)int.Parse(basic.GetValue("NewINIFormat", "0"));
var XOffset = int.Parse(map.GetValue("X", "0"));
var YOffset = int.Parse(map.GetValue("Y", "0"));
var Width = int.Parse(map.GetValue("Width", "0"));
var Height = int.Parse(map.GetValue("Height", "0"));
MapSize = (legacyMapFormat == IniMapFormat.RedAlert) ? 128 : 64;
Map.Title = basic.GetValue("Name", "(null)");
Map.Author = "Westwood Studios";
Map.Tileset = Truncate(map.GetValue("Theater", "TEMPERAT"), 8);
Map.MapSize.X = MapSize;
Map.MapSize.Y = MapSize;
Map.Bounds = Rectangle.FromLTRB(XOffset, YOffset, XOffset + Width, YOffset + Height);
Map.Selectable = true;
Map.Smudges = Lazy.New(() => new List<SmudgeReference>());
Map.Actors = Lazy.New(() => new Dictionary<string, ActorReference>());
Map.MapResources = Lazy.New(() => new TileReference<byte, byte>[MapSize, MapSize]);
Map.MapTiles = Lazy.New(() => new TileReference<ushort, byte>[MapSize, MapSize]);
if (legacyMapFormat == IniMapFormat.RedAlert)
{
UnpackRATileData(ReadPackedSection(file.GetSection("MapPack")));
UnpackRAOverlayData(ReadPackedSection(file.GetSection("OverlayPack")));
ReadRATrees(file);
}
else // CNC
{
UnpackCncTileData(FileSystem.Open(iniFile.Substring(0, iniFile.Length - 4) + ".bin"));
ReadCncOverlay(file);
ReadCncTrees(file);
}
LoadActors(file, "STRUCTURES");
LoadActors(file, "UNITS");
LoadActors(file, "INFANTRY");
LoadSmudges(file, "SMUDGE");
foreach (var p in Players)
LoadPlayer(file, p, (legacyMapFormat == IniMapFormat.RedAlert));
var wps = file.GetSection("Waypoints")
.Where(kv => int.Parse(kv.Value) > 0)
.Select(kv => Pair.New(int.Parse(kv.Key),
LocationFromMapOffset(int.Parse(kv.Value), MapSize)))
.ToArray();
// Add waypoint actors
foreach( var kv in wps )
{
var a = new ActorReference("waypoint");
a.Add(new LocationInit((CPos)kv.Second));
a.Add(new OwnerInit("Neutral"));
Map.Actors.Value.Add("waypoint" + kv.First, a);
}
}
示例10: LoadPlayer
void LoadPlayer(IniFile file, string section, bool isRA)
{
string c;
string faction;
switch (section)
{
case "Spain":
c = "gold";
faction = "allies";
break;
case "England":
c = "green";
faction = "allies";
break;
case "Ukraine":
c = "orange";
faction = "soviet";
break;
case "Germany":
c = "black";
faction = "allies";
break;
case "France":
c = "teal";
faction = "allies";
break;
case "Turkey":
c = "salmon";
faction = "allies";
break;
case "Greece":
case "GoodGuy":
c = isRA ? "blue" : "gold";
faction = isRA ? "allies" : "gdi";
break;
case "USSR":
case "BadGuy":
c = "red";
faction = isRA ? "soviet" : "nod";
break;
case "Special":
case "Neutral":
default:
c = "neutral";
faction = isRA ? "allies" : "gdi";
break;
}
var pr = new PlayerReference
{
Name = section,
OwnsWorld = section == "Neutral",
NonCombatant = section == "Neutral",
Faction = faction,
Color = namedColorMapping[c]
};
var neutral = new[] { "Neutral" };
foreach (var s in file.GetSection(section, true))
{
switch (s.Key)
{
case "Allies":
pr.Allies = s.Value.Split(',').Intersect(players).Except(neutral).ToArray();
pr.Enemies = s.Value.Split(',').SymmetricDifference(players).Except(neutral).ToArray();
break;
default:
Console.WriteLine("Ignoring unknown {0}={1} for player {2}", s.Key, s.Value, pr.Name);
break;
}
}
// Overwrite default player definitions if needed
if (!mapPlayers.Players.ContainsKey(section))
mapPlayers.Players.Add(section, pr);
else
mapPlayers.Players[section] = pr;
}
示例11: LoadActors
void LoadActors(IniFile file, string section)
{
foreach (var s in file.GetSection(section, true))
{
// Structures: num=owner,type,health,location,turret-facing,trigger
// Units: num=owner,type,health,location,facing,action,trigger
// Infantry: num=owner,type,health,location,subcell,action,facing,trigger
try
{
var parts = s.Value.Split(',');
if (parts[0] == "")
parts[0] = "Neutral";
if (!players.Contains(parts[0]))
players.Add(parts[0]);
var loc = Exts.ParseIntegerInvariant(parts[3]);
var health = Exts.ParseIntegerInvariant(parts[2]) * 100 / 256;
var facing = (section == "INFANTRY") ? Exts.ParseIntegerInvariant(parts[6]) : Exts.ParseIntegerInvariant(parts[4]);
var actor = new ActorReference(parts[1].ToLowerInvariant())
{
new LocationInit(new CPos(loc % mapSize, loc / mapSize)),
new OwnerInit(parts[0]),
};
var initDict = actor.InitDict;
if (health != 100)
initDict.Add(new HealthInit(health));
if (facing != 0)
initDict.Add(new FacingInit(facing));
if (section == "INFANTRY")
actor.Add(new SubCellInit(Exts.ParseIntegerInvariant(parts[4])));
if (!rules.Actors.ContainsKey(parts[1].ToLowerInvariant()))
errorHandler("Ignoring unknown actor type: `{0}`".F(parts[1].ToLowerInvariant()));
else
map.ActorDefinitions.Add(new MiniYamlNode("Actor" + actorCount++, actor.Save()));
}
catch (Exception)
{
errorHandler("Malformed actor definition: `{0}`".F(s));
}
}
}
示例12: ReadRATrees
void ReadRATrees(IniFile file)
{
var terrain = file.GetSection("TERRAIN", true);
if (terrain == null)
return;
foreach (var kv in terrain)
{
var loc = Exts.ParseIntegerInvariant(kv.Key);
map.Actors.Value.Add("Actor" + actorCount++,
new ActorReference(kv.Value.ToLowerInvariant())
{
new LocationInit(new CPos(loc % mapSize, loc / mapSize)),
new OwnerInit("Neutral")
});
}
}
示例13: ConvertIniMap
public void ConvertIniMap(string iniFile)
{
var file = new IniFile(GlobalFileSystem.Open(iniFile));
var basic = file.GetSection("Basic");
var mapSection = file.GetSection("Map");
var legacyMapFormat = (IniMapFormat)Exts.ParseIntegerInvariant(basic.GetValue("NewINIFormat", "0"));
var offsetX = Exts.ParseIntegerInvariant(mapSection.GetValue("X", "0"));
var offsetY = Exts.ParseIntegerInvariant(mapSection.GetValue("Y", "0"));
var width = Exts.ParseIntegerInvariant(mapSection.GetValue("Width", "0"));
var height = Exts.ParseIntegerInvariant(mapSection.GetValue("Height", "0"));
mapSize = (legacyMapFormat == IniMapFormat.RedAlert) ? 128 : 64;
var size = new Size(mapSize, mapSize);
var tileset = Truncate(mapSection.GetValue("Theater", "TEMPERAT"), 8);
map = Map.FromTileset(rules.TileSets[tileset]);
map.Title = basic.GetValue("Name", Path.GetFileNameWithoutExtension(iniFile));
map.Author = "Westwood Studios";
map.MapSize.X = mapSize;
map.MapSize.Y = mapSize;
map.Bounds = Rectangle.FromLTRB(offsetX, offsetY, offsetX + width, offsetY + height);
map.Selectable = true;
map.Smudges = Exts.Lazy(() => new List<SmudgeReference>());
map.Actors = Exts.Lazy(() => new Dictionary<string, ActorReference>());
map.MapResources = Exts.Lazy(() => new CellLayer<ResourceTile>(TileShape.Rectangle, size));
map.MapTiles = Exts.Lazy(() => new CellLayer<TerrainTile>(TileShape.Rectangle, size));
map.Options = new MapOptions();
if (legacyMapFormat == IniMapFormat.RedAlert)
{
UnpackRATileData(ReadPackedSection(file.GetSection("MapPack")));
UnpackRAOverlayData(ReadPackedSection(file.GetSection("OverlayPack")));
ReadRATrees(file);
}
else
{
// CnC
using (var s = GlobalFileSystem.Open(iniFile.Substring(0, iniFile.Length - 4) + ".bin"))
UnpackCncTileData(s);
ReadCncOverlay(file);
ReadCncTrees(file);
}
LoadActors(file, "STRUCTURES");
LoadActors(file, "UNITS");
LoadActors(file, "INFANTRY");
LoadSmudges(file, "SMUDGE");
foreach (var p in players)
LoadPlayer(file, p, legacyMapFormat == IniMapFormat.RedAlert);
var wps = file.GetSection("Waypoints")
.Where(kv => Exts.ParseIntegerInvariant(kv.Value) > 0)
.Select(kv => Pair.New(Exts.ParseIntegerInvariant(kv.Key),
LocationFromMapOffset(Exts.ParseIntegerInvariant(kv.Value), mapSize)))
.ToArray();
// Add waypoint actors
foreach (var kv in wps)
{
if (kv.First <= 7)
{
var a = new ActorReference("mpspawn");
a.Add(new LocationInit((CPos)kv.Second));
a.Add(new OwnerInit("Neutral"));
map.Actors.Value.Add("Actor" + map.Actors.Value.Count.ToString(), a);
}
else
{
var a = new ActorReference("waypoint");
a.Add(new LocationInit((CPos)kv.Second));
a.Add(new OwnerInit("Neutral"));
map.Actors.Value.Add("waypoint" + kv.First, a);
}
}
}
示例14: Run
public void Run(ModData modData, string[] args)
{
// HACK: The engine code assumes that Game.modData is set.
Game.ModData = modData;
GlobalFileSystem.LoadFromManifest(Game.ModData.Manifest);
var file = new IniFile(File.Open(args[1], FileMode.Open));
var extension = args[2];
var templateIndex = 0;
var terrainTypes = new string[]
{
"Clear",
"Clear", // Note: sometimes "Ice"
"Ice",
"Ice",
"Ice",
"Road", // TS defines this as "Tunnel", but we don't need this
"Rail",
"Impassable", // TS defines this as "Rock", but also uses it for buildings
"Impassable",
"Water",
"Water", // TS defines this as "Beach", but uses it for water...?
"Road",
"DirtRoad", // TS defines this as "Road", but we may want different speeds
"Clear",
"Rough",
"Cliff" // TS defines this as "Rock"
};
// Loop over template sets
try
{
for (var tilesetGroupIndex = 0;; tilesetGroupIndex++)
{
var section = file.GetSection("TileSet{0:D4}".F(tilesetGroupIndex));
var sectionCount = int.Parse(section.GetValue("TilesInSet", "1"));
var sectionFilename = section.GetValue("FileName", "");
var sectionCategory = section.GetValue("SetName", "");
// Loop over templates
for (var i = 1; i <= sectionCount; i++, templateIndex++)
{
var templateFilename = "{0}{1:D2}.{2}".F(sectionFilename, i, extension);
if (!GlobalFileSystem.Exists(templateFilename))
continue;
using (var s = GlobalFileSystem.Open(templateFilename))
{
Console.WriteLine("\[email protected]{0}:", templateIndex);
Console.WriteLine("\t\tCategory: {0}", sectionCategory);
Console.WriteLine("\t\tId: {0}", templateIndex);
var images = new List<string>();
images.Add("{0}{1:D2}.{2}".F(sectionFilename, i, extension));
for (var v = 'a'; v <= 'z'; v++)
{
var variant = "{0}{1:D2}{2}.{3}".F(sectionFilename, i, v, extension);
if (GlobalFileSystem.Exists(variant))
images.Add(variant);
}
Console.WriteLine("\t\tImage: {0}", images.JoinWith(", "));
var templateWidth = s.ReadUInt32();
var templateHeight = s.ReadUInt32();
/* var tileWidth = */s.ReadInt32();
/* var tileHeight = */s.ReadInt32();
var offsets = new uint[templateWidth * templateHeight];
for (var j = 0; j < offsets.Length; j++)
offsets[j] = s.ReadUInt32();
Console.WriteLine("\t\tSize: {0}, {1}", templateWidth, templateHeight);
Console.WriteLine("\t\tTiles:");
for (var j = 0; j < offsets.Length; j++)
{
if (offsets[j] == 0)
continue;
s.Position = offsets[j] + 40;
var height = s.ReadUInt8();
var terrainType = s.ReadUInt8();
var rampType = s.ReadUInt8();
if (terrainType >= terrainTypes.Length)
throw new InvalidDataException("Unknown terrain type {0} in {1}".F(terrainType, templateFilename));
Console.WriteLine("\t\t\t{0}: {1}", j, terrainTypes[terrainType]);
if (height != 0)
Console.WriteLine("\t\t\t\tHeight: {0}", height);
if (rampType != 0)
Console.WriteLine("\t\t\t\tRampType: {0}", rampType);
Console.WriteLine("\t\t\t\tLeftColor: {0},{1},{2}", s.ReadUInt8(), s.ReadUInt8(), s.ReadUInt8());
//.........这里部分代码省略.........
示例15: ReadCncOverlay
void ReadCncOverlay(IniFile file)
{
var overlay = file.GetSection("OVERLAY", true);
if (overlay == null)
return;
foreach (var kv in overlay)
{
var loc = Exts.ParseIntegerInvariant(kv.Key);
var cell = new CPos(loc % mapSize, loc / mapSize);
var res = Pair.New((byte)0, (byte)0);
if (overlayResourceMapping.ContainsKey(kv.Value.ToLower()))
res = overlayResourceMapping[kv.Value.ToLower()];
map.MapResources.Value[cell] = new ResourceTile(res.First, res.Second);
if (overlayActorMapping.ContainsKey(kv.Value.ToLower()))
{
var ar = new ActorReference(overlayActorMapping[kv.Value.ToLower()])
{
new LocationInit(cell),
new OwnerInit("Neutral")
};
map.ActorDefinitions.Add(new MiniYamlNode("Actor" + actorCount++, ar.Save()));
}
}
}