public void CreateWorld() { Node size = SaveLoadMap.newWorldSize; int szx = size.x; int szy = size.y; Map = new World(size); Map.terrain = mapGenerator.GetRandomTerrain(size); Map.elevation = mapGenerator.GetRandomElevation(size); //Map.elevation = new float[szx, szy]; //until we've successfully placed the map entrance/exit, keep trying bool success = false; do { success = CreateMapEntrance(szx, szy); } while (!success); money.Money = 10000; actionSelecter.FreshActions(); if (notifications != null) { notifications.FreshEvents(); } ProductivityController.CreateProductivities(); ResourcesDatabase.CreateWhitelist(); money.FreshStartingQuarter((int)timeController.CurrentSeason, timeController.CurrentYear); timeController.finances.LoadFinancialReports(); }
public void GenerateWorld() { GameObject worldObj = new GameObject(); worldObj.name = "WorldMap"; //List<GameObject> tiles = new List<GameObject>(); tiles = new GameObject[Map.size.x, Map.size.y]; for (int a = 0; a < Map.size.x; a++) { GameObject row = new GameObject(); row.transform.parent = worldObj.transform; row.name = "Row_" + a; for (int b = 0; b < Map.size.y; b++) { GameObject tile = GenerateTile(a, b, row); tiles[a, b] = tile; } } meshCombiner.CreateTilemapMesh(tiles); //actionSelecter.LoadActionButtons(); actionSelecter.LoadActionEnablers(); ProductivityController.LoadProductivityLists(); ProductivityController.LoadCompetitors(diplomacy.cities); ProductivityController.UpdateProductivities(); immigration.LoadImmigrantData(); WalkerGrid = Map.size.CreateArrayOfSize <List <Walker> > (); }
void Update() { //if (!IsPaused) // Time.timeScale = timescale; TimeDelta += Time.deltaTime; //update label UpdateTimeLabel(); if (TimeDelta >= DayTime) { //convert timedelta to day TimeDelta = 0; Days++; //convert days to week if (Days >= WeekTime) { Days = 0; Weeks++; } //convert weeks to month if (Weeks >= MonthTime) { Weeks = 0; Months++; //research.IterateResearch(); //labor.PayWages(); } //convert months to season if (Months >= SeasonTime) { Months = 0; Seasons++; UpdateClockColor(); if (Seasons < YearTime) { money.BeginNewQuarter(Seasons, CurrentYear); } finances.LoadFinancialReports(); ProductivityController.UpdateProductivities(); } //convert seasons to year if (Seasons >= YearTime) { Seasons = 0; Years++; money.BeginNewQuarter(Seasons, CurrentYear); finances.LoadFinancialReports(); UpdateClockColor(); } } }
private void Update() { float baseDays = ResourcesDatabase.GetBaseDays(ItemName); float localProductivity = ProductivityController.GetAverageProductivityHere(ItemName); float globalProductivity = ProductivityController.GetAverageProductivityEverywhere(ItemName); daysWorldWide.text = Mathf.RoundToInt(baseDays / globalProductivity) + " days"; daysLocal.text = localProductivity > 0 ? "(" + Mathf.RoundToInt(baseDays / localProductivity) + " days here)" : "(??? days here)"; ItemOrder io = new ItemOrder(100, ItemName); valueLabel.text = MoneyController.symbol + io.ExchangeValue().ToString("n2"); }
public static float GetBasePrice(string item, int amount) { if (!resourceData.ContainsKey(item)) { Debug.LogError("ResourceDatabase does not contain " + item); } float baseDays = resourceData[item].days; float globalProductivity = ProductivityController.GetAverageProductivityEverywhere(item); float price = baseDays * PoundsPerDays / globalProductivity; price = (float)Math.Round(price, 2); float ingredientsPrice = 0; //add the ingredients which go into the production of this item foreach (string s in resourceData[item].ingredients) { string[] data = s.Split(' '); int amount2 = (int)(float.Parse(data[0])); //amount / 100f needed to account for when the amount of what's being valued is not 100; preserve the ratio string item2 = data[1]; if (string.IsNullOrEmpty(item2)) { Debug.LogError(item + " has a null ingredient"); } ingredientsPrice += GetBasePrice(item2, amount2); } //SOMEHOW DETERMINE WHAT CONSTANT CAPITAL (STEEL, WOOD, COAL, ETC) IS BEING INVESTED INTO THE PRODUCTION OF THE ITEM // ADD THIS AVERAGE VALUE TO THE VALUE OF THE COMMODITY // BC EACH BUILDING HAS A CONSTANT VALUE OF MACHINERY AND FUEL INVESTED INTO EACH UNIT OF PRODUCTION, THIS SHOULDN'T BE TOO HARD // EXCEPT THAT WE HAVE TO SURVEY EACH BUILDING TO FIGURE OUT WHAT MACHINERY AND FUEL IS USED price += ingredientsPrice / 100f; price += ProductivityController.GetAverageAutomationEverywhere(item) / 100f; return(price * amount); }
public void LeaveProductivityList(string item) { ProductivityController.RemoveStructureFromList(this, item); }
public void JoinProductivityList(string item) { ProductivityController.AddStructureToList(this, item); }
public void LoadSavedGame(WorldProgressSave w) { Map = w.world; timeController.Load(w.time); population.Load(w.population); money.Load(w.money); cameraController.Load(w.camera); actionSelecter.Load(w.actionSelecter); immigration.Load(w.immigration); trade.Load(w.trade); diplomacy.Load(w.diplomacy); scenario.Load(w.scenario); research.Load(w.research); ProductivityController.LoadProductivities(w.productivities, w.automation); notifications.LoadEvents(w.Events); //load whitelist for items ResourcesDatabase.LoadWhitelist(w.Whitelist); //GO THROUGH LISTS OF OBJECTS AND ACTIVATE THEM USING THE LOADMAPOBJECT() FUNCTION //structures foreach (ObjSave save in w.structures) { LoadMapObject(save).transform.parent = structures.transform; } foreach (ObjSave save in w.jobcentres) { LoadMapObject(save).transform.parent = structures.transform; } foreach (ObjSave save in w.workplaces) { LoadMapObject(save).transform.parent = structures.transform; } foreach (ObjSave save in w.storagebuildings) { LoadMapObject(save).transform.parent = structures.transform; } foreach (ObjSave save in w.generators) { LoadMapObject(save).transform.parent = structures.transform; } foreach (ObjSave save in w.stables) { LoadMapObject(save).transform.parent = structures.transform; } foreach (ObjSave save in w.houses) { LoadMapObject(save).transform.parent = structures.transform; } foreach (ObjSave save in w.wtps) { LoadMapObject(save).transform.parent = structures.transform; } foreach (ObjSave save in w.canals) { LoadMapObject(save).transform.parent = structures.transform; } foreach (ObjSave save in w.crops) { LoadMapObject(save).transform.parent = structures.transform; } foreach (ObjSave save in w.farmhouses) { LoadMapObject(save).transform.parent = structures.transform; } //walkers foreach (ObjSave save in w.animals) { LoadMapObject(save).transform.parent = walkers.transform; } foreach (ObjSave save in w.walkers) { LoadMapObject(save).transform.parent = walkers.transform; } }