private void UpdateAllData() { // Big function is used to update all shown data every n seconds ShowMarketStatus(); if (PlanetsSelectList.SelectedItem != null) { string tempPlanetName = PlanetsSelectList.SelectedItem.ToString(); Planet tempPlanet = DefinePlanetByName(tempPlanetName); ShowPlanetData(tempPlanet); if (ColoniesSelectList.SelectedItem != null) { string text = ColoniesSelectList.SelectedItem.ToString(); Colony tempColony = DefineColonyByName(text, tempPlanet.GetColonies(), tempPlanet); ShowColoniesData(tempColony); if (BuildingsSelectList.SelectedItem != null) { string idText = BuildingsSelectList.SelectedItem.ToString(); if (int.TryParse(idText, out int id)) { Building tempBuilding = DefineBuildingByID(id, tempColony.GetBuildings(), tempColony); ShowBuildingsData(tempBuilding, tempColony); } } } } }
private void ShowBuildings(Colony colony) { BuildingsSelectList.Items.Clear(); List <Building> list = colony.GetBuildings(); for (int i = 0; i < list.Count; i++) { BuildingsSelectList.Items.Add(list[i].Id); } }
private void UpdateWindowBuildingsList(Colony colony) { BuildingsSelectList.Items.Clear(); List <Building> tempList = colony.GetBuildings(); for (int i = 0; i < tempList.Count(); i++) { BuildingsSelectList.Items.Add(tempList[i].Id); } }
private void ShowColoniesData(Colony colony) { string data = ""; string nameData = "Name : " + colony.Name + "\n"; string moneyData = "Money : " + colony.Money + "\n"; string buildingsData = "Number of buildings : " + colony.GetBuildings().Count() + "\n"; string resourcesData = "Resources : \n"; List <ResourceInt> tempList = colony.GetStorage(); for (int i = 0; i < tempList.Count(); i++) { resourcesData += tempList[i].Number + " of " + tempList[i].Type.TypeString + "\n"; } data = nameData + moneyData + buildingsData + resourcesData; ColonyInfoData.Text = data; }
private void BuildingsSelectList_SelectedIndexChanged(object sender, EventArgs e) { if (BuildingsSelectList.SelectedItem != null) { string text = ColoniesSelectList.SelectedItem.ToString(); string tempPlanetName = PlanetsSelectList.SelectedItem.ToString(); Planet tempPlanet = DefinePlanetByName(tempPlanetName); Colony tempColony = DefineColonyByName(text, tempPlanet.GetColonies(), tempPlanet); string idText = BuildingsSelectList.SelectedItem.ToString(); if (int.TryParse(idText, out int id)) { Building tempBuilding = DefineBuildingByID(id, tempColony.GetBuildings(), tempColony); ShowBuildingsData(tempBuilding, tempColony); } } else { ShowStatus("Select at least one Building"); } }