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


C# ModelObject.Load方法代码示例

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


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

示例1: Load

        public bool Load(Stream rsw, Map owner)
        {
            BinaryReader br = new BinaryReader(rsw);
            string header = ((char)br.ReadByte()).ToString() + ((char)br.ReadByte()) + ((char)br.ReadByte()) + ((char)br.ReadByte());

            if (header != "GRSW")
                return false;

            majorVersion = br.ReadByte();
            minorVersion = br.ReadByte();

            if (!(majorVersion == 1 && minorVersion >= 2 && minorVersion <= 9) &&
                !(majorVersion == 2 && minorVersion <= 2))
                return false;

            _iniFile = br.ReadCString(40);
            _groundFile = br.ReadCString(40);
            _altitudeFile = br.ReadCString(40);
            _scrFile = br.ReadCString(40);

            _waterInfo.Load(br, majorVersion, minorVersion);
            _lightInfo.Load(br, majorVersion, minorVersion);
            _groundInfo.Load(br, majorVersion, minorVersion);

            _models = new List<ModelObject>();

            Logger.TabLevel++;

            int count = br.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                int type = br.ReadInt32();
                int skipSize = 0;

                if (type == 1)
                {
                    ModelObject mo = new ModelObject();

                    mo.Load(br, majorVersion, minorVersion, owner.Ground);

                    Vector3 tmp = mo.Position;
                    tmp.X = (mo.Position.X / 5) + owner.Ground.Width;
                    tmp.Z = (mo.Position.Z / 5) + owner.Ground.Height;
                    mo.Position = tmp;

                    _models.Add(mo);
                }
                else if (type == 2)
                {
                    skipSize = 80 + sizeof(float) * 3 + sizeof(int) + sizeof(int) + sizeof(int) + sizeof(float);
                }
                else if (type == 3)
                {
                    skipSize = 80 + 80 + sizeof(float) * 3 + sizeof(float) + sizeof(int) + sizeof(int) + sizeof(float);

                    if (majorVersion >= 2)
                        skipSize += sizeof(float);
                }
                else if (type == 4)
                {
                    skipSize = 80 + sizeof(float) * 3 + sizeof(int) + sizeof(float) + sizeof(float) * 4;
                }

                if (skipSize > 0)
                    br.ReadBytes(skipSize);
            }

            Logger.TabLevel--;

            Logger.WriteLine("Loading water type {0} textures...", _waterInfo.Type);
            SetupWater(_waterInfo.Type);

            Logger.WriteLine("Creating water vertex buffer...");
            UpdateWaterVertices(owner);

            Logger.WriteLine("World v{0}.{1} status: {2} objects - {3} models", majorVersion, minorVersion, count, _models.Count);
            Logger.WriteLine("    Water height: {0}", _waterInfo.Level);
            Logger.WriteLine("    Water type: {0}", _waterInfo.Type);

            return true;
        }
开发者ID:GodLesZ,项目名称:FimbulwinterClient,代码行数:81,代码来源:World.cs


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