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


C# Map.GetMapChunk方法代碼示例

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


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

示例1: OnClick

 void OnClick()
 {
     Directory.CreateDirectory("Chunks");
     IsometricLighting lighting = new IsometricLighting();
     MouseOverList mouseOverNull = new MouseOverList(new MousePicking());
     SpriteBatch3D spritebatch = Service.Get<SpriteBatch3D>();
     RenderTarget2D render = new RenderTarget2D(spritebatch.GraphicsDevice, Width + WidthExtra * 2, Height + HeightExtra * 2 + HeightExtra2);
     Map map = new Map(0);
     for (int chunky = 0; chunky < 10; chunky++)
     {
         for (int chunkx = 0; chunkx < 10; chunkx++)
         {
             spritebatch.GraphicsDevice.SetRenderTarget(render);
             spritebatch.Reset();
             uint cx = (uint)chunkx + 200;
             uint cy = (uint)chunky + 200;
             map.CenterPosition = new Point((int)(cx << 3), (int)(cy << 3));
             MapChunk chunk = map.GetMapChunk(cx, cy);
             chunk.LoadStatics(map.MapData, map);
             int z = 0;
             for (int i = 0; i < 64; i++)
             {
                 int y = (i / 8);
                 int x = (i % 8);
                 int sy = y * 22 + x * 22 + HeightExtra + HeightExtra2;
                 int sx = 22 * 8 - y * 22 + x * 22 + WidthExtra;
                 MapTile tile = chunk.Tiles[i];
                 tile.ForceSort();
                 for (int j = 0; j < tile.Entities.Count; j++)
                 {
                     AEntity e = tile.Entities[j];
                     AEntityView view = e.GetView();
                     view.Draw(spritebatch, new Vector3(sx, sy, 0), mouseOverNull, map, false);
                 }
             }
             spritebatch.SetLightIntensity(lighting.IsometricLightLevel);
             spritebatch.SetLightDirection(lighting.IsometricLightDirection);
             spritebatch.GraphicsDevice.Clear(Color.Transparent);
             spritebatch.FlushSprites(true);
             spritebatch.GraphicsDevice.SetRenderTarget(null);
             render.SaveAsPng(new FileStream($"Chunks/{cy}-{cx}.png", FileMode.Create), render.Width, render.Height);
         }
     }
 }
開發者ID:jorsi,項目名稱:UltimaXNA,代碼行數:44,代碼來源:MapRendererModule.cs

示例2: InternalQueueMapBlock

        private void InternalQueueMapBlock(Map map, uint cellx, uint celly)
        {
            uint chunkIndex = (cellx % BlockCacheWidth) + (celly % BlockCacheHeight) * BlockCacheWidth;

            MiniMapChunk chunk = m_BlockCache[chunkIndex];
            if (chunk == null || chunk.X != cellx || chunk.Y != celly)
            {
                // the chunk is not in our cache! Try loading it from the map?
                MapChunk mapBlock = map.GetMapChunk(cellx, celly);
                if (mapBlock == null)
                {
                    // if the chunk is not loaded in memory, load it from the filesystem.
                    m_BlockCache[chunkIndex] = new MiniMapChunk(cellx, celly, map.MapData);
                }
                else
                {
                    // get the colors for this chunk from the map chunk, which will have already sorted the objects.
                    m_BlockCache[chunkIndex] = new MiniMapChunk(mapBlock);
                }
            }
            else
            {
                m_BlockColors = chunk.Colors;
            }

            m_QueuedToDrawBlocks.Add(chunkIndex);
        }
開發者ID:jorsi,項目名稱:UltimaXNA,代碼行數:27,代碼來源:MiniMapTexture.cs


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