/// <summary>
 /// Factories the specified act.
 /// </summary>
 /// <param name="act">The act.</param>
 /// <param name="Params">The params.</param>
 /// <param name="arrayPos">The array pos.</param>
 /// <param name="confHash">The conf hash.</param>
 /// <param name="scaling">The scaling.</param>
 /// <param name="loadStream">The load stream.</param>
 /// <returns></returns>
 internal static Tower Factory(FactoryAct act, TowerParam Params, Point arrayPos, string confHash, float scaling = 1F, BinaryReader loadStream = null)
 {
   try
   {
     Tower result = new Tower(Params, arrayPos, confHash, scaling);
     switch (act)
     {
       case FactoryAct.Create:
         break;
       case FactoryAct.Load:
         result.Load(loadStream);
         break;
       default:
         throw new ArgumentOutOfRangeException("act");
     }
     return result;
   }
   catch (Exception exc)
   {
     //TODO add NLog
     throw;
   }
 }
 /// <summary>
 /// New tower creating
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void BNewTowerConf_Click(object sender, EventArgs e)
 {
   TowerConfig = new TowerParam();
   SetParams();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Tower"/> class.
 /// </summary>
 /// <param name="Params">The params.</param>
 /// <param name="arrayPos">The array pos.</param>
 /// <param name="confHash">The conf hash.</param>
 /// <param name="scaling">The scaling.</param>
 private Tower(TowerParam Params, Point arrayPos, string confHash, float scaling = 1F)
 {
   _params = Params;
   ArrayPos = new Point(arrayPos.X, arrayPos.Y);
   Scaling = scaling;
   Level = 1;
   _confHash = string.Copy(confHash);
   _currentTowerParams = _params.UpgradeParams[Level - 1];
   CanUpgrade = _params.UpgradeParams.Count > 1;
   _currentTowerParams.Cooldown = 0;
   _currentMaxCooldown = _params.UpgradeParams[0].Cooldown;
   _towerCenterPos = new Point((ArrayPos.X + 1) * Settings.ElemSize, (ArrayPos.Y + 1) * Settings.ElemSize);
   _currentTowerParams.Picture.MakeTransparent(Color.FromArgb(255, 0, 255));
 }
 /// <summary>
 /// Tower configuration loading
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void BLoad_Click(object sender, EventArgs e)
 {
   OFDialog.FileName = "*.tdtc";
   OFDialog.Filter = "Tower configuration|*.tdtc";
   if (OFDialog.ShowDialog() == DialogResult.OK)
   {
     using (FileStream TowerConfLoadStream = new FileStream(OFDialog.FileName, FileMode.Open, FileAccess.Read))
     {
       try
       {
         IFormatter Formatter = new BinaryFormatter();
         TowerConfig = (TowerParam)Formatter.Deserialize(TowerConfLoadStream);
         SetParams();
       }
       catch (Exception Exc)
       {
         MessageBox.Show("Tower configuration loading error: \n" + Exc.Message);
       }
     }
   }
 }