Guest User

Untitled

a guest
Jul 18th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.17 KB | None | 0 0
  1. private short calcTime(int amount, string resource, string heroResource,
  2.             int baseWood, int baseClay, int baseIron, int baseCrop)
  3.         {
  4.             short heroProduction = short.Parse(txtRes.Text);
  5.             short woodProduction = short.Parse(txtWoodHour.Text);
  6.             short clayProduction = short.Parse(txtClayHour.Text);
  7.             short ironProduction = short.Parse(txtIronHour.Text);
  8.             short cropProduction = short.Parse(txtCropHour.Text);
  9.             switch (resource)
  10.             {
  11.                 case "wood":
  12.                     // How fast can I gather wood
  13.                     if (heroResource == "wood")
  14.                     {
  15.                         return Convert.ToInt16(amount / (baseWood - Convert.ToInt32(txtRes.Text) * 10));
  16.                     }
  17.                     else if (heroResource == "all")
  18.                     {
  19.                         return Convert.ToInt16(amount / (baseWood - Convert.ToInt32(txtRes.Text) * 3));
  20.                     }
  21.                     else
  22.                     {
  23.                         return Convert.ToInt16(amount / baseWood);
  24.                     }
  25.                 case "clay":
  26.                     // How fast can I gather clay
  27.                     if (heroResource == "clay")
  28.                     {
  29.                         return Convert.ToInt16(amount / (baseClay - Convert.ToInt32(txtRes.Text) * 10));
  30.                     }
  31.                     else if (heroResource == "all")
  32.                     {
  33.                         return Convert.ToInt16(amount / (baseClay - Convert.ToInt32(txtRes.Text) * 3));
  34.                     }
  35.                     else
  36.                     {
  37.                         return Convert.ToInt16(amount / baseClay);
  38.                     }
  39.                 case "iron":
  40.                     // How fast can I gather iron
  41.                     if (heroResource == "iron")
  42.                     {
  43.                         return Convert.ToInt16(amount / (baseIron - Convert.ToInt32(txtRes.Text) * 10));
  44.                     }
  45.                     else if (heroResource == "all")
  46.                     {
  47.                         return Convert.ToInt16(amount / (baseIron - Convert.ToInt32(txtRes.Text) * 3));
  48.                     }
  49.                     else
  50.                     {
  51.                         return Convert.ToInt16(amount / baseIron);
  52.                     }
  53.                 case "crop":
  54.                     // How fast can I gather crop
  55.                     if (heroResource == "crop")
  56.                     {
  57.                         return Convert.ToInt16(amount / (baseCrop - Convert.ToInt32(txtRes.Text) * 10));
  58.                     }
  59.                     else if (heroResource == "all")
  60.                     {
  61.                         return Convert.ToInt16(amount / (baseCrop - Convert.ToInt32(txtRes.Text) * 3));
  62.                     }
  63.                     else
  64.                     {
  65.                         return Convert.ToInt16(amount / baseCrop);
  66.                     }
  67.                 default:
  68.                     // Wrong input
  69.                     MessageBox.Show("Wrong input to calcTime(" + heroResource + ")", "Error");
  70.                     return 0;
  71.             }
  72.         }
Advertisement
Add Comment
Please, Sign In to add comment