private void UpdateBuildTasks(Village vill) { buildListView.Items.Clear(); for (int i = 0; i < vill.Build.Tasks.Count; i++) { var task = vill.Build.Tasks[i]; var item = new ListViewItem(); //building if (task.TaskType == BuildingType.AutoUpgradeResFields) { item.SubItems[0].Text = AutoBuildResFieldsStr(task); } else { item.SubItems[0].Text = VillageHelper.BuildingTypeToString(task.Building); } item.ForeColor = Color.FromName(oldSelected == i ? "DodgerBlue" : "Black"); item.SubItems.Add(task.Level.ToString()); //lvl item.SubItems.Add(task.BuildingId.ToString()); //buildingId //var upgradeTask = acc.Tasks?.FirstOrDefault(x => // x.GetType() == typeof(UpgradeBuilding) // && ((UpgradeBuilding)x).Task == task // ); //item.SubItems.Add(upgradeTask == null ? "" : upgradeTask.ExecuteAt.ToString()); //execute at buildListView.Items.Add(item); } }
private void RefreshBuildingsList(Village vill) { //update buildings list view buildingsList.Items.Clear(); //19, 38); for (int i = 0; i <= 39; i++) { var building = vill.Build.Buildings[i]; var item = new ListViewItem(); var id = building.Id; item.SubItems[0].Text = id.ToString();//id string buildingName = VillageHelper.BuildingTypeToString(building.Type); //if there is a task for upgrading/construction the building on this site string upgradeLvl = ""; var upgradeBuilding = vill.Build.Tasks.LastOrDefault(x => x.BuildingId == id); if (upgradeBuilding != null) { upgradeLvl = " -> " + upgradeBuilding.Level; if (buildingName == "Site") { buildingName = VillageHelper.BuildingTypeToString(upgradeBuilding.Building); } } item.SubItems.Add(buildingName); //building item.SubItems.Add(building.Level.ToString() + upgradeLvl); //level //set color switch (building.Type) { case BuildingEnum.Woodcutter: item.ForeColor = Color.LightGreen; break; case BuildingEnum.ClayPit: item.ForeColor = Color.Orange; break; case BuildingEnum.IronMine: item.ForeColor = Color.Gray; break; case BuildingEnum.Cropland: item.ForeColor = Color.Yellow; break; case BuildingEnum.Site: item.ForeColor = (buildingName == "Site" ? Color.White : Color.LightBlue); break; default: item.ForeColor = Color.GreenYellow; break; } buildingsList.Items.Add(item); } }
public void UpdateUc() { Account acc = GetSelectedAcc(); var vill = GetSelectedVillage(); if (vill == null) { return; } RefreshBuildingsList(vill); //Building Tasks ListView UpdateBuildTasks(vill); foreach (var task in vill.Build.DemolishTasks) { var item = new ListViewItem(); //building item.SubItems[0].Text = "Demolish " + VillageHelper.BuildingTypeToString(vill.Build.Buildings.FirstOrDefault(x => x.Id == task.BuildingId).Type); item.SubItems.Add(task.Level.ToString()); //lvl item.SubItems.Add(task.BuildingId.ToString()); //buildingId buildListView.Items.Add(item); } //Currently building ListView currentlyBuildinglistView.Items.Clear(); foreach (var building in vill.Build.CurrentlyBuilding) { var item = new ListViewItem(); item.SubItems[0].Text = building.Building.ToString(); item.SubItems.Add(building.Level.ToString()); //lvl item.SubItems.Add(building.Duration == DateTime.MinValue ? "/" : building.Duration.ToString()); //execute at currentlyBuildinglistView.Items.Add(item); } autoBuildResType.SelectedIndex = 0; autoBuildResStrat.SelectedIndex = 0; autoBuildResLevel.Value = 10; AutoBuildBonusBuildings.Checked = vill.Build.AutoBuildResourceBonusBuildings; buildTypeComboBox.Enabled = false; buildRadioButton.Checked = true; instaUpgradeUpDown.Enabled = vill.Build.InstaBuild; instaUpgradeUpDown.Value = vill.Build.InstaBuildHours; var prereqComboList = BuildingHelper.SetPrereqCombo(acc, vill); prereqCombo.Items.Clear(); prereqComboList.ForEach(x => prereqCombo.Items.Add(x)); if (0 < prereqComboList.Count) { prereqCombo.SelectedIndex = 0; } }
public void UpdateBuildTab() { Account acc = getSelectedAcc(); var vill = getSelectedVillage(); if (vill == null) { return; } RefreshBuildingsList(vill); //Building Tasks ListView buildListView.Items.Clear(); foreach (var task in vill.Build.Tasks) { var item = new ListViewItem(); //building if (task.TaskType == BuildingHelper.BuildingType.AutoUpgradeResFields) { item.SubItems[0].Text = "Auto-upgrade Res Fields"; } else { item.SubItems[0].Text = VillageHelper.BuildingTypeToString(task.Building); } item.SubItems.Add(task.Level.ToString()); //lvl item.SubItems.Add(task.BuildingId.ToString()); //buildingId item.SubItems.Add("TODO when will it be executed"); //execute at buildListView.Items.Add(item); } foreach (var task in vill.Build.DemolishTasks) { var item = new ListViewItem(); //building item.SubItems[0].Text = "Demolish " + VillageHelper.BuildingTypeToString(vill.Build.Buildings.FirstOrDefault(x => x.Id == task.BuildingId).Type); item.SubItems.Add(task.Level.ToString()); //lvl item.SubItems.Add(task.BuildingId.ToString()); //buildingId buildListView.Items.Add(item); } //Currently building ListView currentlyBuildinglistView.Items.Clear(); foreach (var building in vill.Build.CurrentlyBuilding) { var item = new ListViewItem(); item.SubItems[0].Text = building.Building.ToString(); item.SubItems.Add(building.Level.ToString()); //lvl item.SubItems.Add(building.Duration == DateTime.MinValue ? "/" : building.Duration.ToString()); //execute at currentlyBuildinglistView.Items.Add(item); } autoBuildResType.SelectedIndex = 0; autoBuildResStrat.SelectedIndex = 0; autoBuildResLevel.Value = 10; AutoBuildBonusBuildings.Checked = vill.Build.AutoBuildResourceBonusBuildings; buildTypeComboBox.Enabled = false; buildRadioButton.Checked = true; }