/// <summary>
    /// For the given chunk's topsoil blocks, ask each decorator (tree, bush, etc)
    /// to decorate here. Of course, the decorator ultimately decides if it wants to
    /// be here or not.
    /// </summary>
    /// <param name="chunk"></param>
    public void GenerateDecorationsForChunk(Chunk chunk)
    {
        if (chunk.IsOnTheBorder)
        {
            return;
        }
        IRandom random = new DotNetRandom();

        try
        {
            foreach (Vector3i topSoilBlock in chunk.TopSoilBlocks)
            {
                foreach (IDecoration decoration in m_Decorations)
                {
                    // This passes in the LOCAL map block coordinate for the topsoil block
                    // we are considering for decoration.
                    if (decoration.Decorate(chunk, topSoilBlock - m_WorldData.MapBlockOffset, random))
                    {
                        continue;
                    }
                }
            }
        }
        catch (Exception e)
        {
            Debug.Log("Exception decorating " + e.Message + "\r\n\r\n" + e.StackTrace);
        }
    }
Ejemplo n.º 2
0
        public void Create_MapCreatedWithRandomRoomsMapCreationStrategy_ExpectedMap()
        {
            int     expectedWidth  = 17;
            int     expectedHeight = 10;
            IRandom random         = new DotNetRandom(13);
            IMapCreationStrategy <LibtcodMap> mapCreationStrategy = new RandomRoomsMapCreationStrategy <LibtcodMap>(expectedWidth, expectedHeight, 30, 5, 3, random);
            string expectedMapRepresentation = @"#################
                                              #################
                                              ##...#######...##
                                              ##.............##
                                              ###.###....#...##
                                              ###...##.#####.##
                                              ###...##...###..#
                                              ####............#
                                              ##############..#
                                              #################";

            IMap actualMap = LibtcodMap.Create(mapCreationStrategy);

            Trace.Write(actualMap);

            Assert.AreEqual(expectedWidth, actualMap.Width);
            Assert.AreEqual(expectedHeight, actualMap.Height);
            Assert.AreEqual(expectedMapRepresentation.Replace(" ", string.Empty), actualMap.ToString());
        }
Ejemplo n.º 3
0
        private static void LoadNextLevel()
        {
            if (_mapLevel == 4)
            {
                GameOver();
                return;
            }

            if (playWithSeed && _mapLevel <= _save.Seeds.Count)
            {
                _seed = _save.Seeds[_mapLevel - 1];
            }
            else
            {
                // Creating a new seed for the next level
                _seed = (int)DateTime.UtcNow.Ticks;
                // Saving that seed int the save
                _save.Seeds.Add(_seed);
            }

            Random = new DotNetRandom(_seed);
            MapGenerator mapGenerator = ChoseMapGenerator();

            Map           = mapGenerator.CreateMap(_seed);
            MessageLog    = new MessageLog();
            CommandSystem = new CommandSystem();

            MessageLog.Add(Story.levelBeginnigTexts[_mapLevel - 1]);
        }
Ejemplo n.º 4
0
        private Point GetRandomEdgePoint(DungeonMap map)
        {
            var random = new DotNetRandom();
            int result = random.Next(1, 4);

            switch (result)
            {
            case 1: // TOP
            {
                return(new Point(random.Next(3, map.Width - 3), 3));
            }

            case 2: // BOTTOM
            {
                return(new Point(random.Next(3, map.Width - 3), map.Height - 3));
            }

            case 3: // RIGHT
            {
                return(new Point(map.Width - 3, random.Next(3, map.Height - 3)));
            }

            case 4: // LEFT
            {
                return(new Point(3, random.Next(3, map.Height - 3)));
            }

            default:
            {
                return(new Point(3, 3));
            }
            }
        }
Ejemplo n.º 5
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(RemoveWhiteSpace(expectedMapRepresentation), RemoveWhiteSpace(actualMap.ToString()));
        }
Ejemplo n.º 6
0
        public void Create_PrimMaze()
        {
            IRandom random         = new DotNetRandom(0);
            int     expectedWidth  = 7;
            int     expectedHeight = 11;
            IMapCreationStrategy <CaveMap> mapCreationStrategy = new PrimsMazeMapCreationStrategy <CaveMap>(expectedWidth, expectedHeight, random);
            IMap actualMap = mapCreationStrategy.CreateMap();

            Trace.Write(actualMap);
            string expectedMapRepresentation = @"#######
                                              #.....#
                                              #.###.#
                                              #...#.#
                                              #.#.###
                                              #.#...#
                                              #.#####
                                              #...#.#
                                              #.###.#
                                              #.....#
                                              #######";

            Assert.AreEqual(expectedWidth, actualMap.Width);
            Assert.AreEqual(expectedHeight, actualMap.Height);
            Assert.AreEqual(RemoveWhiteSpace(expectedMapRepresentation), RemoveWhiteSpace(actualMap.ToString()));
        }
Ejemplo n.º 7
0
        public static void Main()
        {
            TurnQueue = new TurnQueue();
            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);
            string bitmap = "terminal8x8.png";
            string Title  = $"RPG - Poziom {Facade._mapLevel}";

            _mainConsole         = new RLRootConsole(bitmap, _screenWidth, _screenHeight, 8, 8, 1f, Title);
            _mapConsole          = new RLConsole(_mapWidth, _mapHeight);
            _logConsole          = new RLConsole(_logWidth, _logHeight);
            _statConsole         = new RLConsole(_statWidth, _statHeight);
            _lootConsole         = new RLConsole(_lootWidth, _lootHeight);
            _mainConsole.Update += OnRootConsoleUpdate;
            _mainConsole.Render += OnRootConsoleRender;
            _mapConsole.SetBackColor(0, 0, _mapWidth, _mapHeight, Colors.FloorBG);
            _mapConsole.Print(1, 1, "Mapa", Colors.TextH);
            _statConsole.SetBackColor(0, 0, _statWidth, _statHeight, Palette.Red2);
            _statConsole.Print(1, 1, "Statystyki", Colors.TextH);
            _lootConsole.SetBackColor(0, 0, _lootWidth, _lootHeight, Palette.Wood);
            _lootConsole.Print(1, 1, "Ekwipunek", Colors.TextH);
            soundplayer.SoundLocation = AppDomain.CurrentDomain.BaseDirectory + "\\muzyka.wav";
            soundplayer.PlayLooping();
            facade.InitGame();
            _mainConsole.Run();
        }
Ejemplo n.º 8
0
        public void TestCellAutoConnectivityAndEnclosure()
        {
            var random = new DotNetRandom();
            var map    = new ArrayMap <bool>(80, 50);

            Generators.CellularAutomataGenerator.Generate(map, random, 40, 7, 4);

            for (int i = 0; i < 500; i++)
            {
                Generators.CellularAutomataGenerator.Generate(map, random, 40, 7, 4);

                // Ensure it's connected
                var areas = MapAreaFinder.MapAreasFor(map, Distance.MANHATTAN).ToList();
                Assert.AreEqual(1, areas.Count);

                // Ensure it's enclosed
                for (int x = 0; x < map.Width; x++)
                {
                    Assert.AreEqual(false, map[x, 0]);
                    Assert.AreEqual(false, map[x, map.Height - 1]);
                }
                for (int y = 0; y < map.Height; y++)
                {
                    Assert.AreEqual(false, map[0, y]);
                    Assert.AreEqual(false, map[map.Width - 1, y]);
                }
            }
        }
Ejemplo n.º 9
0
        public MapBuilder(int width, int height, int depth, int seed = 1337)
        {
            Random = new DotNetRandom(seed);
            Map    = new Map(width, height, depth);

#if DEBUG
            History = new List <Map>();
#endif
        }
Ejemplo n.º 10
0
    public void Reset()
    {
        int seed = (int)DateTime.UtcNow.Ticks;

        Random = new DotNetRandom(seed);

        //MessageLog.Clear();
        SchedulingSystem.Clear();
        gameOver = false;
    }
Ejemplo n.º 11
0
        public void ManualTestRandomRoomsGen()
        {
            var random = new DotNetRandom();
            var map    = new ArrayMap <bool>(30, 30);

            Generators.RandomRoomsGenerator.Generate(map, 7, 4, 7, 5, random);

            displayMap(map);
            // TODO: Some assert here
        }
Ejemplo n.º 12
0
        public void SpawnEnemies(int n)
        {
            var map      = _dungeon.CurrentMap;
            var tileSize = _dungeon.TileSize;
            var random   = new DotNetRandom();

            for (var i = 0; i < n; i++)
            {
                _badDudes.Add(SpawnNewEnemy(map, tileSize, random));
            }
        }
Ejemplo n.º 13
0
        public void ManualTestCellAutoGen()
        {
            var random = new DotNetRandom();
            var map    = new ArrayMap <bool>(80, 50);

            Generators.CellularAutomataGenerator.Generate(map, random, 40, 7, 4);

            displayMap(map);

            // TODO: Asserts
        }
Ejemplo n.º 14
0
    // Use this for initialization
    void OnEnable()
    {
        int     width = 300, height = 100;
        IRandom random = new DotNetRandom(12);
        IMapCreationStrategy <Map> mapCreationStrategy = new RandomRoomsMapCreationStrategy <Map>(width, height, 30, 30, 10, random);
        //  mapCreationStrategy = new CaveMapCreationStrategy<Map>(width, height, 30, 20, 5, random);
        IMap actualMap = Map.Create(mapCreationStrategy);

        Color[] colors = new Color[width * height];
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                var cell = actualMap.GetCell(j, i);
                if (cell.IsWalkable)
                {
                    colors[width * i + j] = Color.red;
                }
                else
                {
                    colors[width * i + j] = Color.blue;
                }
            }
        }
        Texture2D tex = new Texture2D(width, height);

        tex.SetPixels(colors);
        tex.Apply();
        var bytes = tex.EncodeToPNG();

        File.WriteAllBytes(Application.dataPath + "/randomtxt.png", bytes);
        //var str = actualMap.ToString();
        //str = str.Replace(".", "<color=#C5C1407B>#</color>");
        //DLog.Log(str);
        //int[,] map = MapGenerate(20, 20, 3, 5, 3, 8);
        //string s = "";
        //for (int i = 0; i < map.GetLength(0); i++)
        //{
        //    for (int j = 0; j < map.GetLength(1); j++)
        //    {
        //        if(map[i,j] == 0)
        //        {
        //            s += "#";
        //        }
        //        else
        //        {
        //            s += "<color=#111111>#</color>";
        //        }
        //    }
        //    s += "\r\n";
        //}
        //  DLog.Log(s);
    }
Ejemplo n.º 15
0
        public Game(UI.Main screen)
        {
            int seed = (int)DateTime.UtcNow.Ticks;

            Random           = new DotNetRandom(seed);
            CommandSystem    = new CommandSystem(this);
            Logger           = new Systems.Logger(this);
            SchedulingSystem = new SchedulingSystem(this);
            TargetingSystem  = new TargetingSystem(this);

            this.screen          = screen;
            screen.UpdateRender += OnUpdate;
        }
Ejemplo n.º 16
0
        public static void Play()
        {
            string fontFileName = "terminal16x16_gs_ro.png";

            // for testing use 1138043851
            Random = new DotNetRandom(seed);
            //TODO: Take seed out after debugging
            string consoleTitle = $"D$ DungeonZ Level {_mapLevel} - Seed {seed}";

            //setup systems
            SchedulingSystem = new SchedulingSystem();
            CommandSystem    = new CommandSystem();
            MessageLog       = new MessageLog();
            Player           = new Player();

            // Dont change map width or height
            //Attempting to make 20 rooms that are between 5 and 13 cells for room size
            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 50, 5, 13, _mapLevel);

            DungeonMap = mapGenerator.CreateMap();
            DungeonMap.UpdatePlayerFieldOfView();

            // first numbers effect tile size
            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight, 16, 16, 1.5f, consoleTitle);

            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);

            //these console methods have to be run before the update and render below
            _mapConsole.SetBackColor(0, 0, _mapWidth, _mapHeight, Colors.FloorBackground);
            _mapConsole.Print(1, 1, "Map", Colors.TextHeading);

            // Create a new MessageLog and print the random seed used to generate the level
            MessageLog.Add($"{Player.Name} arrives on level 1");
            MessageLog.Add($"Level created with seed '{seed}'");

            // Remove these lines:
            _messageConsole.SetBackColor(0, 0, _messageWidth, _messageHeight, Swatch.DbDeepWater);
            _messageConsole.Print(1, 1, "Messages", Colors.TextHeading);

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

            // have to register events for RLNet for update and render
            _rootConsole.Update += OnRootConsoleUpdate;
            _rootConsole.Render += OnRootConsoleRender;
            _rootConsole.Run();
        }
Ejemplo n.º 17
0
        private Cell GetRandomEmptyCell()
        {
            IRandom random = new DotNetRandom();

            while (true)
            {
                int x = Global.Random.Next(49);
                int y = Global.Random.Next(29);
                if (map.IsWalkable(x, y))
                {
                    return(map.GetCell(x, y));
                }
            }
        }
Ejemplo n.º 18
0
        public static void Main()
        {
            //Console.WriteLine("Good luck, you will need it.");
            string fontFileName = "terminal8x8.png";
            int    seed         = (int)DateTime.UtcNow.Ticks;
            string consoleTitle = $"RoguelikeGame - Level {MapLevel}";

            Random           = new DotNetRandom(seed);
            MessageLog       = new MessageLog();
            SchedulingSystem = new SchedulingSystem();
            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, MapLevel);

            DungeonMap = mapGenerator.CreateForrest();
            DungeonMaps.Add(DungeonMap);

            _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);

            CommandSystem       = new CommandSystem();
            TargetingSystem     = new TargetingSystem();
            InputSystem         = new InputSystemPlaying();
            InventoryScreen     = new InventoryScreen(_popupWidth, _popupHeight);
            DialogScreen        = new DialogScreen(_popupWidth, _dialogHeight);
            ShopSelectionScreen = new ShopSelectionScreen(_popupWidth, _dialogHeight);
            BuyScreen           = new BuyScreen(_popupWidth, _popupHeight);
            SellScreen          = new SellScreen(_popupWidth, _popupHeight);

            if (Player.GreetMessages != null)
            {
                Random random = new Random();
                int    i      = random.Next(0, Player.GreetMessages.Length);
                MessageLog.Add($"{Player.GreetMessages[i]}", Colors.Gold);
            }
            else
            {
                MessageLog.Add("Good luck on your quest ", Colors.Gold);
            }
            // MessageLog.Add($"Level created with seed '{seed}'"); // debug

            _rootConsole.Update += OnIntroUpdate;
            _rootConsole.Render += OnIntroRender;

            Timer t = new Timer(UpdateColoredText, null, 0, 200);

            _rootConsole.Run();
        }
Ejemplo n.º 19
0
        public static void Main()
        {
            // Establish the seed for the random number generator from the current time
            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);

            // This must be the exact name of the bitmap font file we are using or it will error.
            string fontFileName = "terminal8x8.png";

            // The title will appear at the top of the console window along with the seed used to generate the level
            string consoleTitle = $"Rouge - Level {_mapLevel} - Seed {seed}";

            SchedulingSystem = new SchedulingSystem();

            // Create a new MessageLog and print the random seed used to generate the level
            MessageLog = new MessageLog();
            MessageLog.Add("The rogue arrives on level 1");
            MessageLog.Add($"Level created with seed '{seed}'");

            // Tell RLNet to use the bitmap font that we specified and that each tile is 8 x 8 pixels
            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight, 8, 8, 1f, consoleTitle);

            // Initialize the sub consoles that we will Blit to the root console
            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);

            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 40, 22, 7, _mapLevel);

            DungeonMap = mapGenerator.CreateMap();
            DungeonMap.UpdatePlayerFieldOfView();

            CommandSystem = new CommandSystem();

            // Set up a handler for RLNET's Update event
            _rootConsole.Update += OnRootConsoleUpdate;

            // Set up a handler for RLNET's Render event
            _rootConsole.Render += OnRootConsoleRender;

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

            // Begin RLNET's game loop
            _rootConsole.Run();
        }
Ejemplo n.º 20
0
    public Game(GameManager manager, int seed)
    {
        this.Manager = manager;

        Random = new DotNetRandom(seed);

        commandSystem    = new CommandSystem(this);
        MessageLog       = new MessageLog(this);
        SchedulingSystem = new SchedulingSystem();

        MessageLog.Add("You have entered Level " + (GameData.Data.CurrentLevel + 1));

        if (GameData.Data.CurrentLevel == GameData.Data.Levels - 1)
        {
            MessageLog.Add("You sense an ominous presence.");
        }
    }
Ejemplo n.º 21
0
        public static FloorState BuildFloor(DungeonState dungeon, int width, int height, string mapID, int level)
        {
            var           distributions = FloorBuilder.levelDefinitions[level];
            List <Entity> mapEntities   = new List <Entity>();
            var           placementRand = new DotNetRandom(Int32.Parse(mapID));
            int           d             = 0;

            foreach (var dist in distributions)
            {
                var numToAdd = placementRand.Next(dist.Min, dist.Max);
                for (int i = 0; i < numToAdd; i++)
                {
                    mapEntities.Add(EntityBuilder_Enemies.BuildRandomLevelledEntity(placementRand, d.ToString(), dist.EntityLevel));
                    d++;
                }
            }
            return(FloorBuilder.BuildArena(dungeon, width, height, mapID, mapEntities, level));
        }
Ejemplo n.º 22
0
        public void NPCTurn(IActor player)
        {
            foreach (Enemie enemie in _enemies)
            {
                FieldOfView monsterFov = new FieldOfView(_dungeonMap);
                monsterFov.ComputeFov(enemie.X, enemie.Y, enemie.RangeFov, true);

                if (monsterFov.IsInFov(player.X, player.Y))
                {
                    SetWalkable(player.X, player.Y, true);
                    SetWalkable(enemie.X, enemie.Y, true);

                    ICell cellPlayer = _dungeonMap.GetCell(player.X, player.Y);
                    ICell cellEnemie = _dungeonMap.GetCell(enemie.X, enemie.Y);

                    PathFinder pathFinder = new PathFinder(_dungeonMap);
                    Path       path       = pathFinder.TryFindShortestPath(cellEnemie, cellPlayer);

                    SetWalkable(player.X, player.Y, false);
                    SetWalkable(enemie.X, enemie.Y, false);

                    if (path != null)
                    {
                        ICell cell = path.TryStepForward();
                        SetActorPosition(enemie, cell.X, cell.Y);
                    }
                }
                else
                {
                    //Czy się poruszy w losowe miejsce?
                    if (Roll.Dice.D100() < 50)
                    {
                        DotNetRandom dot = new DotNetRandom();

                        List <ICell> cells = _dungeonMap.GetCellsInSquare(enemie.X, enemie.Y, 1).Where(c => c.IsWalkable).ToList();
                        ICell        cell  = cells[(dot.Next(0, cells.Count() - 1))];
                        if (cell != null)
                        {
                            SetActorPosition(enemie, cell.X, cell.Y);
                        }
                    }
                }
            }
        }
Ejemplo n.º 23
0
        public void Restore_AfterGeneratingThreeNumbers_RegeneratesSameThreeNumbers()
        {
            IRandom random = new DotNetRandom();

            for (int i = 0; i < 25; i++)
            {
                random.Next(1000);
            }
            RandomState state  = random.Save();
            int         first  = random.Next(1000);
            int         second = random.Next(1000);
            int         third  = random.Next(1000);

            random.Restore(state);

            Assert.AreEqual(first, random.Next(1000));
            Assert.AreEqual(second, random.Next(1000));
            Assert.AreEqual(third, random.Next(1000));
        }
Ejemplo n.º 24
0
        public static void Main()
        {
            // This must be the exact name of the bitmap font file we are using or it will error.
            string fontFileName = "terminal8x8.png";
            // The title will appear at the top of the console window

            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);

            // The title will appear at the top of the console window
            // also include the seed used to generate the level
            string consoleTitle = $"RougeSharp V3 Tutorial - Level 1 - Seed {seed}";

            // Tell RLNet to use the bitmap font that we specified and that each tile is 8 x 8 pixels
            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight, 8, 8, 1f, consoleTitle);
            // Initialize the sub consoles that we will Blit to the root console
            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);
            MessageLog        = new MessageLog();
            MessageLog.Add("The rogue arrives on level 1");
            MessageLog.Add($"Level created with seed '{seed}'");

            _statConsole.SetBackColor(0, 0, _statWidth, _statHeight, Palette.DbOldStone);
            _statConsole.Print(1, 1, "Stats", Colors.TextHeading);

            _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Palette.DbWood);
            _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading);
            CommandSystem = new CommandSystem();
            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7);

            DungeonMap = mapGenerator.CreateMap();
            //DungeonMap.UpdatePlayerFieldOfView();
            // Set up a handler for RLNET's Update event
            _rootConsole.Update += OnRootConsoleUpdate;
            // Set up a handler for RLNET's Render event
            _rootConsole.Render += OnRootConsoleRender;
            //_rootConsole.OnLoad += rootConsole_OnLoad;
            // Begin RLNET's game loop
            _rootConsole.Run();
        }
Ejemplo n.º 25
0
        public static void Main(string[] args)
        {
            string fontFileName = "terminal8x8.png";

            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);

            string consoleTitle = $"RogueLike Test - Level {_mapLevel} - Seed {seed}";

            CommandSystem    = new CommandSystem();
            SchedulingSystem = new SchedulingSystem();

            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, _mapLevel);

            DungeonMap = mapGenerator.CreateMap();
            DungeonMap.UpdatePlayerFieldOfView();

            _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);

            _mapConsole.SetBackColor(0, 0, _mapWidth, _mapHeight, Colors.FloorBackground);
            _mapConsole.Print(1, 1, "Mapa", Colors.TextHeading);

            MessageLog = new MessageLog();
            MessageLog.Add("O Errante chega no andar 1");
            MessageLog.Add($"Level criado com a seed '{seed}'");

            _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Swatch.DbWood);
            _inventoryConsole.Print(1, 1, "Inventario", Colors.TextHeading);


            _rootConsole.Update += OnRootConsoleUpdate;

            _rootConsole.Render += OnRootConsoleRender;

            _rootConsole.Run();
        }
Ejemplo n.º 26
0
        private static FloorState BuildArena(DungeonState dungeon, int width, int height, string mapID, IEnumerable <Entity> entities, int level)
        {
            if (!seedsToMaps.ContainsKey(mapID))
            {
                var map = Map.Create(new RogueSharp.MapCreation.RandomRoomsMapCreationStrategy <Map>(width, height,
                                                                                                     2000, 9, 5, new DotNetRandom(Int32.Parse(mapID))));
                var pathFinder = new PathFinder(map);
                seedsToMaps[mapID] = new Tuple <IMap, PathFinder>(map, pathFinder);
            }

            var mapEntities = new List <Entity>();

            foreach (var e in entities)
            {
                mapEntities.Add(e);
            }
            FloorState floorState = new FloorState(dungeon, mapEntities, mapID, seedsToMaps[mapID].Item1, seedsToMaps[mapID].Item2, level);

            var openCells     = floorState.FloorMap.GetAllCells().Where(c => c.IsWalkable).ToList();
            var placementRand = new DotNetRandom(Int32.Parse(mapID));

            foreach (var e in mapEntities)
            {
                while (!e.HasComponentOfType <Component_Position>())
                {
                    var cell = openCells[placementRand.Next(openCells.Count - 1)];

                    Component_AI ai = e.GetComponentOfType <Component_AI>();
                    if (ai != null && !FloorBuilder.InScanRangeOfPlayer(floorState.Player, e, cell))
                    {
                        floorState.PlaceEntityNear(e, cell.X, cell.Y);
                        ai.DeterminePatrolPath(floorState, placementRand);
                    }
                    else if (ai == null)
                    {
                        floorState.PlaceEntityNear(e, cell.X, cell.Y);
                    }
                }
            }

            return(floorState);
        }
Ejemplo n.º 27
0
        public Game(UI_Main console)
        {
            int seed = (int)DateTime.UtcNow.Ticks;

            Random           = new DotNetRandom(seed);
            commandSystem    = new CommandSystem(this);
            MessageLog       = new MessageLog(this);
            SchedulingSystem = new SchedulingSystem();

            rootConsole             = console;
            rootConsole.UpdateView += OnUpdate;                          // Set up a handler for graphic engine Update event

            MessageLog.Add("The rogue arrives on level " + mapLevel);
            MessageLog.Add("Level created with seed '" + seed + "'");

            GenerateMap();
            rootConsole.SetPlayer(Player);
            World.UpdatePlayerFieldOfView(Player);
            Draw();
        }
Ejemplo n.º 28
0
    public void NewGame()
    {
        PlayerHealth    = 0;
        PlayerMaxHealth = 0;
        PlayerAttack    = 0;
        PlayerMoves     = 0;
        ItemsFound      = 0;
        SlippersFound   = false;

        CurrentLevel = 0;
        LastLevel    = 0;

        PrimarySeed = (int)DateTime.UtcNow.Ticks;

        IRandom Level = new DotNetRandom(PrimarySeed);

        for (int i = 0; i < Levels; i++)
        {
            LevelSeeds[i] = Level.Next(int.MinValue + 1, int.MaxValue - 1);
        }
    }
Ejemplo n.º 29
0
        static void Main(string[] args)
        {
            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);

            string fontFileName = "terminal8x8.png";
            string consoleTitle = $"RogueSharp - Level 1 - Seed: {seed}";

            _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);

            SchedulingSystem = new SchedulingSystem();

            //Player = new Player();
            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7);

            DungeonMap = mapGenerator.CreateMap();
            DungeonMap.UpdatePlayerFieldOfView();

            CommandSystem = new CommandSystem();


            MessageLog = new MessageLog();
            MessageLog.Add("The rogue arrives at level 1");
            MessageLog.Add($"Dungeon generated with seed: {seed}");

            // Only Run This Block Once... For now
            _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Swatch.DbWood);
            _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading);

            // Resume regular operation
            _rootConsole.Update += OnRootConsoleUpdate;
            _rootConsole.Render += OnRootConsoleRender;
            _rootConsole.Run();
        }
Ejemplo n.º 30
0
        public static void Main()
        {
            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);

            string fontFileName = "terminal8x8.png";
            string consoleTitle = $"Game tutorial - Level {mapLevel} - Seed {seed}";

            rootConsole = new RLRootConsole(fontFileName, screenWidth, screenHeight, 8, 8, 1f, consoleTitle);
            mapConsole  = new RLConsole(mapWidth, mapHeight);
            Messages    = new RLConsole(messageWidth, messageHeight);
            Stats       = new RLConsole(statWidth, statHeight);
            QuickBar    = new RLConsole(quickbarWidth, quickbarHeight);

            SchedulingSystem = new ActionScheduling();

            MapGenerator mapGenerator = new MapGenerator(mapWidth, mapHeight, 20, 13, 7, mapLevel);

            DungeonMap = mapGenerator.CreateMap(mapConsole);
            DungeonMap.UpdatePlayerFieldOfView();

            CommandSystem = new CommandSystem();

            // Create a new MessageLog and print the random seed used to generate the level
            MessageLog = new MessageLog();
            MessageLog.Add("The rogue arrives on level 1");
            MessageLog.Add($"Level created with seed '{seed}'");

            // PlayerInventory keeps player's equipment and prints its content onto the QuickBar
            //PlayerInventory = new PlayerInventory();

            PlaceConsoles();

            rootConsole.Render += OnRootConsoleUpdate;
            rootConsole.Render += OnRootConsoleRender;


            rootConsole.Run();
        }
Ejemplo n.º 31
0
 /// <summary>
 /// For the given chunk's topsoil blocks, ask each decorator (tree, bush, etc)
 /// to decorate here. Of course, the decorator ultimately decides if it wants to 
 /// be here or not.
 /// </summary>
 /// <param name="chunk"></param>
 public void GenerateDecorationsForChunk(Chunk chunk)
 {
     if (chunk.IsOnTheBorder)
     {
         return;
     }
     IRandom random = new DotNetRandom();
     try
     {
         foreach (Vector3i topSoilBlock in chunk.TopSoilBlocks)
         {
             foreach (IDecoration decoration in m_Decorations)
             {
                 // This passes in the LOCAL map block coordinate for the topsoil block
                 // we are considering for decoration.
                 if (decoration.Decorate(chunk, topSoilBlock - m_WorldData.MapBlockOffset, random))
                 {
                     continue;
                 }
             }
         }
     }
     catch (Exception e)
     {
         Debug.Log("Exception decorating " + e.Message  + "\r\n\r\n" + e.StackTrace);
     }
 }