当前位置: 首页>>代码示例>>C#>>正文


C# Layer.Load方法代码示例

本文整理汇总了C#中Layer.Load方法的典型用法代码示例。如果您正苦于以下问题:C# Layer.Load方法的具体用法?C# Layer.Load怎么用?C# Layer.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Layer的用法示例。


在下文中一共展示了Layer.Load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load

    public bool Load(string Filename)
    {
        if (string.IsNullOrEmpty(Filename))
            return false;
        if (!System.IO.File.Exists(Filename))
            return false;

        this.Filename = Filename;

        Clear();

        System.IO.FileStream fs = new System.IO.FileStream(Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
        BinaryReader Stream = new BinaryReader(fs);

		TexturemapTex = new Texture2D(0,0);
		TexturemapTex2 = new Texture2D(0,0);
		NormalmapTex = new Texture2D(0,0);
		WatermapTex = new Texture2D(0,0);
		PreviewTex = new Texture2D(0,0);

        byte[] PreviewData = new byte[0];
        byte[] TexturemapData = new byte[0];
        byte[] TexturemapData2 = new byte[0];
        byte[] NormalmapData = new byte[0];
        byte[] WatermapData = new byte[0];
        int Count = 0;

        BinaryReader _with1 = Stream;
        //# Header Section #
        if (_with1.ReadInt32() == MAP_MAGIC)
        {
            VersionMajor = _with1.ReadInt32();
            //? always 2
            Unknown10 = _with1.ReadInt32();
            //? always EDFE EFBE
            Unknown11 = _with1.ReadInt32();
            //? always 2
            _with1.ReadSingle();
            //Map Width (in float)
            _with1.ReadSingle();
            //Map Height (in float)
            Unknown12 = _with1.ReadInt32();
            //? always 0
            Unknown13 = _with1.ReadInt16();
            //? always 0
            int ImageLength = _with1.ReadInt32();
            PreviewData = _with1.ReadBytes(ImageLength);

            VersionMinor = _with1.ReadInt32();
            if (VersionMinor <= 0)
                VersionMinor = 56;

            if (VersionMinor > 56)
            {
                Console.WriteLine("This map uses SCMAP file version" + VersionMinor + " which is not yet supported by this editor. I will try to load it with the newest known version (" + 56 + "), but it is very likely to fail or cause errors.");
            }

            //# Heightmap Section #
            Width = _with1.ReadInt32();
            Height = _with1.ReadInt32();

            HeightScale = _with1.ReadSingle();
            //Height Scale, usually 1/128
            HeightmapData = _with1.ReadInt16Array((Height + 1) * (Width + 1));//TODO: Current saving method gets a memory overload on trying to reload the map here.
            //heightmap dimension is always 1 more than texture dimension!

            if (VersionMinor >= 56)
                _with1.ReadByte();
            //Always 0?

            //# Texture Definition Section #
            TerrainShader = _with1.ReadStringNull();
            //Terrain Shader, usually "TTerrain"
            TexPathBackground = _with1.ReadStringNull();
            TexPathSkyCubemap = _with1.ReadStringNull();

            if (VersionMinor >= 56)
            {
                Count = _with1.ReadInt32();
                //always 1?
                EnvCubemapsName = new string[Count];
                EnvCubemapsFile = new string[Count];
                for (int i = 0; i <= Count - 1; i++)
                {
                    EnvCubemapsName[i] = _with1.ReadStringNull();
                    EnvCubemapsFile[i] = _with1.ReadStringNull();
                }
            }
            else
            {
                EnvCubemapsName = new string[2];
                EnvCubemapsName[0] = "<default>";
                EnvCubemapsFile = new string[2];
                EnvCubemapsFile[0] = _with1.ReadStringNull();
            }

            LightingMultiplier = _with1.ReadSingle();
            SunDirection = _with1.ReadVector3();
            SunAmbience = _with1.ReadVector3();
            SunColor = _with1.ReadVector3();
//.........这里部分代码省略.........
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:101,代码来源:Map.cs


注:本文中的Layer.Load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。