/// <summary> /// Function that updates text in buildings labels /// </summary> private void UpdateBuildingsCountLabels() { labelSawmillCount.Text = Sawmill.GetSawmillsCount().ToString(); labelQuarriesCount.Text = Quarry.GetQuarriesCount().ToString(); labelMinesCount.Text = Mine.GetMinesCount().ToString(); labelFarmsCount.Text = Farm.GetFarmsCount().ToString(); labelCastleLevel.Text = Castle.GetLevel().ToString(); }
/// <summary> /// Function that updates incomes of the player /// </summary> private void UpdateIncomes() { // Calculating incomes woodIncome = Sawmill.GetBaseProduction() * Sawmill.GetSawmillsCount(); stoneIncome = Quarry.GetBaseProduction() * Quarry.GetQuarriesCount(); gemsIncome = Mine.GetBaseProduction() * Mine.GetMinesCount(); // Food income depends on how many other buildings player has foodIncome = Farm.GetBaseProduction() * Farm.GetFarmsCount() - (Quarry.GetFoodIncomeCost() + Mine.GetFoodIncomeCost() + Castle.GetFoodIncomeCost()); moneyIncome = 10 + Castle.GetBaseProduction(); }
/// <summary> /// Function that takes care of destroying propper building /// </summary> private void Destroy() { // Getting selected item from comboBox string chosedOption = comboBoxBuildings.SelectedItem.ToString(); switch (chosedOption) // Depending on selected item, propper destroying procedure will began { case "Tartak": if (Sawmill.GetSawmillsCount() > 0) { Sawmill.Destroy(); MessageBox.Show("Zburzono tartak"); } else { MessageBox.Show("Nie masz tartaków"); } break; case "Kamieniołom": if (Quarry.GetQuarriesCount() > 0) { Quarry.Destroy(); MessageBox.Show("Zburzono kamieniołom"); } else { MessageBox.Show("Nie masz kamieniołomów"); } break; case "Kopalnia": if (Mine.GetMinesCount() > 0) { Mine.Destroy(); MessageBox.Show("Zburzono kopalnię"); } else { MessageBox.Show("Nie masz kopalni"); } break; case "Farma": if (Farm.GetFarmsCount() > 0) { Farm.Destroy(); MessageBox.Show("Zburzono farmę"); } break; case "Rozbudowa zamku": if (Castle.GetLevel() > 1) { Castle.Destroy(); if (Castle.GetLevel() < 5) { Bitmap image = new Bitmap("Resources/img/castle" + Castle.GetLevel().ToString() + ".png"); // Loading new images for specific level of upgrade. There is 4 levels, but you can build more pictureBoxCastle.Image = image; // Assigning image to pictureBox } MessageBox.Show("Wyburzono część zamku"); labelCost.Text = Castle.GetCost(); //updating label } else { MessageBox.Show("Nie możesz zniszczyć zamku"); } break; } UpdateIncomes(); // After demolition, there is need to update propper labels UpdateBuildingsCountLabels(); }