예제 #1
0
        // Creating the final level of the game
        // Killing the final boss will end the game
        // So there is no need to create stairs down
        public DungeonMap CreateFinalLevel(SchedulingSystem schedule)
        {
            map.Initialize(width, height);
            Rectangle playerSpawn = new Rectangle(10, height / 2 - 5, 8, 8);
            Rectangle bossSpawn   = new Rectangle(width / 2, 0, width / 2 - 1, height - 2);

            List <ICell> playerRoom = new List <ICell>();
            List <ICell> bossRoom   = new List <ICell>();

            for (int i = playerSpawn.X; i < playerSpawn.X + playerSpawn.Width; i++)
            {
                for (int j = playerSpawn.Y; j < playerSpawn.Y + playerSpawn.Height; j++)
                {
                    map.SetCellProperties(i, j, true, true, false);
                    playerRoom.Add(map.GetCell(i, j));
                }
            }

            for (int i = bossSpawn.X; i < bossSpawn.X + bossSpawn.Width; i++)
            {
                for (int j = bossSpawn.Y; j < bossSpawn.Y + bossSpawn.Height; j++)
                {
                    map.SetCellProperties(i, j, true, true, false);
                    bossRoom.Add(map.GetCell(i, j));
                }
            }

            for (int i = playerSpawn.Center.X; i < bossSpawn.Center.X; i++)
            {
                map.SetCellProperties(i, playerSpawn.Center.Y, true, true, false);
            }
            map.Rooms.Add(playerRoom);
            map.Rooms.Add(bossRoom);
            PlacePlayer();

            var dragon = Dragon.Create(1);

            dragon.X = bossSpawn.Center.X;
            dragon.Y = bossSpawn.Center.Y;

            map.AddMonster(dragon);
            CreateStairs();
            // Setting the second stairs at 0,0 to avoid exception
            map.StairsDown.X = map.StairsDown.Y = 0;
            return(map);
        }
        public static Monster CreateMonster(int level, Point location)
        {
            Pool <Monster> monsterPool = new Pool <Monster>();

            if (level <= 2)
            {
                monsterPool.Add(Rat.Create(level), 20);
                monsterPool.Add(Lichen.Create(level), 30);
                monsterPool.Add(Jackal.Create(level), 25);
                monsterPool.Add(Kobold.Create(level), 25);
            }
            else if (level <= 4)
            {
                monsterPool.Add(Lichen.Create(level), 15);
                monsterPool.Add(Rat.Create(level), 16);
                monsterPool.Add(Jackal.Create(level), 25);
                monsterPool.Add(Kobold.Create(level), 25);
                monsterPool.Add(Goblin.Create(level), 15);
                monsterPool.Add(Sludge.Create(level), 3);
                monsterPool.Add(Wolf.Create(level), 1);
            }
            else if (level <= 6)
            {
                monsterPool.Add(Jackal.Create(level), 5);
                monsterPool.Add(Wolf.Create(level), 10);
                monsterPool.Add(Kobold.Create(level), 15);
                monsterPool.Add(Goblin.Create(level), 30);
                monsterPool.Add(Sludge.Create(level), 25);
                monsterPool.Add(Gnoll.Create(level), 5);
                monsterPool.Add(Viper.Create(level), 10);
            }
            else if (level <= 8)
            {
                monsterPool.Add(Goblin.Create(level), 8);
                monsterPool.Add(Slime.Create(level), 15);
                monsterPool.Add(Viper.Create(level), 8);
                monsterPool.Add(Wolf.Create(level), 20);
                monsterPool.Add(Gnoll.Create(level), 25);
                monsterPool.Add(LizardMan.Create(level), 10);
                monsterPool.Add(Werewolf.Create(level), 4);
            }
            else if (level <= 10)
            {
                monsterPool.Add(Ogre.Create(level), 10);
                monsterPool.Add(Gnoll.Create(level), 10);
                monsterPool.Add(Werewolf.Create(level), 20);
                monsterPool.Add(LizardMan.Create(level), 30);
                monsterPool.Add(Orc.Create(level), 20);
                monsterPool.Add(Dragon.Create(level), 10);
            }
            else
            {
                monsterPool.Add(Werewolf.Create(level), 20);
                monsterPool.Add(Ogre.Create(level), 20);
                monsterPool.Add(LizardMan.Create(level), 20);
                monsterPool.Add(Orc.Create(level), 20);
                monsterPool.Add(Dragon.Create(level), 30);
            }

            Monster monster = monsterPool.Get();

            monster.X = location.X;
            monster.Y = location.Y;

            return(monster);
        }