Пример #1
0
        static void Cleanup(IMapGrid map)
        {
            // cleanup empty
            for (int x = 0; x < map.Width; x++) {
                for (int y = 0; y < map.Height; y++) {
                    if (map.GetID(x, y) == MapGridTypes.ID.Empty)
                        map.SetID (x, y, MapGridTypes.ID.Blocked);
                    if (map.GetID(x, y) == MapGridTypes.ID.TunnelEnd)
                        map.SetID (x, y, MapGridTypes.ID.Tunnel);
                }
            }

            // cleanup tunnels
            for (int x = 0; x < map.Width; x++) {
                for (int y = 0; y < map.Height; y++) {
                    if (map.GetID(x, y) == MapGridTypes.ID.Tunnel) {
                        if (!map.GetBBox(x, y).Any(z => z.Type != MapGridTypes.ID.Blocked))
                            map.SetID (x, y, MapGridTypes.ID.Blocked);
                    }
                }
            }
        }
Пример #2
0
        static void PlaceCorridors(IMapGrid map)
        {
            for (int i = 0; i < map.Width/2; i++) {
                for (int j = 0; j < map.Height/2; j++) {
                    int x = i * 2 + 1;
                    int y = j * 2 + 1;

                    if (map.GetID(x, y) != MapGridTypes.ID.Empty)
                        continue;

                    OpenCorridor (map, i, j, Utils.RandomEnumValue<Direction> ());
                }
            }

            // fixup tunnels end
            for (int x = 0; x < map.Width; x++) {
                for (int y = 0; y < map.Height; y++) {
                    if (map.GetID(x, y) == MapGridTypes.ID.TunnelEnd) {
                        if (map.GetBBox(x, y).Any(z => z.Type == MapGridTypes.ID.Door))
                            map.SetID (x, y, MapGridTypes.ID.Tunnel);
                    }
                }
            }
        }