當前位置: 首頁>>代碼示例>>C#>>正文


C# Map.SetBounds方法代碼示例

本文整理匯總了C#中OpenRA.FileFormats.Map.SetBounds方法的典型用法代碼示例。如果您正苦於以下問題:C# Map.SetBounds方法的具體用法?C# Map.SetBounds怎麽用?C# Map.SetBounds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenRA.FileFormats.Map的用法示例。


在下文中一共展示了Map.SetBounds方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: 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();
			}
		}
開發者ID:Roger-luo,項目名稱:OpenRA,代碼行數:86,代碼來源:LegacyMapImporter.cs


注:本文中的OpenRA.FileFormats.Map.SetBounds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。