Exemple #1
0
        static public void MakeRoom(ref AreaMap new_map, ref AreaMapTemplate template)
        {
            RoomTypes room_type = RoomTypes.NULL;

            // loads a random RoomTypes into local var room_typr and returns room_index;
            // room_index matches a room in List<MapRoomTypes> in AreaMap
            template.currRoomTypeIndex = GetRoomTypeProb(ref template, ref room_type);

            switch (room_type)
            {
            case RoomTypes.RECTANGLE:
                SetRectRoomArea(ref new_map, ref template);
                if (Globals.roomFail)
                {
                    break;
                }

                foreach (Point sqr in new_map.RoomList[MapGenHelper.roomCounter].AllSquares)
                {
                    MapGenHelper.PreToRoomOrWall(ref new_map, sqr, MapGenHelper.roomCounter);
                }

                SetRoomBarrier(ref new_map, ref template, MapGenHelper.roomCounter);
                MakeRoomArea(ref new_map, ref template);
                MapGenHelper.roomCounter++;

                break;
            }
        }
Exemple #2
0
        // 1) Gets random TileSet index for Room from LoadedTileSets
        // 2) Calls AddTextureName, which adds the TileSet name to this.mapEngineTextureNames
        //      and current AreaMap.TextureNameList
        static public void MakeRoomArea(ref AreaMap new_map, ref AreaMapTemplate template)
        {
            int rand_tile_set_index = 0;

            rand_tile_set_index         = rand.Next(0, MapGenHelper.LoadedTileSets.Count());
            MapGenHelper.CurrentTileSet = MapGenHelper.LoadedTileSets[rand_tile_set_index];

            foreach (Point sqr in new_map.RoomList[MapGenHelper.roomCounter].AllSquares)
            {
                MapGenHelper.AddTextureName(ref new_map, ref new_map.MSGrid[sqr.Y][sqr.X], MapGenHelper.LoadedTileSets[rand_tile_set_index].TextureName);
                MapGenHelper.AddRoomSqrTile(ref new_map, ref new_map.MSGrid[sqr.Y][sqr.X], sqr.X, sqr.Y);
            }
        }
Exemple #3
0
        static public void Initialize(ref ContentManager cm, ref int disc_rooms, ref int room_count)
        {
            isInitialized = true;
            TileSetManager.Initialize();
            TextureManager.Initialize(cm);
            RoomMaker.initialize();
            HallMaker.initialize();
            PathFinder.Initialize();

            LoadMapSetNames();
            MapGenHelper.Initialize();

            GenerateMap(ref cm, ref disc_rooms, ref room_count);
        }
Exemple #4
0
        static public void GenerateMap(ref ContentManager cm, ref int disc_rooms, ref int room_count)
        {
            AreaMap         current_map;
            AreaMapTemplate map_template = new AreaMapTemplate();

            discRooms = new List <int>();
            MapSets map_set   = MapSets.TEST_MAP_SET;           // change this
            Sizes   map_size  = Sizes.LARGE;                    // change this
            string  file_name = "test.xml";                     // change/remove this

            LoadMapSet(map_set, ref map_template);
            MapGenHelper.MakeMap(out current_map, ref map_template, map_size);
            MapGenHelper.GetMapData(ref disc_rooms, ref room_count);
            MapGenHelper.ResetMapGenHelper();
            //MapGenHelper.GetMapData(ref discRooms);
            MapLoader.MapToSavedMap(ref current_map, ref file_name);
        }
Exemple #5
0
        static public void MakeHallWalls(ref AreaMap new_map)
        {
            int x_tile_max = new_map.widthTiles; int y_tile_max = new_map.heightTiles;

            for (int y = 0; y < y_tile_max; y++)
            {
                for (int x = 0; x < x_tile_max; x++)
                {
                    if (new_map.MSGrid[y][x].MSStates[(int)MSFlagIndex.WALL_RM_ENT] == MSFlag.PWALL)
                    {
                        new_map.MSGrid[y][x].MSStates[(int)MSFlagIndex.BL_ST]       = MSFlag.NT_BL;
                        new_map.MSGrid[y][x].MSStates[(int)MSFlagIndex.WALL_RM_ENT] = MSFlag.WALL;
                        new_map.MSGrid[y][x].MSStates[(int)MSFlagIndex.PASSABLE]    = MSFlag.BLKD;
                        MapGenHelper.AddRoomSqrTile(ref new_map, ref new_map.MSGrid[y][x], x, y);
                    }
                }
            }
        }
Exemple #6
0
        // needs a list of of vector2 for the hall path(vec_path);
        static public void MakeHall(ref AreaMap new_map, int curr_path, ref List <List <Point> > paths)
        {
            int new_x    = 0;
            int new_y    = 0;
            int prev_x   = -1;
            int prev_y   = -1;
            int num_sqrs = paths[curr_path].Count;

            for (int square = 1; square < num_sqrs - 1; square++)
            {
                prev_x = paths[curr_path][square - 1].X; prev_y = paths[curr_path][square - 1].Y;
                new_x  = paths[curr_path][square].X; new_y = paths[curr_path][square].Y;

                // make new hall MapSquare
                new_map.MSGrid[new_y][new_x].MSStates[(int)MSFlagIndex.BL_ST]       = MSFlag.NT_BL;
                new_map.MSGrid[new_y][new_x].MSStates[(int)MSFlagIndex.WALL_RM_ENT] = MSFlag.ROOM;
                new_map.MSGrid[new_y][new_x].MSStates[(int)MSFlagIndex.PASSABLE]    = MSFlag.NT_BLKD;
                MapGenHelper.AddRoomSqrTile(ref new_map, ref new_map.MSGrid[new_y][new_x], new_x, new_y);
            }

            // turn beginning and ending MapSquares to Entrances
            new_x = paths[curr_path][0].X;
            new_y = paths[curr_path][0].Y;
            new_map.MSGrid[new_y][new_x].MSStates[(int)MSFlagIndex.WALL_RM_ENT] = MSFlag.ENT;
            new_map.MSGrid[new_y][new_x].MSStates[(int)MSFlagIndex.PASSABLE]    = MSFlag.NT_BLKD;
            MapGenHelper.AddRoomSqrTile(ref new_map, ref new_map.MSGrid[new_y][new_x], new_x, new_y);

            new_x = paths[curr_path][num_sqrs - 1].X;
            new_y = paths[curr_path][num_sqrs - 1].Y;
            new_map.MSGrid[new_y][new_x].MSStates[(int)MSFlagIndex.WALL_RM_ENT] = MSFlag.ENT;
            new_map.MSGrid[new_y][new_x].MSStates[(int)MSFlagIndex.PASSABLE]    = MSFlag.NT_BLKD;
            MapGenHelper.AddRoomSqrTile(ref new_map, ref new_map.MSGrid[new_y][new_x], new_x, new_y);

            if (Globals.DrawHallHeightsLinear)
            {
                MapGenHelper.SetAltitudesTest(ref new_map, curr_path, ref paths);
            }
        }
Exemple #7
0
        static public bool FloodIsConnectedCheck(ref AreaMap new_map, bool unmark_after)
        {
            int           adjacent_x = 0; int adjacent_y = 0;
            int           curr_ID       = 0;
            List <int>    visited_rooms = new List <int>();
            Stack <Point> squares       = new Stack <Point>();
            Point         cur_sqr       = Point.Zero;

            visited_rooms.Add(0);
            squares.Push(new_map.RoomList[0].RoomSquares[0]);

            if (new_map.MSGrid[new_map.RoomList[0].RoomSquares[0].Y]
                [new_map.RoomList[0].RoomSquares[0].X].MSStates[(int)MSFlagIndex.IS_MKD] == MSFlag.MKD)
            {
                MapGenHelper.UnmarkMap(ref new_map); ///
            }
            while (squares.Count > 0)
            {
                cur_sqr = squares.Pop();

                for (int dir = 0; dir < Globals.Directions.Count(); dir += Globals.NESWItr)
                {
                    adjacent_x = cur_sqr.X + Globals.Directions[dir].X; adjacent_y = cur_sqr.Y + Globals.Directions[dir].Y;

                    if (new_map.OffMap(adjacent_x, adjacent_y))
                    {
                        continue;
                    }

                    if (!new_map.ChkMSForState(ref new_map.MSGrid[adjacent_y][adjacent_x], MSFlag.WALL, MSFlagIndex.WALL_RM_ENT)) // changed: WALL->ROOM
                    {
                        if (new_map.ChkMSForState(ref new_map.MSGrid[adjacent_y][adjacent_x], MSFlag.NT_MKD, MSFlagIndex.IS_MKD))
                        {
                            curr_ID = new_map.MSGrid[adjacent_y][adjacent_x].RoomID;
                            new_map.MSGrid[adjacent_y][adjacent_x].MSStates[(int)MSFlagIndex.IS_MKD] = MSFlag.MKD;
                            squares.Push(new Point(adjacent_x, adjacent_y));

                            if (!visited_rooms.Contains(curr_ID))
                            {
                                visited_rooms.Add(curr_ID);
                            }
                        }
                    }
                }
            }

            MapGenHelper.disconnectedRooms.Clear();
            for (int i = 0; i < new_map.RoomList.Count(); i++)
            {
                if (!visited_rooms.Contains(i))
                {
                    MapGenHelper.disconnectedRooms.Add(i);
                }
            }

            if (MapGenHelper.disconnectedRooms.Count == 0)
            {
                MapGenHelper.UnmarkMap(ref new_map);
            }

            MapGenHelper.dcCount = MapGenHelper.disconnectedRooms.Count();

            if (MapGenHelper.disconnectedRooms.Count > 0)
            {
                return(false);
            }

            return(true);
        }