public void InitializeForest() { var totalSpots = (Bound * Bound); var initialLumberJackCount = totalSpots * .1; for (var i = 0; i < initialLumberJackCount; i++) { GenerateLumberJack(); } var initialTreeCount = totalSpots * .5; for (var i = 0; i < initialTreeCount; i++) { var assigned = false; while (!assigned) { var desiredX = _numberGeneratorService.GetNextRandomOfBound(Bound); var desiredY = _numberGeneratorService.GetNextRandomOfBound(Bound); if (IsOpenSpot(desiredX, desiredY)) { assigned = true; ForestObjects.Add(new Tree(desiredX, desiredY, new SaplingGeneratorService(), TreeAge.Tree, _numberGeneratorService)); } } } var initialBearCount = totalSpots * .02; for (var i = 0; i < initialBearCount; i++) { GenerateBear(); } }
public void GenerateLumberJack() { var assigned = false; while (!assigned) { var desiredX = _numberGeneratorService.GetNextRandomOfBound(Bound); var desiredY = _numberGeneratorService.GetNextRandomOfBound(Bound); if (IsOpenSpot(desiredX, desiredY)) { ForestObjects.Add(new LumberJack(desiredX, desiredY, _numberGeneratorService)); assigned = true; } } }
public void AddForestObject(IForestObject forestObject) { ForestObjects.Add(forestObject); }
public void Remove(IForestObject forestObject) { ForestObjects.Remove(forestObject); }
public List <IForestObject> GridContents(int x, int y) { return(ForestObjects.Where(o => o.Location.X == x && o.Location.Y == y).ToList()); }
public Boolean IsOpenSpot(int desiredX, int desiredY) { return(!ForestObjects.Any(o => o.Location.X == desiredX && o.Location.Y == desiredY)); }