public GameTile(GameEnvironment world) { World = world; Plants = new Plant[]{ }; People = new Person[]{ }; Inventory = new Inventory(this, null, world.Context.Settings); }
public bool FellTreeCycle(Person person, Plant plant) { Status = "Chopping down tree " + (int)plant.PercentHarvested + "%"; if (Settings.IsVerbose) Console.WriteDebugLine (" Felling tree"); plant.PercentHarvested += Settings.FellingRate; TotalWoodFelled += Settings.FellingRate; // TODO: Should this be set here or once the tree is finished? if (plant.PercentHarvested > 100) plant.PercentHarvested = 100; if (Settings.OutputType == ConsoleOutputType.Debug) { Console.WriteDebugLine (" " + plant.PercentHarvested + "% felled"); } if (plant.PercentHarvested > 100) { plant.PercentHarvested = 100; } if (plant.PercentHarvested == 100 && Settings.IsVerbose) { Console.WriteDebugLine (" Finished felling tree."); } return plant.PercentHarvested == 100; }
public void AddTrees(Plant[] trees) { var list = new List<Plant> (Plants); list.AddRange (trees); Plants = list.ToArray (); World.AddTrees (trees); foreach (var tree in trees) tree.Tile = this; }
public GameEnvironment(EngineContext context) { Context = context; Populator = new GameEnvironmentPopulator (this); PersonCreator = new PersonCreator (context.Settings); PlantCreator = new PlantCreator (context.Settings); Tiles = new GameTile[]{}; People = new Person[] {}; Plants = new Plant[]{ }; Logic = new GameLogic (); Tiles = new GameTile[]{new GameTile(this)}; }
public void RemovePlant(Plant plant) { var list = new List<Plant> (Plants); list.Remove (plant); Plants = list.ToArray (); }
public Plant GetTreeToFell() { Plant tree = null; if (Target != null) tree = (Plant)Target; else { tree = FindLargeTree (); Target = tree; if (Settings.IsVerbose) { Console.WriteDebugLine (" Cutting down tree"); } } return tree; }
public void FinishedFellingSingleTree(Person person, Plant tree) { Status = "Finished felling tree"; person.Tile.RemovePlant (tree); var amountOfWood = tree.Size; ItemsProduced [ItemType.Wood] = amountOfWood; if (Settings.IsVerbose) { Console.WriteDebugLine (" Wood from tree: " + amountOfWood); Console.WriteDebugLine (" Total wood: " + person.Inventory.Items [ItemType.Wood] + amountOfWood); } Target = null; //if (Context.Settings.PlayerId == person.Id) //Context.Log.WriteLine (String.Format("Player cut a tree down. Age:{0} size:{1} wood:{2}", (int)tree.Age, (int)tree.Size, (int)amountOfWood)); }
public void AddTrees(Plant[] trees) { var list = new List<Plant> (Plants); list.AddRange (trees); Plants = list.ToArray (); }