Beispiel #1
0
        private static void Init()
        {
            // Generate map
            CurrentMap = TestGameMap.CreateDungeonMap(100, 100);

            // Entity to test layering
            var testItem = new Entity(Color.White, Color.Transparent, 'i', (2, 2), 1, true, true);

            CurrentMap.AddEntity(testItem);

            Player = new Player(CurrentMap.WalkabilityView.RandomPosition(true));
            CurrentMap.AddEntity(Player);

            MapConsole = new ScrollingConsole(width: CurrentMap.Width, height: CurrentMap.Height,
                                              font: SadConsole.Global.FontDefault,
                                              viewPort: new XnaRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
                                              initialCells: CurrentMap.RenderingCellData);
            MapConsole.CenterViewPortOnPoint(Player.Position);

            CurrentMap.ConfigureAsRenderer(MapConsole);

            // Set our new console as the main object SadConsole processes, and set up keyboard input
            SadConsole.Global.CurrentScreen = MapConsole;
            SadConsole.Global.FocusedConsoles.Push(Player);
        }
        public static TestGameMap CreateDungeonMap(int width, int height)
        {
            var map     = new TestGameMap(width, height);
            var terrain = new ArrayMap <bool>(width, height);

            QuickGenerators.GenerateRectangleMap(terrain);

            foreach (var pos in terrain.Positions())
            {
                if (terrain[pos])
                {
                    map.SetTerrain(TerrainFactory.Floor(pos));
                }
                else
                {
                    map.SetTerrain(TerrainFactory.Wall(pos));
                }
            }

            return(map);
        }