Exemple #1
0
 //============================================================
 // <T>释放资源。</T>
 //============================================================
 public void Dispose()
 {
     if (_bitmap != null)
     {
         _bitmap.Dispose();
         _bitmap = null;
     }
 }
Exemple #2
0
 //============================================================
 // <T>释放资源。</T>
 //============================================================
 public void Dispose()
 {
     if (bitmap != null)
     {
         bitmap.Dispose();
         bitmap = null;
     }
 }
Exemple #3
0
        //============================================================
        // <T>创建位图。</T>
        //
        // @parma fileName 文件名称
        // @return 位图
        //============================================================
        public FDxBitmap CreateBitmap(string fileName)
        {
            FDxBitmap result = new FDxBitmap();

            result.Device = this;
            result.LoadFile(fileName);
            result.Setup();
            return(result);
        }
Exemple #4
0
        //============================================================
        // <T>创建位图。</T>
        //
        // @parma bitmap 位图
        // @return 位图
        //============================================================
        public FDxBitmap CreateBitmap(System.Drawing.Bitmap bitmap)
        {
            FDxBitmap result = new FDxBitmap();

            result.Device = this;
            result.LoadBitmap(bitmap);
            result.Setup();
            return(result);
        }
Exemple #5
0
        //============================================================
        // <T>绘制出生点。</T>
        //============================================================
        public void DrawBirths()
        {
            FObjects <FMbMapBirth> births = _map.Births;

            if (!births.IsEmpty())
            {
                int count = births.Count;
                for (int n = 0; n < count; n++)
                {
                    FMbMapBirth birth    = births[n];
                    SIntPoint2  location = birth.Location;
                    // 获取敌机集合
                    FObjects <FMbMapBirthEnemy> enemys = birth.BirthEnemys;
                    int enemyCount = enemys.Count;
                    for (int x = 0; x < enemyCount; x++)
                    {
                        FMbMapBirthEnemy birthEnemy = enemys[x];
                        int         templateId      = birthEnemy.TemplateId;
                        FMbTplEnemy enemy           = RMobileManager.TemplateConsole.EnemyConsole.FingById(templateId);
                        int         resourceRid     = enemy.ResourceRid;
                        // 获取资源图片
                        FRsResourcePicture resource    = RContent2dManager.ResourceConsole.FindOpen(resourceRid) as FRsResourcePicture;
                        Bitmap             resourceMap = resource.Bitmap.Native;
                        // 创建绘制对象
                        FDxBitmap bitmap = null;
                        if (!_dxBitmapSet.Contains(resourceRid.ToString()))
                        {
                            bitmap = _context.Device.CreateBitmap(resourceMap);
                            _dxBitmapSet.Set(resourceRid.ToString(), bitmap);
                        }
                        else
                        {
                            bitmap = _dxBitmapSet.Get(resourceRid.ToString());
                        }
                        _context.DrawBitmap(bitmap, location.X - _location.X, location.Y - _location.Y);
                    }
                }
            }
        }
Exemple #6
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);
        }
Exemple #7
0
        //============================================================
        // <T>绘制边界位图。</T>
        //
        // @param bitmap 位图
        // @param bitmapRectangle 位图范围
        // @param x 横坐标
        // @param y 纵坐标
        // @param width 宽度
        // @param height 高度
        // @param padding 空格
        //============================================================
        public void DrawBitmapPadding(FDxBitmap bitmap, SIntRectangle bitmapRectangle, int x, int y, int width, int height, SIntPadding padding, float scale = 1.0f)
        {
            // 计算缩放
            int paddingLeft   = padding.Left;
            int paddingTop    = padding.Top;
            int paddingRight  = padding.Right;
            int paddingBottom = padding.Bottom;

            width  -= x;
            height -= y;
            if (scale != 1.0f)
            {
                x             = (int)(x * scale);
                y             = (int)(y * scale);
                width         = (int)(width * scale);
                height        = (int)(height * scale);
                paddingLeft   = (int)(paddingLeft * scale);
                paddingTop    = (int)(paddingTop * scale);
                paddingRight  = (int)(paddingRight * scale);
                paddingBottom = (int)(paddingBottom * scale);
            }
            // 绘制对象
            int[] sxs = null;
            int[] sys = null;
            if (bitmapRectangle != null)
            {
                sxs = new int[4] {
                    bitmapRectangle.Left, bitmapRectangle.Left + paddingLeft, bitmapRectangle.Right - paddingRight, bitmapRectangle.Right
                };
                sys = new int[4] {
                    bitmapRectangle.Top, bitmapRectangle.Top + paddingTop, bitmapRectangle.Bottom - paddingBottom, bitmapRectangle.Bottom
                };
            }
            else
            {
                sxs = new int[4] {
                    0, paddingLeft, bitmap.Size.Width - paddingRight, bitmap.Size.Width
                };
                sys = new int[4] {
                    0, paddingTop, bitmap.Size.Height - paddingBottom, bitmap.Size.Height
                };
            }
            int[] dxs = new int[4] {
                0, paddingLeft, width - paddingRight, width
            };
            int[] dys = new int[4] {
                0, paddingTop, height - paddingBottom, height
            };
            for (int ny = 0; ny < 3; ny++)
            {
                for (int nx = 0; nx < 3; nx++)
                {
                    int n = 3 * ny + nx;
                    // 计算来源信息
                    int sx = sxs[nx];
                    int sw = sxs[nx + 1] - sx;
                    if (sw <= 0)
                    {
                        continue;
                    }
                    int sy = sys[ny];
                    int sh = sys[ny + 1] - sy;
                    if (sh <= 0)
                    {
                        continue;
                    }
                    // 计算目标信息
                    int dx = dxs[nx];
                    int dw = dxs[nx + 1] - dx;
                    if (dw <= 0)
                    {
                        continue;
                    }
                    int dy = dys[ny];
                    int dh = dys[ny + 1] - dy;
                    if (dh <= 0)
                    {
                        continue;
                    }
                    // 绘制图片
                    _target.DrawBitmap(bitmap.Native, new Rectangle(x + dx, y + dy, dw, dh), 1.0f, InterpolationMode.Linear, new Rectangle(sx, sy, sw, sh));
                }
            }
        }
Exemple #8
0
 //============================================================
 // <T>绘制边界位图。</T>
 //
 // @param bitmap 位图
 // @param x 横坐标
 // @param y 纵坐标
 // @param width 宽度
 // @param height 高度
 // @param padding 空格
 //============================================================
 public void DrawBitmapPadding(FDxBitmap bitmap, int x, int y, int width, int height, SIntPadding padding, float scale = 1.0f)
 {
     DrawBitmapPadding(bitmap, null, x, y, width, height, padding, scale);
 }
Exemple #9
0
 //============================================================
 // <T>绘制位图。</T>
 //
 // @param bitmap 位图
 // @param bitmapRectangle 位图范围
 // @param x 横坐标
 // @param y 纵坐标
 // @param width 横坐标
 // @param height 纵坐标
 // @param scale 缩放
 //============================================================
 public void DrawBitmap(FDxBitmap bitmap, SIntRectangle bitmapRectangle, int x, int y, int width, int height, float scale = 1.0f)
 {
     _target.DrawBitmap(bitmap.Native,
                        new Rectangle((int)(x * scale), (int)(y * scale), (int)(width * scale), (int)(height * scale)), 1.0f, InterpolationMode.NearestNeighbor,
                        new Rectangle(bitmapRectangle.Left, bitmapRectangle.Top, bitmapRectangle.Width, bitmapRectangle.Height));
 }
Exemple #10
0
 //============================================================
 // <T>绘制位图。</T>
 //
 // @param bitmap 位图
 // @param x 横坐标
 // @param y 纵坐标
 // @param width 横坐标
 // @param height 纵坐标
 //============================================================
 public void DrawBitmap(FDxBitmap bitmap, int x, int y, int width, int height)
 {
     _target.DrawBitmap(bitmap.Native, new Rectangle(x, y, width, height));
 }
Exemple #11
0
 //============================================================
 // <T>绘制位图。</T>
 //
 // @param bitmap 位图
 // @param x 横坐标
 // @param y 纵坐标
 //============================================================
 public void DrawBitmap(FDxBitmap bitmap, int x, int y)
 {
     _target.DrawBitmap(bitmap.Native, new Rectangle(x, y, bitmap.Size.Width, bitmap.Size.Height));
 }