Beispiel #1
0
        public static void SelectTile(int xPos, int yPos, TileTab tab, int clicks)
        {
            var ti            = TileHandler.GetTileImage(tab);
            var tileSize      = ti.TileSize;
            int originalIndex = TileHandler.GetTileIndex(xPos, yPos, tab);
            int index         = ti.ColumnsPerRow * yPos + xPos;

            if (xPos >= ti.Image.Width / tileSize || yPos >= ti.Image.Height / tileSize)
            {
                return;
            }

            if (clicks == 1)
            {
                if (SelectedTiles.Contains(index))
                {
                    SelectedTiles.Remove(index);
                }
                else
                {
                    SelectedTiles.Add(index);
                }
            }
            else
            {
                switch (tab)
                {
                case TileTab.Source: { TileHandler.SelectedTile = originalIndex; break; }

                case TileTab.Randomized: { TileHandler.SelectedTile = RandomizedMap[xPos, yPos]; break; }

                case TileTab.RuleTest: { TileHandler.SelectedTile = RuleTestMap[xPos, yPos]; break; }
                }
            }
        }
Beispiel #2
0
        private void pctbMain_MouseMove(object sender, MouseEventArgs e)
        {
            var pctb   = _PictureBoxes[tbcMain.SelectedIndex];
            var grid   = (TileTab)tbcMain.SelectedIndex == TileTab.Randomized ? TileHandler.RandomizedMap : TileHandler.RuleTestMap;
            var xStart = pctb.Image.Width / 2 - TileHandler.GetWidth((TileTab)tbcMain.SelectedIndex) / 2;
            var yStart = pctb.Image.Height / 2 - TileHandler.GetHeight((TileTab)tbcMain.SelectedIndex) / 2;
            int xPos   = (e.X - xStart) / TileHandler.TileSize;
            int yPos   = (e.Y - yStart) / TileHandler.TileSize;

            if (tbcMain.SelectedIndex != 0 && (xPos >= grid.GetLength(0) || yPos >= grid.GetLength(1)))
            {
                return;
            }

            if (tbcMain.SelectedIndex == 0)
            {
                stlblTileId.Text = (TileHandler.GetTileIndex(xPos, yPos, (TileTab)tbcMain.SelectedIndex)).ToString();
            }
            else
            {
                stlblTileId.Text = grid[xPos, yPos].ToString();
            }
        }