//============================================================ // <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> //============================================================ private void pnlCanvas_MouseMove(object sender, MouseEventArgs e) { // 计算当前坐标 tspLabTxtLocation.Text = (e.X + _designer.Location.X) + "," + (e.Y + _designer.Location.Y); // 计算当前格子索引 int indexX = (e.X + _designer.Location.X) / (_mapLayer.Resource.CellSize.Width); int indexY = (e.Y + _designer.Location.Y) / (_mapLayer.Resource.CellSize.Height); tspTxtIndex.Text = indexX + "," + indexY; if (e.Button == MouseButtons.Left) { if (1 == lvwTile.SelectedItems.Count) { 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); _designer.Paint(); } } }
//============================================================ // <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(); } } }