示例#1
0
        /// <summary>
        /// Change labelCost content when new item was selected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void comboBoxBuildings_SelectedValueChanged(object sender, EventArgs e)
        {
            // Getting selected item from comboBox
            string chosedOption = comboBoxBuildings.SelectedItem.ToString();

            switch (chosedOption) // Depending on selected item, propper cost will be displayed
            {
            case "Tartak":
                labelCost.Text = "Koszt: " + Sawmill.GetCost();
                break;

            case "Kamieniołom":
                labelCost.Text = "Koszt: " + Quarry.GetCost();
                break;

            case "Kopalnia":
                labelCost.Text = "Koszt: " + Mine.GetCost();
                break;

            case "Farma":
                labelCost.Text = "Koszt: " + Farm.GetCost();
                break;

            case "Rozbudowa zamku":
                labelCost.Text = "Koszt: " + Castle.GetCost();
                break;
            }

            // Showing build/destroy many menu
            labelQuantity.Visible     = true;
            textBoxQuantity.Visible   = true;
            buttonBuildMany.Visible   = true;
            buttonDestroyMany.Visible = true;
        }
示例#2
0
        /// <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();
        }
示例#3
0
        /// <summary>
        /// Function that takes care of building proper building
        /// </summary>
        private void Build()
        {
            // Getting selected item from comboBox
            string chosedOption = comboBoxBuildings.SelectedItem.ToString();

            switch (chosedOption) // Depending on chosed item, propper building procedure will begin
            {
            case "Tartak":
                if (Sawmill.ResourceCheck(ref wood, ref money))
                {
                    Sawmill.Build();
                }
                else
                {
                    MessageBox.Show("Nie posiadasz odpowiedniej liczby surowców");
                }
                break;

            case "Kamieniołom":
                if (Quarry.ResourceCheck(ref wood, ref money))
                {
                    Quarry.Build();
                }
                else
                {
                    MessageBox.Show("Nie posiadasz odpowiedniej liczby surowców");
                }
                break;

            case "Kopalnia":
                if (Mine.ResourcesCheck(ref wood, ref stone, ref money))
                {
                    Mine.Build();
                }
                else
                {
                    MessageBox.Show("Nie posiadasz odpowiedniej liczby surowców");
                }
                break;

            case "Farma":
                if (Farm.ResourceCheck(ref wood, ref money))
                {
                    Farm.Build();
                }
                else
                {
                    MessageBox.Show("Nie posiadasz odpowiedniej liczby surowców");
                }
                break;

            case "Rozbudowa zamku":
                if (Castle.ResourceCheck(ref wood, ref stone, ref gems, ref money))
                {
                    Castle.Build();
                    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
                    }
                    labelCost.Text = Castle.GetCost();                                                             // Updating label
                }
                else
                {
                    MessageBox.Show("Nie posiadasz odpowiedniej liczby surowców");
                }
                break;
            }
            UpdateIncomes();                // After building is done, there is need to update propper labels
            UpdateBuildingsCountLabels();
        }