Beispiel #1
0
        private void SetupDungeon()
        {
            //Create dungeon and set it as current in Game
            dungeon = new Dungeon();
            Game.Dungeon = dungeon;

            //Randomer
            Random rand = new Random();

            //Create dungeon map (at least level 1)
            MapGeneratorBSP mapGen1 = new MapGeneratorBSP();
            //MapGeneratorRogue mapGen = new MapGeneratorRogue();
            mapGen1.Width = 80;
            mapGen1.Height = 25;
            int extraCorridors = rand.Next(10);

            Map level1 = mapGen1.GenerateMap(extraCorridors);

            MapGeneratorBSP mapGen2 = new MapGeneratorBSP();
            mapGen2.Width = 80;
            mapGen2.Height = 25;
            Map level2 = mapGen2.GenerateMap(extraCorridors);

            MapGeneratorCave cave1 = new MapGeneratorCave();
            cave1.Width = 80;
            cave1.Height = 25;

            Map cave = cave1.GenerateMap();

            //KeyPress userKey = Keyboard.WaitForKeyPress(true);

            //Test
            //for (int i = 0; i < 10000; i++)
            //{
            //    mapGen.GenerateMap();
            //}

            //Give map to dungeon
            dungeon.AddMap(level1); //level 1
            //dungeon.AddMap(level2); //level 2

            int caveLevel = dungeon.AddMap(cave);
            cave1.AddStaircases(caveLevel);

            //Load level 3 from file
            try
            {
                MapGeneratorFromASCIIFile mapGen3 = new MapGeneratorFromASCIIFile();
                mapGen3.LoadASCIIFile("test1.txt");
                mapGen3.AddMapToDungeon();
            }
            catch (Exception ex)
            {
                MessageBox.Show("failed to add level 3: " + ex.Message);
            }
            //Setup PC
            Player player = dungeon.Player;

            player.Representation = '@';
            player.LocationMap = level1.PCStartLocation;

            player.Hitpoints = 100;
            player.MaxHitpoints = 100;

            //Give the player some items
            //player.PickUpItem(new Items.Potion());

            //Add a down staircase where the player is standing
            AddFeatureToDungeon(new Features.StaircaseDown(), 0, new Point(player.LocationMap.x, player.LocationMap.y));

            //Add a test short sword
            dungeon.AddItem(new Items.ShortSword(), 0, new Point(player.LocationMap.x, player.LocationMap.y));

            //Create creatures and start positions

            //Add some random creatures

            int noCreatures = rand.Next(10) + 215;

            for (int i = 0; i < noCreatures; i++)
            {
                Monster creature = new Creatures.Rat();
                creature.Representation = Convert.ToChar(65 + rand.Next(26));

                //int level = rand.Next(2);
                int level = 0;
                Point location = new Point(0, 0);

                //Loop until we find an acceptable location and the add works
                do
                {
                    if (level == 0)
                        location = mapGen1.RandomWalkablePoint();
                    else if (level == 1)
                        location = mapGen2.RandomWalkablePoint();
                    LogFile.Log.LogEntryDebug("Creature " + i.ToString() + " pos x: " + location.x + " y: " + location.y, LogDebugLevel.Low);
                }
                while (!dungeon.AddMonster(creature, level, location));
            }

            //Create features

            //Add some random features
            /*
            int noFeatures = rand.Next(5) + 2;

            for (int i = 0; i < noFeatures; i++)
            {
                Features.StaircaseUp feature = new Features.StaircaseUp();

                feature.Representation = Convert.ToChar(58 + rand.Next(6));
                AddFeatureToDungeon(feature, mapGen1, 0);
            }*/

            //Add staircases to dungeons level 1 and 2
            AddFeatureToDungeonRandomPoint(new Features.StaircaseDown(), mapGen1, 0);
            //AddFeatureToDungeonRandomPoint(new Features.StaircaseUp(), mapGen2, 1);

            //Create objects and start positions

            //Add some random objects

            int noItems = rand.Next(10) + 5;

            for (int i = 0; i < noItems; i++)
            {
                Item item;

                if (rand.Next(2) < 1)
                {
                    item = new Items.Potion();
                }
                else
                {
                    item = new Items.ShortSword();
                }

                //item.Representation = Convert.ToChar(33 + rand.Next(12));

                int level = 0;
                Point location;

                //Loop until we find an acceptable location and the add works
                do
                {
                    location = mapGen1.RandomWalkablePoint();
                }
                while (!dungeon.AddItem(item, level, location));
            }
        }
Beispiel #2
0
        private void SetupDungeon()
        {
            //Create dungeon and set it as current in Game
            dungeon      = new Dungeon();
            Game.Dungeon = dungeon;

            //Randomer
            Random rand = new Random();

            //Create dungeon map (at least level 1)
            MapGeneratorBSP mapGen1 = new MapGeneratorBSP();

            //MapGeneratorRogue mapGen = new MapGeneratorRogue();
            mapGen1.Width  = 80;
            mapGen1.Height = 25;
            int extraCorridors = rand.Next(10);

            Map level1 = mapGen1.GenerateMap(extraCorridors);

            MapGeneratorBSP mapGen2 = new MapGeneratorBSP();

            mapGen2.Width  = 80;
            mapGen2.Height = 25;
            Map level2 = mapGen2.GenerateMap(extraCorridors);

            MapGeneratorCave cave1 = new MapGeneratorCave();

            cave1.Width  = 80;
            cave1.Height = 25;

            Map cave = cave1.GenerateMap();


            //KeyPress userKey = Keyboard.WaitForKeyPress(true);


            //Test
            //for (int i = 0; i < 10000; i++)
            //{
            //    mapGen.GenerateMap();
            //}

            //Give map to dungeon
            dungeon.AddMap(level1); //level 1
            //dungeon.AddMap(level2); //level 2

            int caveLevel = dungeon.AddMap(cave);

            cave1.AddStaircases(caveLevel);


            //Load level 3 from file
            try
            {
                MapGeneratorFromASCIIFile mapGen3 = new MapGeneratorFromASCIIFile();
                mapGen3.LoadASCIIFile("test1.txt");
                mapGen3.AddMapToDungeon();
            }
            catch (Exception ex)
            {
                MessageBox.Show("failed to add level 3: " + ex.Message);
            }
            //Setup PC
            Player player = dungeon.Player;

            player.Representation = '@';
            player.LocationMap    = level1.PCStartLocation;

            player.Hitpoints    = 100;
            player.MaxHitpoints = 100;

            //Give the player some items
            //player.PickUpItem(new Items.Potion());

            //Add a down staircase where the player is standing
            AddFeatureToDungeon(new Features.StaircaseDown(), 0, new Point(player.LocationMap.x, player.LocationMap.y));

            //Add a test short sword
            dungeon.AddItem(new Items.ShortSword(), 0, new Point(player.LocationMap.x, player.LocationMap.y));

            //Create creatures and start positions

            //Add some random creatures



            int noCreatures = rand.Next(10) + 215;

            for (int i = 0; i < noCreatures; i++)
            {
                Monster creature = new Creatures.Rat();
                creature.Representation = Convert.ToChar(65 + rand.Next(26));

                //int level = rand.Next(2);
                int   level    = 0;
                Point location = new Point(0, 0);

                //Loop until we find an acceptable location and the add works
                do
                {
                    if (level == 0)
                    {
                        location = mapGen1.RandomWalkablePoint();
                    }
                    else if (level == 1)
                    {
                        location = mapGen2.RandomWalkablePoint();
                    }
                    LogFile.Log.LogEntryDebug("Creature " + i.ToString() + " pos x: " + location.x + " y: " + location.y, LogDebugLevel.Low);
                }while (!dungeon.AddMonster(creature, level, location));
            }

            //Create features

            //Add some random features

            /*
             * int noFeatures = rand.Next(5) + 2;
             *
             * for (int i = 0; i < noFeatures; i++)
             * {
             *  Features.StaircaseUp feature = new Features.StaircaseUp();
             *
             *  feature.Representation = Convert.ToChar(58 + rand.Next(6));
             *  AddFeatureToDungeon(feature, mapGen1, 0);
             * }*/

            //Add staircases to dungeons level 1 and 2
            AddFeatureToDungeonRandomPoint(new Features.StaircaseDown(), mapGen1, 0);
            //AddFeatureToDungeonRandomPoint(new Features.StaircaseUp(), mapGen2, 1);


            //Create objects and start positions

            //Add some random objects

            int noItems = rand.Next(10) + 5;

            for (int i = 0; i < noItems; i++)
            {
                Item item;

                if (rand.Next(2) < 1)
                {
                    item = new Items.Potion();
                }
                else
                {
                    item = new Items.ShortSword();
                }

                //item.Representation = Convert.ToChar(33 + rand.Next(12));

                int   level = 0;
                Point location;

                //Loop until we find an acceptable location and the add works
                do
                {
                    location = mapGen1.RandomWalkablePoint();
                }while (!dungeon.AddItem(item, level, location));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Adds levels and interconnecting staircases
        /// </summary>
        private void SetupMapsFlatline()
        {
            Dungeon dungeon = Game.Dungeon;

            //Levels

            //Set up the maps here. Light levels are set up in SpawnXXXXCreatures methods. These set the dungeons light and the creature sight. Perhaps set light here - TODO

            //Set up the levels. Needs to be done here so the wilderness is initialized properly.

            //Game.Dungeon.DungeonInfo.SetupDungeonStartAndEndDebug();

            //Make the generators

            MapGeneratorCave caveGen = new MapGeneratorCave();

            //Set width height of all maps to 60 / 25
            caveGen.Width = 60;
            caveGen.Height = 25;

            //These need to start from 0 now and be continuous

            List<int> dungeonLevelsToTest = RebuildAllMaps();

            //Place the player, so monster placing can be checked against it
            //Game.Dungeon.Player.LocationLevel = 0; //on reload, don't reset this
            Game.Dungeon.Player.LocationMap = Game.Dungeon.Levels[Game.Dungeon.Player.LocationLevel].PCStartLocation;

            //Place monsters in levels
            SpawnCreaturesFlatline(dungeonLevelsToTest, levelGen, false);

            SpawnItemsFlatline(dungeonLevelsToTest, levelGen, false);

            SpawnObjectivesFlatline(dungeonLevelsToTest, levelGen, false);
        }