Exemple #1
0
        public static WorldInstance GenerateDungeon(string name, int size, int levels, params string[] dungeonTypes)
        {
            DungeonInteriorGenerator interiorGenerator = new DungeonInteriorGenerator();
            SpawnPointPlacer         spawnPointPlacer  = new SpawnPointPlacer();

            List <string> entitiesToPlace = new List <string>();

            if (dungeonTypes != null)
            {
                entitiesToPlace.AddRange(dungeonTypes);
            }

            WorldInstance root    = null;
            WorldInstance current = null;

            for (int i = 1; i <= levels; i++)
            {
                WorldTile[,] tiles = interiorGenerator.GenerateWorldSpace(size);
                WorldInstance worldInstance = new WorldInstance(tiles, WorldType.Interior, name + " " + i);

                List <JoyObject> walls = interiorGenerator.GenerateWalls(tiles);
                foreach (JoyObject wall in walls)
                {
                    worldInstance.AddObject(wall);
                }

                List <ItemInstance> items = DungeonItemPlacer.PlaceItems(worldInstance);
                foreach (ItemInstance item in items)
                {
                    worldInstance.AddObject(item);
                }

                List <Entity> entities = DungeonEntityPlacer.PlaceEntities(worldInstance, entitiesToPlace);
                foreach (Entity entity in entities)
                {
                    worldInstance.AddEntity(entity);
                }

                //Do the spawn points
                worldInstance.SpawnPoint = spawnPointPlacer.PlaceSpawnPoint(worldInstance);

                //Use this as our root if we don't have one
                if (root == null)
                {
                    root = worldInstance;
                }

                //Link to the previous floor
                if (current != null)
                {
                    current.AddArea(worldInstance.SpawnPoint, worldInstance);
                }
                current = worldInstance;
            }

            return(root);
        }
Exemple #2
0
        private void CreateWorld()
        {
            //Make a new overworld generator
            OverworldGenerator overworldGen = new OverworldGenerator();

            //Generate the basic overworld
            m_World = new WorldInstance(overworldGen.GenerateWorldSpace(WORLD_SIZE), WorldType.Overworld, "Everse");

            //Set the date and time for 1/1/1555, 12:00pm
            m_World.SetDateTime(new DateTime(1555, 1, 1, 12, 0, 0));

            //Do the spawn point
            SpawnPointPlacer spawnPlacer = new SpawnPointPlacer();
            Vector2Int       spawnPoint  = spawnPlacer.PlaceSpawnPoint(m_World);

            while ((spawnPoint.x == -1 && spawnPoint.y == -1))
            {
                spawnPoint = spawnPlacer.PlaceSpawnPoint(m_World);
            }
            m_World.SpawnPoint = spawnPoint;

            //Set up the player
            m_Player.Move(m_World.SpawnPoint);
            m_Player.MyWorld = m_World;
            m_World.AddEntity(m_Player);

            //Begin the first floor of the Naga Pits
            List <string> dungeonTypes = new List <string>();

            dungeonTypes.Add("Naga");
            dungeonTypes.Add("Dungeon Slime");

            WorldInstance dungeon = DungeonGenerator.GenerateDungeon("Naga Pits", WORLD_SIZE, 3, dungeonTypes.ToArray());

            Vector2Int transitionPoint = spawnPlacer.PlaceTransitionPoint(m_World);

            m_World.AddArea(transitionPoint, dungeon);
            Done = true;

            m_Player.AddItem(new ItemInstance(ItemHandler.GetSpecificItem("Lantern"), new Vector2Int(-1, -1), true));
            m_World.Tick();
        }
Exemple #3
0
        public WorldInstance GenerateDungeon(
            WorldInfo.WorldInfo worldInfo,
            int size,
            int levels,
            IGameManager gameManager,
            RNG roller)
        {
            DungeonInteriorGenerator interiorGenerator = new DungeonInteriorGenerator(
                gameManager.GUIDManager,
                gameManager.ObjectIconHandler,
                gameManager.DerivedValueHandler,
                gameManager.WorldInfoHandler,
                roller);
            SpawnPointPlacer  spawnPointPlacer = new SpawnPointPlacer(roller);
            DungeonItemPlacer itemPlacer       = new DungeonItemPlacer(
                gameManager.ItemHandler,
                roller,
                gameManager.ItemFactory);

            DungeonEntityPlacer entityPlacer = new DungeonEntityPlacer(
                gameManager.EntityHandler,
                gameManager.CultureHandler,
                gameManager.EntityTemplateHandler,
                gameManager.PhysicsManager,
                gameManager.EntityFactory);

            List <string> entitiesToPlace = new List <string>(worldInfo.inhabitants);
            List <string> cultures        = new List <string>(worldInfo.cultures);

            WorldInstance root    = null;
            WorldInstance current = null;

            for (int i = 1; i <= levels; i++)
            {
                WorldTile[,] tiles = interiorGenerator.GenerateWorldSpace(size, worldInfo.name);
                HashSet <Vector2Int> walls         = interiorGenerator.GenerateWalls(tiles);
                WorldInstance        worldInstance = new WorldInstance(
                    tiles,
                    worldInfo.tags,
                    worldInfo.name + " " + i,
                    gameManager.EntityHandler,
                    roller);
                foreach (Vector2Int wall in walls)
                {
                    worldInstance.AddWall(wall);
                }

                List <IItemInstance> items = itemPlacer.PlaceItems(worldInstance);

                IEnumerable <IEntity> entities = entityPlacer.PlaceEntities(
                    worldInstance,
                    cultures,
                    entitiesToPlace,
                    roller);

                foreach (IEntity entity in entities)
                {
                    worldInstance.AddEntity(entity);
                }

                //Do the spawn points
                worldInstance.SpawnPoint = spawnPointPlacer.PlaceSpawnPoint(worldInstance);

                //Use this as our root if we don't have one
                if (root == null)
                {
                    root = worldInstance;
                }

                //Link to the previous floor
                if (current != null)
                {
                    current.AddArea(spawnPointPlacer.PlaceTransitionPoint(current), worldInstance);
                }
                current = worldInstance;
            }

            return(root);
        }