private void Tabs_TabIndexChanged(object sender, EventArgs e) { if (Tabs.SelectedTab == PlayerPage) { try { PopulationLabel.Text = "Population: " + Clicked.Population.Count(); } catch { PopulationLabel.Text = "Population: " + "ERROR"; } InventroyLabel.Text = "Wood: " + PlayerInventory["wood"] + "\nBricks: " + PlayerInventory["bricks"] + "\nWheat: " + PlayerInventory["wheat"] + "\nMeat: " + PlayerInventory["meat"] + "\nMetals: " + PlayerInventory["metals"] + "\nTools: " + PlayerInventory["tools"] + "\nWeapons: " + PlayerInventory["weapons"] + "\nWool: " + PlayerInventory["wool"] + "\nCloth: " + PlayerInventory["cloth"] + "\nFurs: " + PlayerInventory["furs"] + "\nAle: " + PlayerInventory["ale"] + "\nWine: " + PlayerInventory["wine"] + "\nSpices: " + PlayerInventory["spices"] + "\nSalt: " + PlayerInventory["salt"] + "\nHemps: " + PlayerInventory["hemps"]; #region woodUpdateBuySell WoodBuySellBox.Text = ""; WoodStorageLabel.Text = "City storage: " + Clicked.Storage["wood"]; WoodTrackBar.Maximum = Clicked.Storage["wood"]; WoodShortageBar.Value = Clicked.Shortage["wood"]; try { Clicked.CalculateNeed(); WoodStorageBar.Maximum = Clicked.PopulationUsage["wood"] * 3; WoodStorageBar.Value = Clicked.Storage["wood"]; } catch { WoodStorageBar.Value = WoodStorageBar.Maximum; } #endregion } }
/* * Prices: * * if shortage + 10% for every shortage point + + if production last turn was on - +10% + else + -10% + + city needs = 100% + price - 50% + city needs = 0% + price + 50% + */ private void WoodTrackBar_Scroll(object sender, EventArgs e) { Clicked.CalculateNeed(); WoodNumberLabel.Text = WoodTrackBar.Value.ToString(); int price = 0; for (int n = 1; n < WoodTrackBar.Value; n++) { int addtoprice = 0; Clicked.CalculateNeed("wood", (Clicked.Storage["wood"] - n)); addtoprice = (int)Math.Round(Prices["wood"] * Clicked.PriceModifier["wood"]); price += addtoprice; } WoodPriceLabel.Text = "Price: " + price; /* * int WoodNeededToEndShortage = (int)Math.Round(Clicked.Population.Count * 0.01); * for (int n = 0; n < WoodTrackBar.Value; n++) * { * int addtoprice = 0; * if (Clicked.Shortage["wood"] > 0 && NewStorage < WoodNeededToEndShortage) * { * addtoprice = (int)(Prices["wood"] + Math.Round(Prices["wood"] * (0.1 * Clicked.Shortage["wood"]))); * } * else * { * addtoprice = Prices["wood"]; * } * if (Clicked.Production["wood"] < 0) * { * addtoprice += (int)Math.Round(Prices["wood"] * 0.1); * } * else if (Clicked.Production["wood"] == 0) * { * addtoprice += (int)Math.Round(Prices["wood"] * 0.05); * } * else * { * addtoprice -= (int)Math.Round(Prices["wood"] * 0.1); * } * double percentage = 0; * if (WoodStorageBar.Maximum >= NewStorage) * { * percentage = NewStorage / WoodStorageBar.Maximum; * } * else * { * percentage = -(WoodStorageBar.Maximum / NewStorage); * } * percentage /= 2; * addtoprice += (int)Math.Round(Prices["wood"] * percentage); * price += addtoprice; * NewStorage--; * } */ }