Beispiel #1
0
 public AntFactory(Ant antPrefab, Game game)
 {
     this.nestPositionX = game.NestPositionX;
     this.nestPositionY = game.NestPositionY;
     this.nestRadius    = game.NestRadius;
     antDictionary      = new Dictionary <int, Ant>();
     this.antPrefab     = antPrefab.Duplicate();
     this.game          = game;
     game.OnWaveChange += (wave) =>
     {
         if (((wave - 20) % 15) == 0)
         {
             nest.distributionMaps.Sort();
             DistributionMap good_good    = DistributionMap.Evolution(nest.distributionMaps[2], nest.distributionMaps[2]);
             DistributionMap good_middle1 = DistributionMap.Evolution(nest.distributionMaps[2], nest.distributionMaps[1]);
             DistributionMap good_middle2 = DistributionMap.Evolution(nest.distributionMaps[1], nest.distributionMaps[2]);
             nest.distributionMaps[0] = good_good;
             nest.distributionMaps[1] = good_middle1;
             nest.distributionMaps[2] = good_middle2;
         }
         if (wave % 5 == 0)
         {
             nest.distributionMap = nest.distributionMaps[(wave / 5 - 1) % 3];
         }
     };
 }
Beispiel #2
0
        public virtual Ant InstantiateNewAnt()
        {
            totalAntCount++;
            if (totalAntCount % (game.AntNumber + nest.GrowthProperties.population * game.Wave / 20) == 0)
            {
                antPrefab.LevelUp();
                game.Wave += 1;
            }
            Ant    ant             = antPrefab.Duplicate();
            Random randomGenerator = new Random();
            double distance        = game.NestRadius * randomGenerator.NextDouble() * 0.8;
            double rotation        = 360 * randomGenerator.NextDouble();

            ant.UpdateTransform(nestPositionX + (float)(distance * Math.Cos(rotation)), nestPositionY + (float)(distance * Math.Sin(rotation)), (float)rotation);
            antDictionary.Add(ant.ID, ant);
            return(ant);
        }