public void Initiate() { // starts the beginning situation of the game // create the buildings Buildings.Add(new House(new Location(100, 100), "house")); Buildings.Add(new Warehouse(new Location(300, 300), "warehouse")); Buildings.Add(new ResourceHub(new Location(100, 300), "resources", 9999999)); // add roadpoints to them Buildings[0].AddRoadpoint(new Location(200, 200)); Buildings[1].AddRoadpoint(Buildings[0].Roadpoint.BeginLocation); Buildings[2].AddRoadpoint(Buildings[0].Roadpoint.BeginLocation); // put a dude in the building's spawn Dude dude = new Dude(1, Buildings[0].Spawn.Location); Buildings[0].EnterBuilding(dude); Dudes.Add(dude); EndGame = false; // initiate a thread with the gameloop. This separates the GUI thread with the code thread. threads.Add(new Thread(PerformDudePrio)); // makes all the dudes perform their prioritary task threads.Add(new Thread(KeepRoadsUpdated)); // makes sure that roads get generated when new buildings pop up threads[0].Start(); // start managing the dudes } //
private void Load() { string[] comrads = File.ReadAllLines(Path.Combine(path, "dudes.csv")); foreach (var comrad in comrads) { string[] dudestring = comrad.Split(';'); Dudes.Add(new Dude(dudestring[0], dudestring[1], int.Parse(dudestring[2]), DateTime.Parse(dudestring[3]))); } }
// ------------------------------------- private void Add() { Dudes.Add(new Dude(Firstname, Lastname, Ssn, Birthdate)); ReinitializeProperties(); }