Esempio n. 1
0
        static void Main(string[] args)
        {
            Random = new RogueSharp.Random.DotNetRandom(seed);

            // create output system
            string fontFileName = "terminal8x8.png";
            string consoleTitle = $"ECS Test Level = {_mapLevel}";

            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight,
                                             8, 8, 1f, consoleTitle);
            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);

            // create systems, entityManager first
            EntityManager = new Systems.EntityManager(_mapWidth, _mapHeight);

            CommandSystem = new Systems.CommandSystem();
            MessageLog    = new Systems.MessageLog();

            SystemsManager  = new Systems.SystemManager(EntityManager);
            RenderSystem    = new Systems.RenderSystem(EntityManager);
            ShedSystem      = new Systems.SchedulingSystem();
            UseSystem       = new Systems.UseSystem(EntityManager);
            InventorySystem = new Systems.InventorySystem(EntityManager);

            //listen for critical events
            Core.EventBus.Subscribe(Core.EventTypes.GameCritical, (sender, e) => OnMessage(e));


            //MessageLog.Add("Rogue At level 1");

            //create map stuff
            Systems.MapGenerator mapGenerator = new Systems.MapGenerator(_mapWidth,
                                                                         _mapHeight, 25, 20, 7, _mapLevel, EntityManager);
            DungeonMap      = mapGenerator.CreateMap();
            MovementSystem  = new Systems.MovementSystem(DungeonMap, EntityManager);
            CollisionSystem = new Systems.CollisionSystem(EntityManager, DungeonMap);

            // place monsters
            mapGenerator.PlaceMonsters(EntityManager);
            mapGenerator.PlaceGold(EntityManager);

            //run initial FOV for monsters
            //DungeonMap.UpdateFOVForMonsters(EntityManager);

            //creat garbage system
            GarbageSystem = new Systems.GarbageSystem(ShedSystem, EntityManager, DungeonMap);

            //create AI system
            AISystem = new Systems.AISystem(EntityManager, DungeonMap, GarbageSystem);

            _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Core.Swatch.DbWood);
            _inventoryConsole.Print(1, 1, "Inventory", Core.Colours.TextHeading);

            _rootConsole.Update += OnRootConsoleUpdate;
            _rootConsole.Render += OnRootConsoleRender;
            _rootConsole.Run();
        }
Esempio n. 2
0
        private void GenerateMap()
        {
            // Create the map.
            RogueSharp.MapCreation.IMapCreationStrategy <RogueSharp.Map> mapCreationStrategy
                = new RogueSharp.MapCreation.RandomRoomsMapCreationStrategy <RogueSharp.Map>(Width, Height, 100, 15, 4);

            rogueMap = RogueSharp.Map.Create(mapCreationStrategy);
            rogueFOV = new RogueSharp.FieldOfView(rogueMap);

            // Create the local cache of the map data.
            mapData = new MapObjects.MapObjectBase[Width, Height];

            // Loop through the map information generated by RogueSharp and create out cached visuals of that data.
            foreach (var cell in rogueMap.GetAllCells())
            {
                if (cell.IsWalkable)
                {
                    // Our local information about each map square.
                    mapData[cell.X, cell.Y] = new MapObjects.Floor();

                    // Copy the appearance we've defined for Floor or Wall or whatever to the actual console data that is being rendered.
                    mapData[cell.X, cell.Y].RenderToCell(this[cell.X, cell.Y], false, false);
                }
                else
                {
                    rogueMap.SetCellProperties(cell.X, cell.Y, false, false);
                    mapData[cell.X, cell.Y] = new MapObjects.Wall();
                    mapData[cell.X, cell.Y].RenderToCell(this[cell.X, cell.Y], false, false);

                    // A wall blocks LOS
                    rogueMap.SetCellProperties(cell.X, cell.Y, false, cell.IsWalkable);
                }
            }

            RogueSharp.Random.IRandom random = new RogueSharp.Random.DotNetRandom();

            // Position the player somewhere on a walkable square.
            while (true)
            {
                int x = random.Next(Width - 1);
                int y = random.Next(Height - 1);
                if (rogueMap.IsWalkable(x, y))
                {
                    Player.Position = new Point(x, y);

                    // Center the view 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 = this.Position - TextSurface.RenderArea.Location;

                    break;
                }
            }
        }
Esempio n. 3
0
        private Menu_Floor NewFloorMenu(int seed = 1)
        {
            RogueSharp.Random.IRandom iRand = new RogueSharp.Random.DotNetRandom(seed);

            var player  = EntityBuilder.BuildPlayerEntity();
            var dungeon = new DungeonState(player);

            dungeon.AddFloor(FloorBuilder.BuildFloor(dungeon, Config.FloorWidth, Config.FloorHeight, iRand.Next(Int16.MaxValue).ToString(), 0, player));
            dungeon.AddFloor(FloorBuilder.BuildFloor(dungeon, Config.FloorWidth, Config.FloorHeight, iRand.Next(Int16.MaxValue).ToString(), 1));
            dungeon.AddFloor(FloorBuilder.BuildFloor(dungeon, Config.FloorWidth, Config.FloorHeight, iRand.Next(Int16.MaxValue).ToString(), 2));

            dungeon.FinalizeConstruction();

            this.floorMenu = new Menu_Floor(this, dungeon);
            return(this.floorMenu);
        }
Esempio n. 4
0
        public IDisplay OnRootConsoleUpdate(RLConsole console, RLKeyPress keyPress)
        {
            if (keyPress != null)
            {
                RogueSharp.Random.IRandom iRand = new RogueSharp.Random.DotNetRandom();

                return(this.floorMenu);
            }
            else if (keyPress != null)
            {
                return(this.mainMenu);
            }
            else
            {
                return(this);
            }
        }