示例#1
0
文件: MapTest.cs 项目: Retucex/SORL
        public void Create_MapCreatedWithCaveCreationStrategy_ExpectedMap()
        {
            int     expectedWidth  = 50;
            int     expectedHeight = 20;
            IRandom random         = new DotNetRandom(27);
            IMapCreationStrategy <Map> mapCreationStrategy = new CaveMapCreationStrategy <Map>(expectedWidth, expectedHeight, 45, 3, 2, random);
            string expectedMapRepresentation = @"##################################################
                                              ########...###################.#.#####....########
                                              ######.......##############......#####....########
                                              ####........###############......####......#######
                                              ###.........#################...######........####
                                              ##........#################.##..#####.....########
                                              ###.......#######.#.######..##..#######.#..#######
                                              ####......######.......#........#########..#######
                                              #####.......#....##....###......#########..#######
                                              ######........#####..............#########..######
                                              #..###......########....######...#########..######
                                              #...##......########.....#####.....#.######..#####
                                              #............##########..######......######..#####
                                              #...........########.....######.#....#######..####
                                              ##...........#######.....###################..####
                                              #............#.#####........#################..###
                                              ##.............#####................#########..###
                                              ###.............#####........######...........####
                                              ####.#....#.#.#######.#.#...######################
                                              ##################################################";

            IMap actualMap = Map.Create(mapCreationStrategy);

            Trace.Write(actualMap);

            Assert.AreEqual(expectedWidth, actualMap.Width);
            Assert.AreEqual(expectedHeight, actualMap.Height);
            Assert.AreEqual(RemoveWhiteSpace(expectedMapRepresentation), RemoveWhiteSpace(actualMap.ToString()));
        }
        public void CaveTest()
        {
            var strat = new CaveMapCreationStrategy <RogueSharp.Map>(100, 120, 0.65);
            var map   = strat.CreateMap();

            Debug.WriteLine(map.ToString());
        }
示例#3
0
        public DungeonMap CreateCave(bool explored)
        {
            map.Initialize(width, heigth);

            IMapCreationStrategy <Map> strategy = new CaveMapCreationStrategy <Map>(width, heigth, 48, 3, 1);

            map.Copy(strategy.CreateMap());

            foreach (Cell cell in map.GetAllCells())
            {
                map.SetCellProperties(cell.X, cell.Y, cell.IsTransparent, cell.IsWalkable, explored);
            }

            return(map);
        }
示例#4
0
        public void Create_MapCreatedWithCaveCreationStrategy_ExpectedMap()
        {
            int expectedWidth = 50;
             int expectedHeight = 20;
             IRandom random = new DotNetRandom( 27 );
             IMapCreationStrategy<Map> mapCreationStrategy = new CaveMapCreationStrategy<Map>( expectedWidth, expectedHeight, 45, 3, 2, random );
             string expectedMapRepresentation = @"##################################################
                                              ########...###################.#.#####....########
                                              ######.......##############......#####....########
                                              ####........###############......####......#######
                                              ###.........#################...######........####
                                              ##........#################.##..#####.....########
                                              ###.......#######.#.######..##..#######.#..#######
                                              ####......######.......#........#########..#######
                                              #####.......#....##....###......#########..#######
                                              ######........#####..............#########..######
                                              #..###......########....######...#########..######
                                              #...##......########.....#####.....#.######..#####
                                              #............##########..######......######..#####
                                              #...........########.....######.#....#######..####
                                              ##...........#######.....###################..####
                                              #............#.#####........#################..###
                                              ##.............#####................#########..###
                                              ###.............#####........######...........####
                                              ####.#....#.#.#######.#.#...######################
                                              ##################################################";

             IMap actualMap = Map.Create( mapCreationStrategy );
             Trace.Write( actualMap );

             Assert.AreEqual( expectedWidth, actualMap.Width );
             Assert.AreEqual( expectedHeight, actualMap.Height );
             Assert.AreEqual( expectedMapRepresentation.Replace( " ", string.Empty ), actualMap.ToString() );
        }