示例#1
0
        public void ExcavateByGridTest()
        {
            CsRogueMap    map1      = new CsRogueMap();
            GridExcavator excavator = new GridExcavator(seed: 0);

            excavator.Excavate(map1);
            string     str1 = map1.ToString();
            CsRogueMap map2 = new CsRogueMap();

            excavator.Excavate(map2);
            string str2 = map2.ToString();

            Assert.AreEqual(str1, str2);
        }
示例#2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Generates a map. </summary>
        ///
        /// <remarks>   Darrellp, 8/26/2016. </remarks>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        private void GenerateMap()
        {
            _csRogueMap = new CsRogueMap(Width, Height);
            var excavator = new GridExcavator();

            excavator.Excavate(_csRogueMap);
            // Create the local cache of map data
            //
            _mapData = new MapObject[Width, Height];

            // Loop through the map information generated by RogueSharp and create our cached visuals of that data
            for (var iCol = 0; iCol < Width; iCol++)
            {
                for (var iRow = 0; iRow < Height; iRow++)
                {
                    var terrain = _csRogueMap[iCol, iRow].Terrain;
                    if (terrain == TerrainType.OffMap)
                    {
                        continue;
                    }
                    string str = MapTerrainToAppearance[_csRogueMap[iCol, iRow].Terrain];
                    var    obj = _mapData[iCol, iRow] = new MapObject(MapObjectFactory.ObjectNameToAppearance[str]);
                    obj.Appearance.CopyAppearanceTo(this[iCol, iRow]);
                    obj.RemoveCellFromView(this[iCol, iRow]);
                }
            }

            Player.Position = _csRogueMap.RandomFloorLocation().ToPoint();

            // Center the veiw area
            TextSurface.RenderArea = new Rectangle(Player.Position.X - (TextSurface.RenderArea.Width / 2),
                                                   Player.Position.Y - (TextSurface.RenderArea.Height / 2),
                                                   TextSurface.RenderArea.Width, TextSurface.RenderArea.Height);

            Player.RenderOffset = Position - TextSurface.RenderArea.Location;
            _fov = new FOV(_csRogueMap, FovDistance);
            _fov.Scan(Player.Position.ToMapCoordinates());
            foreach (var loc in _fov.CurrentlySeen)
            {
                _mapData[loc.Column, loc.Row].RenderToCell(this[loc.Column, loc.Row], true, true);
            }
        }