static InstitutionManager() { institutionList = new List <Institution>(); constructionCompanyList = new List <ConstructionCompany>(); institutionTypeList = File.ReadAllLines(Directory.GetCurrentDirectory() + "/Assets/Codes/Institution/InstitutionData/institutionTypes.txt"); string[] colorStr = File.ReadAllLines(Directory.GetCurrentDirectory() + "/Assets/Codes/Institution/InstitutionData/institutionColorMap.txt"); colorMap = new Dictionary <string, Color>(); foreach (var line in colorStr) { String[] str = line.Split('|'); Color color = new Color32(Convert.ToByte(str[1]), Convert.ToByte(str[2]), Convert.ToByte(str[3]), 255); colorMap[str[0]] = color; } InstitutionDictionary = new Dictionary <string, List <Institution> >(); // hard-codly assign one initial construction company ConstructionCompany cons = new ConstructionCompany(Person.generateRandomPerson(), new Plot(0, 0), "ConstructionCompany", false); constructionCompanyList.Add(cons); institutionList.Add(cons); // add one school initially ////School school = new School(Person.generateRandomPerson(), new Plot(0, 1), "School"); ////institutionList.Add(school); GeneratorInstitution(Person.generateRandomPerson(), "School", new Plot(0, 1)); //initial apt complex GeneratorInstitution(Person.generateRandomPerson(), "ApartmentComplex", new Plot(0, 2)); }
// generate a new institution public static Institution GeneratorInstitution(Person owner, String type, Plot location) { // string type = GetRandomType(); Institution newInstitution; switch (type) { case "ConstructionCompany": newInstitution = new ConstructionCompany(owner, location, type); break; case "School": newInstitution = new School(owner, location, type); break; case "Hospital": newInstitution = new Hospital(owner, location, type); break; case "LawFirm": newInstitution = new LawFirm(owner, location, type); break; case "ApartmentComplex": newInstitution = new ApartmentComplex(owner, location, type); break; default: newInstitution = new Institution(owner, location, type); break; } if (newInstitution.getType().Equals("ConstructionCompany")) { constructionCompanyList.Add(newInstitution as ConstructionCompany); } institutionList.Add(newInstitution); if (InstitutionDictionary.ContainsKey(type)) { List <Institution> tempList = InstitutionDictionary[type]; tempList.Add(newInstitution); } else { InstitutionDictionary[type] = new List <Institution> { newInstitution }; } Logger.Log("Institution", type, owner.name, "(" + location.x_pos + "," + location.y_pos + ")"); return(newInstitution); }