Пример #1
0
        public override void CreateEntities(Mogwai mogwai, Shift shift)
        {
            mogwai.Reset();
            mogwai.AdventureEntityId = NextId;
            Entities.Add(mogwai.AdventureEntityId, mogwai);

            var adjCr = GetChallengeRating();

            var monsterSet = Monsters.Instance.AllBuilders()
                             .Where(p => (p.EnvironmentTypes.Contains(EnvironmentType.Any) ||
                                          p.EnvironmentTypes.Contains(EnvironmentType.Undergrounds)) &&
                                    p.ChallengeRating <= adjCr).ToList();
            var totXpAmount = 500 * Math.Pow(adjCr, 2);

            var allMonsters = new List <MonsterBuilder>();

            for (var i = 0; i < 100 && totXpAmount > 0; i++)
            {
                var mob = monsterSet[DungeonRandom.Next(monsterSet.Count)];
                allMonsters.Add(mob);
                totXpAmount -= mob.Experience;
            }

            // make sure there are at least 7 mobs in the dungeon
            if (Entities.Count < 7)
            {
                var subMonsterSet = monsterSet.Where(p => p.ChallengeRating <= 0.5).ToList();
                if (subMonsterSet.Count > 0)
                {
                    for (var i = 0; i < 10; i++)
                    {
                        var mob = subMonsterSet[DungeonRandom.Next(subMonsterSet.Count)];
                        allMonsters.Add(mob);
                    }
                }
            }

            var maxCr           = allMonsters.Max(p => p.ChallengeRating);
            var potentialBosses = allMonsters.Where(p => p.ChallengeRating == maxCr).ToList();

            var boss = potentialBosses[DungeonRandom.Next(potentialBosses.Count)].Build();

            boss.AdventureEntityId = NextId;
            boss.Initialize(new Dice(shift, 1));
            Entities.Add(boss.AdventureEntityId, boss);

            var monsterMod = 100;

            foreach (var monsterBuilder in allMonsters)
            {
                var mob = monsterBuilder.Build();
                mob.AdventureEntityId = NextId;
                mob.Initialize(new Dice(shift, monsterMod++));
                Entities.Add(mob.AdventureEntityId, mob);
            }

            // exploration order
            _explorationOrder = EntitiesList.OrderBy(p => p.Inteligence).ThenBy(p => p.SizeType).ToList();
        }
Пример #2
0
        public override void CreateEntities(Mogwai mogwai, Shift shift)
        {
            mogwai.Reset();
            mogwai.AdventureEntityId = NextId;
            Entities.Add(mogwai.AdventureEntityId, mogwai);

            var adjCr = GetChallengeRating();

            //var monsterSet = Monsters.Instance.AllBuilders()
            //    .Where(p => (p.EnvironmentTypes.Contains(EnvironmentType.Any)
            //              || p.EnvironmentTypes.Contains(EnvironmentType.Undergrounds))
            //                && p.ChallengeRating <= adjCr).ToList();

            // TODO work here again and replace it with a real algorithm or make it dungeon dependend.
            var monsterSet = new List <MonsterBuilder>()
            {
                IceCave.BunnyRat,
                IceCave.BearWarrior,
                IceCave.CrystalGuardian,
                IceCave.GoblinFrost,
                IceCave.GoblinMage,
                IceCave.GoblinTorch,
                IceCave.GoblinVenom,
                IceCave.ThreeTailedWolf,
                IceCave.SnowMonster
            };

            var totXpAmount = 500 * Math.Pow(adjCr, 2);

            var allMonsters = new List <MonsterBuilder>();

            for (var i = 0; i < 100 && totXpAmount > 0; i++)
            {
                MonsterBuilder mob = monsterSet[DungeonRandom.Next(monsterSet.Count)];
                allMonsters.Add(mob);
                totXpAmount -= mob.Experience;
            }

            // make sure there are at least 7 mobs in the dungeon
            if (allMonsters.Count < 7)
            {
                var subMonsterSet = monsterSet.Where(p => p.ChallengeRating <= 0.5).ToList();
                if (subMonsterSet.Count > 0)
                {
                    for (var i = 0; i < 10; i++)
                    {
                        MonsterBuilder mob = subMonsterSet[DungeonRandom.Next(subMonsterSet.Count)];
                        allMonsters.Add(mob);
                    }
                }
            }

            var maxCr           = allMonsters.Max(p => p.ChallengeRating);
            var potentialBosses = allMonsters.Where(p => p.ChallengeRating == maxCr).ToList();

            Monster boss = potentialBosses[DungeonRandom.Next(potentialBosses.Count)].Build();

            boss.AdventureEntityId = NextId;
            boss.Initialize(new Dice(shift, 1));
            Entities.Add(boss.AdventureEntityId, boss);
            BossKeys.Add(boss.AdventureEntityId);

            var monsterMod = 100;

            foreach (MonsterBuilder monsterBuilder in allMonsters)
            {
                Monster mob = monsterBuilder.Build();
                mob.AdventureEntityId = NextId;
                mob.Initialize(new Dice(shift, monsterMod++));
                Entities.Add(mob.AdventureEntityId, mob);
            }

            // exploration order
            _explorationOrder = EntitiesList.OrderBy(p => p.Intelligence).ThenBy(p => p.SizeType).ToList();
        }