本文整理汇总了C#中HaloMap.Map.Map.LoadMap方法的典型用法代码示例。如果您正苦于以下问题:C# Map.LoadMap方法的具体用法?C# Map.LoadMap怎么用?C# Map.LoadMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HaloMap.Map.Map
的用法示例。
在下文中一共展示了Map.LoadMap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadFromFile
/// <summary>
/// Loads a .map file and returns it as
/// a map object
/// </summary>
/// <param name="fileName">The file Name.</param>
/// <returns></returns>
/// <remarks></remarks>
public static Map LoadFromFile(string fileName)
{
// create the map object and give it the map filename
Map map = new Map(fileName);
// open the map
map.OpenMap(MapTypes.Internal);
// if the open failed, nothing we can do further
if (!map.isOpen)
{
return null;
}
// Get map version, (what halo this is)
map.BR.BaseStream.Position = 4;
int version = map.BR.ReadInt32();
// set the halo game type in the map object
switch (version)
{
case 609:
map.HaloVersion = HaloVersionEnum.HaloCE;
break;
case 8:
map.HaloVersion = HaloVersionEnum.Halo2;
map.BR.BaseStream.Position = 0x24;
switch (map.BR.ReadInt32())
{
case -1:
map.HaloVersion = HaloVersionEnum.Halo2Vista;
break;
case 0:
map.HaloVersion = HaloVersionEnum.Halo2;
break;
}
break;
case 5:
map.HaloVersion = HaloVersionEnum.Halo1;
break;
// if we dont support the map, dont open it
default:
MessageBox.Show("This is not a supported map type.");
map.CloseMap();
return null;
}
// read from the map
map.LoadMap();
// close file and return map obj
map.CloseMap();
return map;
}