コード例 #1
0
ファイル: Pop.cs プロジェクト: Gibibit/PlanetSimulation
 /// <summary>
 /// Processes food digestion timers and poop fertility
 /// <para>O(num food types)</para>
 /// </summary>
 private void DigestFood()
 {
     _digestionTimers = _digestionTimers.Select(d => d - 1).ToList();
     _digestionTimers.Where(d => d == 0).ToList().ForEach(d =>
     {
         Planet.AddFertility(Position, Planet.Config.PopPoopFertility);
         Planet.TrySeedBushCross(Position);
     });
     _digestionTimers.RemoveAll(d => d <= 0);
 }
コード例 #2
0
        public void Step()
        {
            Age++;

            if (Age <= Planet.Config.BushMaxGrowAge && Grown && _random.NextFloat() < Planet.Config.BushBerryGrowChance)
            {
                var fertileTiles = Planet.GetCross(Position)
                                   .Where(p => Planet.IsInBounds(p) && Planet.GetFertility(p) >= Planet.Config.BushBerryGrowCost).ToList();

                if (fertileTiles.Count > 0 && Planet.SpendFertility(_random.Choose <Point>(fertileTiles), Planet.Config.BushBerryGrowCost))
                {
                    Berries++;
                }
                if (Berries > Planet.Config.BushMaxBerries)
                {
                    Berries = Planet.Config.BushMaxBerries;
                    Planet.TrySeedBushCross(Position);
                }
            }
        }