Exemplo n.º 1
0
        protected void drawTestedCells(Tile[,] map)
        {
            Point[] cells = NearbyCells(map);

            Point CELL_topleft = Map.VectorToCell(TopLeft);
            Point CELL_topright = Map.VectorToCell(TopRight);
            Point CELL_botleft = Map.VectorToCell(BotLeft);
            Point CELL_botright = Map.VectorToCell(BotRight);
            Point CELL_leftSideHigh = Map.VectorToCell(LeftSideHigh);
            Point CELL_leftSideLow = Map.VectorToCell(LeftSideLow);
            Point CELL_rightSideHigh = Map.VectorToCell(RightSideHigh);
            Point CELL_rightSideLow = Map.VectorToCell(RightSideLow);

            foreach (Point p in cells)
            {
                if (map[p.Y, p.X].value == 2 && (p.Equals(CELL_topleft) || p.Equals(CELL_topright) ||
                                           p.Equals(CELL_botleft) || p.Equals(CELL_botright) ||
                                           p.Equals(CELL_leftSideHigh) || p.Equals(CELL_leftSideLow) ||
                                           p.Equals(CELL_rightSideHigh) || p.Equals(CELL_rightSideLow)))
                    MarkTile(p, Color.Yellow);
                else
                    MarkTile(p, Color.Red);
            }
        }
Exemplo n.º 2
0
        // it would be best to break this up into smaller functions
        public Point[] NearbyCells(Tile[,] map)
        {
            int tileMapWidth = map.GetLength(1);
            int tileMapHeight = map.GetLength(0);

            List<Point> cells = new List<Point>();
            Point CELL_topleft = Map.VectorToCell(new Vector2(LeftSideHigh.X - tileMapWidth, TopLeft.Y - Map.tileHeight));
            Point CELL_botright = Map.VectorToCell(new Vector2(RightSideLow.X + tileMapWidth,
                                                         BotRight.Y + Map.tileHeight));
            for (int i = CELL_topleft.Y; i <= CELL_botright.Y; i++)
                for (int j = CELL_topleft.X; j <= CELL_botright.X; j++)
                    cells.Add(new Point(j, i));

            return cells.ToArray();
        }
Exemplo n.º 3
0
        public Point[] NearbyCellsAABB(Tile[,] map)
        {
            int tileMapWidth = map.GetLength(1);
            int tileMapHeight = map.GetLength(0);

            List<Point> cells = new List<Point>();
            Point CELL_topleft = Map.VectorToCell(new Vector2(AABB.X - tileMapWidth, AABB.Y - Map.tileHeight));
            Point CELL_botright = Map.VectorToCell(new Vector2(AABB.X + AABB.Width + tileMapWidth,
                                                         AABB.Y + AABB.Height + Map.tileHeight));
            for (int i = CELL_topleft.Y; i <= CELL_botright.Y; i++)
                for (int j = CELL_topleft.X; j <= CELL_botright.X; j++)
                    cells.Add(new Point(j, i));

            return cells.ToArray();
        }
Exemplo n.º 4
0
        private Tile[,] buildTileLayer(int[,] tileNums)
        {
            Tile[,] TL = new Tile[tileNums.GetLength(1), tileNums.GetLength(0)];

            for (int x = 0; x < tileNums.GetLength(0); x++)
                for (int y = 0; y < tileNums.GetLength(1); y++)
                {
                    TL[y, x] = new Tile(game, spritesheetPTR, tileNums[x, y], new Rectangle(tileNums[x, y] * Map.tileWidth, 0, Map.tileWidth, Map.tileHeight));
                    if (TL[y, x].value == 1 || TL[y, x].value == 2 || TL[y, x].value == 3)
                        TL[y, x].heightmap = fullHeightmap;
                    else if (TL[y, x].value == 4)
                        TL[y, x].heightmap = xySlopeHeightmap;
                    else if (TL[y, x].value == 5)
                    {
                        Array.Reverse(xySlopeHeightmap);
                        TL[y, x].heightmap = xySlopeHeightmap;
                    }
                }

                    return TL;
        }