Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private short calcTime(int amount, string resource, string heroResource,
- int baseWood, int baseClay, int baseIron, int baseCrop)
- {
- short heroProduction = short.Parse(txtRes.Text);
- short woodProduction = short.Parse(txtWoodHour.Text);
- short clayProduction = short.Parse(txtClayHour.Text);
- short ironProduction = short.Parse(txtIronHour.Text);
- short cropProduction = short.Parse(txtCropHour.Text);
- switch (resource)
- {
- case "wood":
- // How fast can I gather wood
- if (heroResource == "wood")
- {
- return Convert.ToInt16(amount / (baseWood - Convert.ToInt32(txtRes.Text) * 10));
- }
- else if (heroResource == "all")
- {
- return Convert.ToInt16(amount / (baseWood - Convert.ToInt32(txtRes.Text) * 3));
- }
- else
- {
- return Convert.ToInt16(amount / baseWood);
- }
- case "clay":
- // How fast can I gather clay
- if (heroResource == "clay")
- {
- return Convert.ToInt16(amount / (baseClay - Convert.ToInt32(txtRes.Text) * 10));
- }
- else if (heroResource == "all")
- {
- return Convert.ToInt16(amount / (baseClay - Convert.ToInt32(txtRes.Text) * 3));
- }
- else
- {
- return Convert.ToInt16(amount / baseClay);
- }
- case "iron":
- // How fast can I gather iron
- if (heroResource == "iron")
- {
- return Convert.ToInt16(amount / (baseIron - Convert.ToInt32(txtRes.Text) * 10));
- }
- else if (heroResource == "all")
- {
- return Convert.ToInt16(amount / (baseIron - Convert.ToInt32(txtRes.Text) * 3));
- }
- else
- {
- return Convert.ToInt16(amount / baseIron);
- }
- case "crop":
- // How fast can I gather crop
- if (heroResource == "crop")
- {
- return Convert.ToInt16(amount / (baseCrop - Convert.ToInt32(txtRes.Text) * 10));
- }
- else if (heroResource == "all")
- {
- return Convert.ToInt16(amount / (baseCrop - Convert.ToInt32(txtRes.Text) * 3));
- }
- else
- {
- return Convert.ToInt16(amount / baseCrop);
- }
- default:
- // Wrong input
- MessageBox.Show("Wrong input to calcTime(" + heroResource + ")", "Error");
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment