Esempio n. 1
0
        private void UpdateUc(bool updateVillList = true)
        {
            var acc = GetSelectedAcc();

            if (villSelected < 0 || acc.Villages.Count <= villSelected)
            {
                villSelected = acc.Villages.Count - 1;
            }

            if (updateVillList)
            {
                VillagesListView.Items.Clear();
                for (int i = 0; i < acc.Villages.Count; i++) // Update villages list
                {
                    var item = new ListViewItem();
                    item.SubItems[0].Text      = acc.Villages[i].Name;
                    item.SubItems[0].ForeColor = Color.FromName(villSelected == i ? "DodgerBlue" : "Black");
                    item.SubItems.Add(acc.Villages[i].Coordinates.x + "/" + acc.Villages[i].Coordinates.y); //coords
                    item.SubItems.Add(VillageHelper.VillageType(acc.Villages[i]));                          //type (resource)
                    item.SubItems.Add(VillageHelper.ResourceIndicator(acc.Villages[i]));                    //resources count
                    VillagesListView.Items.Add(item);
                }
            }

            // Don't update village view if there is no village selected!
            if (GetSelectedVillage() == null)
            {
                return;
            }
            Ucs.ElementAtOrDefault(villageTabController.SelectedIndex)?.UpdateUc();
        }
Esempio n. 2
0
        private void UpdateVillageTab(bool updateVillList = true)
        {
            if (accounts.Count == 0)
            {
                return;
            }
            var acc = GetSelectedAcc();

            if (updateVillList)
            {
                VillagesListView.Items.Clear();
                foreach (var vill in acc.Villages) //update villages list
                {
                    var item = new ListViewItem();
                    item.SubItems[0].Text = vill.Name;
                    item.SubItems.Add(vill.Coordinates.x + "/" + vill.Coordinates.y); //coords
                    item.SubItems.Add(VillageHelper.VillageType(vill));               //type (resource)
                    item.SubItems.Add(VillageHelper.ResourceIndicator(vill));         //resources count
                    VillagesListView.Items.Add(item);
                }
            }

            if (acc.Villages.Count <= 0)
            {
                return;
            }
            switch (villageTabController.SelectedIndex)
            {
            case 0:     // Build
                buildUc1.UpdateBuildTab();
                break;

            case 1:     // Market
                marketUc1.UpdateMarketTab();
                break;

            case 2:     // Troops
                troopsUc1.UpdateTroopTab();
                break;

            case 3:     // Attack tab
                attackUc1.UpdateTab();
                break;

            default: break;
            }
        }