private void pic_MouseMove(object sender, MouseEventArgs e) { map.ListCell.ForEach(cell => cell.Selected = false); prevSelectedCell = selectedCell; selectedCell = map.GetNearestCell(e.Location, 10); if (selectedCell != null) selectedCell.Selected = true; if (prevSelectedCell != selectedCell && selectedCell != null) { PropagateWave(); } }
private void CreateCellsHex() { ListCell = new List<Cell>(); float d = (float)Math.Sqrt(0.75); float r = 6; int maxX = (int)((float)_width / r); int maxY = (int)((float)_height / r); int nb = 0; for (int y = 0; y < maxY; y++) { for (int x = 0; x < maxX; x++) { float fx = (float)x; float fy = (float)y; Cell cell1 = new Cell( (int)((1 + fx * 3) * r), (int)((0.5f + fy) * (2 * d * r))); //if (y == 0 || y == maxY - 1 || x == 0) // cell1.IsBorder = true; //cell1.Coordinate = new Point(x, y); ListCell.Add(cell1); Cell cell2 = new Cell( (int)((2.5f + fx * 3) * r), (int)((fy) * (2 * d * r))); //if (y == 0 || y == maxY - 1 || x == maxX - 1) // cell2.IsBorder = true; //cell2.Coordinate = new Point(x, y); ListCell.Add(cell2); } } }
private void CreateCells() { ListCell = new List<Cell>(); if (_typeCellDistribution == TypeCellDistribution.Random) { for (int i = 0; i < _countCell; i++) { Cell cell = new Cell(_rnd.Next(_width), _rnd.Next(_height)); ListCell.Add(cell); } } else if (_typeCellDistribution == TypeCellDistribution.Square) { } else if (_typeCellDistribution == TypeCellDistribution.Hexagon) { CreateCellsHex(); } }