public void DoLastStepOfTownLoaded() { for (int i = 0; i < AllBuilding.Count; i++) { AllBuilding.ElementAt(i).Value.TownBuildingLastStep(); } }
/// <summary> /// Will update Propersties on AllRegFile so when is saved is there to be loaded /// /// Prop that Update so far: /// BookedHome1 /// Instruction /// Families /// Invetory /// PeopleDic /// PositionFilled /// Anchors /// DollarsPay /// Dock1 /// PlantSave1 /// Dispatch /// BuildersManager1 /// CurrentProd /// </summary> public void ResaveOnRegistro(string myIdP) { //for when Building is loading and writing PeopleDict if (!AllBuilding.ContainsKey(myIdP)) { return; } var build = AllBuilding[myIdP]; int index = AllRegFile.FindIndex(a => a.MyId == myIdP); //bz when destroying Way this method is called if (index == -1) { return; } AllRegFile[index].BookedHome1 = build.BookedHome1; AllRegFile[index].Instruction = build.Instruction; AllRegFile[index].Familes = build.Families; AllRegFile[index].Inventory = build.Inventory; AllRegFile[index].PeopleDict = build.PeopleDict; AllRegFile[index].Anchors = build.Anchors.ToArray(); //UVisHelp.CreateHelpers(build.Anchors, Root.yellowCube); AllRegFile[index].DollarsPay = build.DollarsPay; AllRegFile[index].Dock1 = build.Dock1; AllRegFile[index].Dispatch1 = build.Dispatch1; AllRegFile[index].BuildersManager1 = build.BuildersManager1; AllRegFile[index].PlantSave1 = build.PlantSave1; AllRegFile[index].CurrentProd = build.CurrentProd; AllRegFile[index].Name = build.NameBuilding(); }
/// <summary> /// This is used only when loading a town and needs to redo DimOnMap /// </summary> internal void RedoDimAndResaveAllBuildings() { for (int i = 0; i < AllBuilding.Count; i++) { AllRegFile[i].DimOnMap = ReturnDimOnMap(AllBuilding.ElementAt(i).Value.Anchors); ResaveOnRegistro(AllRegFile[i], AllBuilding.ElementAt(i).Value, true); } }
internal List <string> StringOfAllBuildingsHType() { List <string> res = new List <string>(); for (int i = 0; i < AllBuilding.Count; i++) { res.Add(AllBuilding.ElementAt(i).Value.HType + ""); } return(res); }
internal Vector3 AverageOfAllBuildingsNow() { Vector3 sum = new Vector3(); for (int i = 0; i < AllBuilding.Count; i++) { sum += AllBuilding.ElementAt(i).Value.transform.position; } return(sum / AllBuilding.Count); }
internal void DoEquealPaymentForAllWorks() { List <string> res = new List <string>(); for (int i = 0; i < AllBuilding.Count; i++) { if (BuildingWindow.isAWorkBuild(AllBuilding.ElementAt(i).Value)) { AllBuilding.ElementAt(i).Value.DollarsPay = 5; } } }
/// <summary> /// a list string of all the building types that are a work /// </summary> /// <returns></returns> internal List <string> StringOfAllBuildingsThatAreAWork() { List <string> res = new List <string>(); for (int i = 0; i < AllBuilding.Count; i++) { if (BuildingWindow.isAWorkBuild(AllBuilding.ElementAt(i).Value)) { res.Add(AllBuilding.ElementAt(i).Value.HType + ""); } } return(res); }
/// <summary> /// All the positions in all work buildings /// </summary> /// <returns></returns> internal int MaxPositions() { int res = 0; for (int i = 0; i < AllBuilding.Count; i++) { if (BuildingWindow.isAWorkBuild(AllBuilding.ElementAt(i).Value)) { res += AllBuilding.ElementAt(i).Value.MaxPeople; } } return(res); }
/// <summary> /// todo... /// to be used only when loading a brand new Terra Spawner file /// /// if spawnedData is in the closest9 regions will check if needs to remove itself bz /// could fall into a building /// </summary> /// <param name="spawnedData"></param> /// <param name="closest9"></param> internal void MarkTerraIfNeeded(SpawnedData spawnedData, List <RegionD> closest9) { var index = closest9.FindIndex(a => a.Region == spawnedData.Region); if (index == -1) { return; } for (int i = 0; i < AllBuilding.Count; i++) { AllBuilding.ElementAt(i).Value.CheckOnMarkTerra(); } }
public float ReturnYearSalary() { var works = AllBuilding.Where( a => a.Value.MyId.Contains("House") == false && a.Value.MyId.Contains("Storage") == false && a.Value.MyId.Contains("Church") == false && a.Value.MyId.Contains("Tavern") == false).ToList(); if (works.Count == 0) { return(0); } var avg = works.Average(a => a.Value.DollarsPay); var workers = works.Sum(a => a.Value.PeopleDict.Count); return((float)avg * workers); }
/// <summary> /// Created for GC reasons Im not updating the invetory in buildings as changes anymore /// Call when saving a game /// /// Will get the info from all buildings and will update it into AllRegFiles only Prop specified in ResaveOnRegistro() /// are being resaved /// </summary> internal void ResaveAllBuildings() { var error = 0; for (int i = 0; i < AllBuilding.Count; i++) { if (AllBuilding.ElementAt(i).Value.MyId == AllRegFile[i].MyId) { ResaveOnRegistro(AllRegFile[i], AllBuilding.ElementAt(i).Value, false); } //means that somehow are not in sync //this happens only when destroyed a bulding befofre finished built //still on game and save else { error++; var build = AllBuilding.First(a => a.Value.MyId == AllRegFile[i].MyId); ResaveOnRegistro(AllRegFile[i], build.Value, false); } } Debug.Log("Margin error ReSaving: " + error); }
/// <summary> /// Will return the first Structure that cointains param /// /// So if u pass as param 'dock' will try to find the first dock /// </summary> /// <param name="param"></param> /// <returns></returns> public Structure ReturnFirstThatContains(string param) { var list = AllBuilding.ToList(); return((Structure)list.Find(a => a.Value.MyId.Contains(param)).Value); }