//============================================================ // <T>鼠标落下事件处理。</T> //============================================================ private void pnlCanvas_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { FMbMapCell cell = _mapLayer.Find(e.X + _designer.Location.X, e.Y + _designer.Location.Y); if (null == cell) { return; } cell.ResourceId = 0; _designer.Paint(); } // 绘制图片 if (e.Button == MouseButtons.Left) { if (0 == tbcProperty.SelectedIndex) { // 获取选中图片资源编号 if (1 != lvwTile.SelectedItems.Count) { return; } ListViewItem lv = lvwTile.SelectedItems[0]; // 获取格子 FMbMapCell cell = _mapLayer.Find(e.X + _designer.Location.X, e.Y + _designer.Location.Y); cell.ResourceId = RInt.Parse(lv.Tag); } else { if (1 != lvwFly.SelectedItems.Count) { return; } ListViewItem lv = lvwFly.SelectedItems[0]; // 设置出生点 FMbMapBirth birth = new FMbMapBirth(); birth.Location = new SIntPoint2(e.X + _designer.Location.X, e.Y + _designer.Location.Y); // 设置敌机信息 FMbMapBirthEnemy enemy = new FMbMapBirthEnemy(); enemy.TemplateId = (lv.Tag as FMbTplEnemy).Id; birth.BirthEnemys.Add(enemy); _map.Resource.Births.Add(birth); } _designer.Paint(); } }
//============================================================ // <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); } } } }