Hi..

I'm new to C#, so I figured I'd create a user on this forum and see how this plays out.

I'm trying to create a resource calculator for Travian. I've seen quite a few out there, but none that do exactly what I want it to do, so I decided to make my own.

What I want is this:

I need to train a unit. The unit costs x amount of wood, clay, iron and crop.
I need to find out how to fastest gain access to that amount of resources.
If my hero produces all resources, he gains (3 * points in resource production) resources of each kind per hour.
If my produces any other resource, he gains (10 * points in resource production) resources of that kind per hour.

I want my program to figure out if it is faster to for example take wood production for x hours and then switch to some other production, or which route would be the fastest. I guess I'll need some sort of algorithm for this, I'm not really sure how this can be done.

I put in the form of my program the following:

-Points put in resource production
-How many resources I get per hour
-How many resources I have currently
-How many resources I need
-What type of resource is currently being produces by the hero (wood/clay/iron/crop/all)

I have this code so far:
Code:
        private void btnCalc_Click(object sender, EventArgs e)
        {
            // Initialize variables
            int baseWood = 0;
            int baseClay = 0;
            int baseIron = 0;
            int baseCrop = 0;
            int missingWood = 0;
            int missingClay = 0;
            int missingIron = 0;
            int missingCrop = 0;

            // Check if all fields are filled out
            foreach (TextBox tb in this.Controls.OfType<TextBox>())
            {
                if (tb.Text == string.Empty)
                {
                    // Textbox empty
                    MessageBox.Show("Please fill out all fields.", "Missing number");
                    return;
                }
            }

            if (rbWood.Checked)
            {
                baseWood = Convert.ToInt32(txtWoodHour.Text) - (Convert.ToInt32(txtRes.Text) * 10);
            }
            else if (rbClay.Checked)
            {
                baseClay = Convert.ToInt32(txtClayHour.Text) - (Convert.ToInt32(txtRes.Text) * 10);
            }
            else if (rbIron.Checked)
            {
                baseIron = Convert.ToInt32(txtIronHour.Text) - (Convert.ToInt32(txtRes.Text) * 10);
            }
            else if (rbCrop.Checked)
            {
                baseCrop = Convert.ToInt32(txtCropHour.Text) - (Convert.ToInt32(txtRes.Text) * 10);
            }
            else if (rbAll.Checked)
            {
                baseWood = Convert.ToInt32(txtWoodHour.Text) - (Convert.ToInt32(txtRes.Text) * 3);
                baseClay = Convert.ToInt32(txtClayHour.Text) - (Convert.ToInt32(txtRes.Text) * 3);
                baseIron = Convert.ToInt32(txtIronHour.Text) - (Convert.ToInt32(txtRes.Text) * 3);
                baseCrop = Convert.ToInt32(txtCropHour.Text) - (Convert.ToInt32(txtRes.Text) * 3);
            }
            else
            {
                // No radio buttons selected.
                MessageBox.Show("Please select which resource your hero produces.", "Missing selection.");
                return;
            }

            // Calculate how many resources are needed
            missingWood = Convert.ToInt32(txtTargetWood.Text) - Convert.ToInt32(txtWood.Text);
            missingClay = Convert.ToInt32(txtTargetClay.Text) - Convert.ToInt32(txtClay.Text);
            missingIron = Convert.ToInt32(txtTargetIron.Text) - Convert.ToInt32(txtIron.Text);
            missingCrop = Convert.ToInt32(txtTargetCrop.Text) - Convert.ToInt32(txtCrop.Text);

            // Calculate fastest way to target
        }
Any help would be appreciated, and I'll gladly explain in more detail, if any other info is needed. My mind is a bit foggy after explaining this, which seemed to be a bit harder to explain than I thought

Thanks in advance!
// Jákup