Exemplo n.º 1
0
        //============================================================
        // <T>绘制层。</T>
        //============================================================
        public void DrawLayers()
        {
            FObjects <FMbMapLayer> layers = _map.Layers;

            if (!layers.IsEmpty())
            {
                int count = layers.Count;
                for (int n = 0; n < count; n++)
                {
                    FMbMapLayer layer = layers[n];
                    if (layer.OptionValid)
                    {
                        _cellSize  = layer.CellSize;
                        _cellCount = layer.CellCount;

                        FObjects <FMbMapCell> cells = layer.MapCell;
                        int cellCount = cells.Count;
                        for (int x = 0; x < cellCount; x++)
                        {
                            FMbMapCell cell       = cells[x];
                            int        resourceId = cell.ResourceId;
                            if (0 == resourceId)
                            {
                                continue;
                            }
                            SIntPoint2 cellIndex = cell.Index;

                            FMbMapTile mapTile = RMobileManager.MapTileConsole.FindMapTile(resourceId);
                            if (null != mapTile)
                            {
                                DrawMapTile(mapTile, cellIndex);
                            }
                        }
                    }
                    // 绘制方格
                    DrawLine();
                }
            }
        }
Exemplo n.º 2
0
        //============================================================
        // <T>绘制瓦片。</T>
        //============================================================
        public void DrawMapTile(FMbMapTile mapTile, SIntPoint2 cellIndex)
        {
            Bitmap bm         = mapTile.Resource;
            int    cellIndexX = cellIndex.X;
            int    cellIndexY = cellIndex.Y;

            int cellLocationX = cellIndexX * _cellSize.Width;
            int cellLocationY = cellIndexY * _cellSize.Height;

            FDxBitmap bitmap = null;

            // 创建图片资源
            if (!_dxBitmapSet.Contains(mapTile.Id.ToString()))
            {
                bitmap = _context.Device.CreateBitmap(mapTile.Resource);
                _dxBitmapSet.Set(mapTile.Id.ToString(), bitmap);
            }
            else
            {
                bitmap = _dxBitmapSet.Get(mapTile.Id.ToString());
            }
            _context.DrawBitmap(bitmap, cellLocationX - _location.X, cellLocationY - _location.Y);
        }