public void CutDown(IForest forest, ITree tree) { switch (tree.Age) { case TreeAge.Tree: forest.Lumber += 1; forest.Remove(tree); break; case TreeAge.ElderTree: forest.Lumber += 2; forest.Remove(tree); break; } }
public void Tick() { Month++; foreach (var forestObject in Forest.ForestObjects.ToList()) { forestObject.Tick(Forest); } if (Month % 12 == 0) { var lumberCount = Forest.Lumber; if (lumberCount < Forest.LumberJacks.Count) { if (Forest.LumberJacks.Count > 1) { Forest.Remove(Forest.LumberJacks[_numberGeneratorService.GetNextRandomOfBound(Forest.LumberJacks.Count)]); } } else if (lumberCount >= Forest.LumberJacks.Count) { GenerateLumberJacksFor(lumberCount); } if (Forest.Maulings == PreviousYearsMaulingCount) { Forest.GenerateBear(); } else if (PreviousYearsMaulingCount < Forest.Maulings) { if (Forest.Bears.Count > 0) { Forest.Remove(Forest.Bears[_numberGeneratorService.GetNextRandomOfBound(Forest.Bears.Count)]); } } } if (Month <= 12) { return; } Year++; Month = 1; PreviousYearsMaulingCount = Forest.Maulings - AllPreviousYearsMaulings; AllPreviousYearsMaulings += PreviousYearsMaulingCount; Forest.Lumber = 0; }
public void Maul(IForest forest, ILumberJack lumberJack) { forest.Maulings += 1; forest.Remove(lumberJack); }