Exemple #1
0
 public RectangleUpdate[,] getCurrentMapListView()
 {
     RectangleUpdate[,] newGridView = new RectangleUpdate[7, 9];
     for (int row = -3; row <= 3; row++)
     {
         for (int col = -4; col <= 4; col++)
         {
             int currentY = playerPosition[0] + row;
             int currentX = playerPosition[1] + col;
             if (currentY < 0 || currentY > (currentMap.map.GetLength(0) - 1))
             {
                 newGridView[row + 3, col + 4] = new RectangleUpdate();
             }
             else if (currentX < 0 || currentX > (currentMap.map.GetLength(1) - 1))
             {
                 newGridView[row + 3, col + 4] = new RectangleUpdate();
             }
             else
             {
                 MapTile currentMapTile = currentMap.map[currentY, currentX];
                 newGridView[row + 3, col + 4] = new RectangleUpdate(currentMapTile.getColor(), null, currentMapTile.tileUnpassable());
             }
         }
     }
     return(newGridView);
 }
Exemple #2
0
        public RectangleUpdate[,] getFullMapListView()
        {
            if (worldGenDebug == true)
            {
                mapChanged = false;

                RectangleUpdate[,] fullMapGrid = new RectangleUpdate[currentMap.map.GetLength(0), currentMap.map.GetLength(1)];
                for (int row = 0; row < fullMapGrid.GetLength(0); row++)
                {
                    for (int col = 0; col < fullMapGrid.GetLength(1); col++)
                    {
                        if (row < 0 || row > (currentMap.map.GetLength(0) - 1))
                        {
                            fullMapGrid[row, col] = new RectangleUpdate();
                        }
                        else if (col < 0 || col > (currentMap.map.GetLength(1) - 1))
                        {
                            fullMapGrid[row, col] = new RectangleUpdate();
                        }
                        else
                        {
                            MapTile currentMapTile = currentMap.map[row, col];
                            fullMapGrid[row, col] = new RectangleUpdate(currentMapTile.getColor());
                        }
                    }
                }
                return(fullMapGrid);
            }

            oldY = (int)Math.Round((double)playerPosition[0] / 25) * 25;
            oldX = (int)Math.Round((double)playerPosition[1] / 25) * 25;

            int startRow = Math.Max(0, Math.Min(currentMap.map.GetLength(0) - 51, oldY - 25));
            int startCol = Math.Max(0, Math.Min(currentMap.map.GetLength(1) - 51, oldX - 25));
            int rowCount = Math.Min(currentMap.map.GetLength(0), 50);
            int colCount = Math.Min(currentMap.map.GetLength(1), 50);

            RectangleUpdate[,] miniMapGrid = new RectangleUpdate[rowCount, colCount];
            for (int row = startRow; row < rowCount + startRow; row++)
            {
                for (int col = startCol; col < colCount + startCol; col++)
                {
                    if (row < 0 || row > (currentMap.map.GetLength(0) - 1))
                    {
                        miniMapGrid[row - startRow, col - startCol] = new RectangleUpdate();
                    }
                    else if (col < 0 || col > (currentMap.map.GetLength(1) - 1))
                    {
                        miniMapGrid[row - startRow, col - startCol] = new RectangleUpdate();
                    }
                    else
                    {
                        MapTile currentMapTile = currentMap.map[row, col];
                        miniMapGrid[row - startRow, col - startCol] = new RectangleUpdate(currentMapTile.getColor());
                    }
                }
            }
            return(miniMapGrid);
        }
Exemple #3
0
        /*
         * __  __          _____     _____ _____  _____ _____
         |  \/  |   /\   |  __ \   / ____|  __ \|_   _|  __ \
         | \  / |  /  \  | |__) | | |  __| |__) | | | | |  | |
         | |\/| | / /\ \ |  ___/  | | |_ |  _  /  | | | |  | |
         | |  | |/ ____ \| |      | |__| | | \ \ _| |_| |__| |
         |_|  |_/_/    \_\_|       \_____|_|  \_\_____|_____/
         |
         */

        private void updateMapGrid()
        {
            if (GUIHandler.mapGridChanged())
            {
                RectangleUpdate[,] newRects = GUIHandler.getMapGrid();
                if (newRects.GetLength(0) != mapCellGrid.GetLength(0) || newRects.GetLength(1) != mapCellGrid.GetLength(1))
                {
                    throw new System.ArgumentException("BAD MATRIX SIZED FOR MAP");
                }
                for (int row = 0; row < mapCellGrid.GetLength(0); row++)
                {
                    for (int col = 0; col < mapCellGrid.GetLength(1); col++)
                    {
                        Rectangle       currentRectangle = mapCellGrid[row, col];
                        RectangleUpdate currentUpdate    = newRects[row, col];
                        if (currentUpdate == null)
                        {
                            throw new System.ArgumentException("updateMapGrid failed at row " + row + " col " + col);
                        }

                        if (currentUpdate.turnOffRectangle)
                        {
                            if (currentRectangle.StrokeThickness > 0)
                            {
                                if (currentRectangle.Stroke != null)
                                {
                                    removeClickableRectsClick(currentRectangle);
                                }
                            }

                            if (currentUpdate.color != null)
                            {
                                currentRectangle.Fill = currentUpdate.color;
                            }
                            else
                            {
                                currentRectangle.Fill = Brushes.Black;
                            }
                            if (!string.IsNullOrEmpty(currentUpdate.tooltip))
                            {
                                currentRectangle.ToolTip = currentUpdate.tooltip;
                            }
                        }
                        else
                        {
                            if (currentRectangle.StrokeThickness > 0)
                            {
                                if (currentRectangle.Stroke == null)
                                {
                                    addClickableRectsClick(currentRectangle);
                                }
                            }

                            currentRectangle.Fill = currentUpdate.color;
                            if (!string.IsNullOrEmpty(currentUpdate.tooltip))
                            {
                                currentRectangle.ToolTip = currentUpdate.tooltip;
                            }
                        }
                    }
                }
            }
        }