コード例 #1
0
ファイル: RogueBase.cs プロジェクト: vrum/roguelike
        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));
            }
        }
コード例 #2
0
ファイル: RogueBase.cs プロジェクト: Sinellil/roguelike-cs
        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));
            }
        }
コード例 #3
0
ファイル: DungeonMaker.cs プロジェクト: Sinellil/roguelike-cs
        private void SpawnPrinceItems(int budgetScale)
        {
            int dungeonID = 6;

            int dungeonStartLevel = Game.Dungeon.DungeonInfo.GetDungeonStartLevel(dungeonID);
            int dungeonEndLevel = Game.Dungeon.DungeonInfo.GetDungeonEndLevel(dungeonID);

            int totalPotions = 1 + Game.Random.Next(3);
            /*
            //bonus potions for the dragon level
            for (int j = 0; j < totalPotions; j++)
            {
                int randomChance = Game.Random.Next(100);

                Item potion;

                if (randomChance < 50)
                    potion = new Items.Potion();
                else
                    potion = new Items.PotionMPRestore();

                PlaceItemOnLevel(potion, dungeonEndLevel, 0);
            }*/

            for (int i = dungeonStartLevel; i <= dungeonEndLevel; i++)
            {

                //Spawn bonus potions

                totalPotions = 2 + Game.Random.Next(4);

                for (int j = 0; j < totalPotions; j++)
                {
                    int randomChance = Game.Random.Next(100);

                    Item potion;

                    if (randomChance < 25)
                        potion = new Items.PotionSpeedUp();
                    else if(randomChance < 50)
                        potion = new Items.PotionSightUp();
                    else if(randomChance < 75)
                        potion = new Items.PotionToHitUp();
                    else
                        potion = new Items.PotionDamUp();

                    PlaceItemOnLevel(potion, i, 50);
                }

                //Spawn restore / heal potions

                totalPotions = 1 + Game.Random.Next(3);

                for (int j = 0; j < totalPotions; j++)
                {
                    int randomChance = Game.Random.Next(100);

                    Item potion;

                    if (randomChance < 50)
                        potion = new Items.Potion();
                    else
                        potion = new Items.PotionMPRestore();

                    PlaceItemOnLevel(potion, i, 50);
                }
            }
        }
コード例 #4
0
ファイル: DungeonMaker.cs プロジェクト: Sinellil/roguelike-cs
        private void SpawnWaterCaveItems(int budgetScale)
        {
            int dungeonID = 1;

            int dungeonStartLevel = Game.Dungeon.DungeonInfo.GetDungeonStartLevel(dungeonID);
            int dungeonEndLevel = Game.Dungeon.DungeonInfo.GetDungeonEndLevel(dungeonID);

            for (int i = dungeonStartLevel; i <= dungeonEndLevel; i++)
            {

                //Spawn bonus potions

                int totalPotions = 1 + Game.Random.Next(3);

                for (int j = 0; j < totalPotions; j++)
                {
                    int randomChance = Game.Random.Next(100);

                    Item potion;

                    if (randomChance < 50)
                        potion = new Items.PotionSpeedUp();
                    else
                        potion = new Items.PotionSightUp();

                    PlaceItemOnLevel(potion, i, 50);
                }

                //Spawn restore / heal potions

                totalPotions = 1 + Game.Random.Next(3);

                for (int j = 0; j < totalPotions; j++)
                {
                    int randomChance = Game.Random.Next(100);

                    Item potion;

                    if (randomChance < 50)
                        potion = new Items.Potion();
                    else
                        potion = new Items.PotionMPRestore();

                    PlaceItemOnLevel(potion, i, 50);
                }
            }
        }
コード例 #5
0
ファイル: DungeonMaker.cs プロジェクト: Sinellil/roguelike-cs
        private void SpawnOrcItems(int budgetScale)
        {
            int dungeonID = 3;

            int dungeonStartLevel = Game.Dungeon.DungeonInfo.GetDungeonStartLevel(dungeonID);
            int dungeonEndLevel = Game.Dungeon.DungeonInfo.GetDungeonEndLevel(dungeonID);

            for (int i = dungeonStartLevel; i <= dungeonEndLevel; i++)
            {
                int totalPotions = Game.Random.Next(3);

                for (int j = 0; j < totalPotions; j++)
                {
                    int randomChance = Game.Random.Next(100);

                    Item potion;

                    if (randomChance < 10)
                        potion = new Items.Potion();
                    else if (randomChance < 20)
                        potion = new Items.PotionMPRestore();
                    else if (randomChance < 60)
                        potion = new Items.PotionDamUp();
                    else
                        potion = new Items.PotionToHitUp();

                    PlaceItemOnLevel(potion, i, 50);
                }

                totalPotions = Game.Random.Next(3);

                for (int j = 0; j < totalPotions; j++)
                {
                    int randomChance = Game.Random.Next(2);

                    Item potion;

                        potion = new Items.PotionMPRestore();

                    PlaceItemOnLevel(potion, i, 50);
                }
            }
        }