Esempio n. 1
0
 void CreateChampionGroup(IEnumerable <Coord> locations, D2Enemy enemy)
 {
     foreach (Coord coord in locations)
     {
         factory.BuildChampion(coord, enemy.Prefab);
     }
 }
Esempio n. 2
0
        void CreateEliteGroup(IEnumerable <Coord> locations, D2Enemy enemy)
        {
            Coord      leaderLocation = locations.First();
            GameObject leader         = factory.BuildEliteLeader(leaderLocation, enemy.Prefab);

            foreach (Coord coord in locations.Skip(1))
            {
                factory.BuildEliteMinion(leader, coord, enemy.MinionPrefab);
            }
        }
Esempio n. 3
0
        public void PlaceEncounters(IEnumerable <Coord> locations, D2Enemy[] enemies, float champProb, float eliteProb)
        {
            var encounterLocations = new List <Coord>(offsets.Length);

            foreach (Coord position in locations)
            {
                encounterLocations.Clear();

                D2Enemy     enemy         = enemies[random.Next(0, enemies.Length)];
                double      enemyTypeRoll = random.NextDouble();
                int         numEnemies;
                D2EnemyType type;
                if (enemyTypeRoll < eliteProb)
                {
                    numEnemies = enemy.GetRandomMinionCount(random);
                    type       = D2EnemyType.Elite;
                }
                else if (enemyTypeRoll < champProb + eliteProb)
                {
                    numEnemies = enemy.GetRandomMinionCount(random);
                    type       = D2EnemyType.Champion;
                }
                else
                {
                    numEnemies = enemy.GetRandomGroupSize(random);
                    type       = D2EnemyType.Basic;
                }

                foreach (Coord offset in offsets)
                {
                    Coord coord = position + offset;
                    if (!occupied.Contains(coord) && !map.IsWallOrVoid(coord))
                    {
                        encounterLocations.Add(coord);
                    }
                }

                if (encounterLocations.Count > 0)
                {
                    encounterLocations = encounterLocations.Take(numEnemies).ToList();
                    foreach (Coord coord in encounterLocations)
                    {
                        occupied.Add(coord);
                    }
                    CreateGroup(encounterLocations, enemy, type);
                }
            }
        }
Esempio n. 4
0
        void CreateGroup(IEnumerable <Coord> locations, D2Enemy enemy, D2EnemyType enemyType)
        {
            Assert.IsNotNull(locations);
            Assert.IsNotNull(enemy);
            Assert.IsTrue(locations.Count() > 0);
            switch (enemyType)
            {
            case D2EnemyType.Basic:
                CreateBasicGroup(locations, enemy);
                break;

            case D2EnemyType.Champion:
                CreateChampionGroup(locations, enemy);
                break;

            case D2EnemyType.Elite:
                CreateEliteGroup(locations, enemy);
                break;

            default:
                throw new System.ComponentModel.InvalidEnumArgumentException();
            }
        }