Exemplo n.º 1
0
            public tunnel_profile tun; /* Used to build tunnels */

            #endregion Fields

            #region Constructors

            public cave_profile(string a, cave_builder b, int c, int d, int e, int f, tunnel_profile g, streamer_profile h,
								room_profile[] i, int j)
            {
                name = a;
                builder = b;
                dun_rooms = c;
                dun_unusual = d;
                max_rarity = e;
                n_room_profiles = f;
                tun = g;
                str = h;
                room_profiles = i;
                cutoff = j;
            }
Exemplo n.º 2
0
        /**
         * Attempt to build a room of the given type at the given block
         *
         * Note that we restrict the number of "crowded" rooms to reduce
         * the chance of overflowing the monster list during level creation.
         */
        static bool room_build(Cave c, int by0, int bx0, room_profile profile)
        {
            /* Extract blocks */
            int by1 = by0;
            int bx1 = bx0;
            int by2 = by0 + profile.height;
            int bx2 = bx0 + profile.width;

            int allocated;
            int y, x;
            int by, bx;

            /* Enforce the room profile's minimum depth */
            if (c.depth < profile.level) return false;

            /* Only allow one crowded room per level */
            if (dun.crowded && profile.crowded) return false;

            /* Never run off the screen */
            if (by1 < 0 || by2 >= dun.row_rooms) return false;
            if (bx1 < 0 || bx2 >= dun.col_rooms) return false;

            /* Verify open space */
            for (by = by1; by <= by2; by++) {
                for (bx = bx1; bx <= bx2; bx++) {
                    if (true) {
                        /* previous rooms prevent new ones */
                        if (dun.room_map[by, bx]) return false;
                    } else {
                        return false; /* XYZ */
                    }
                }
            }

            /* Get the location of the room */
            y = ((by1 + by2 + 1) * BLOCK_HGT) / 2;
            x = ((bx1 + bx2 + 1) * BLOCK_WID) / 2;

            /* Try to build a room */
            if (!profile.builder(c, y, x)) return false;

            /* Save the room location */
            if (dun.cent_n < CENT_MAX) {
                dun.cent[dun.cent_n] = new Loc();
                dun.cent[dun.cent_n].y = y;
                dun.cent[dun.cent_n].x = x;
                dun.cent_n++;
            }

            /* Reserve some blocks */
            allocated = 0;
            for (by = by1; by < by2; by++) {
                for (bx = bx1; bx < bx2; bx++) {
                    dun.room_map[by, bx] = true;
                    allocated++;
                }
            }

            /* Count "crowded" rooms */
            if (profile.crowded) dun.crowded = true;

            /* Success */
            return true;
        }