/// <summary>
        /// Critical strike multiplie checking and setting
        /// </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 TBCritMultiple_TextChanged(object sender, EventArgs e)
        {
            if ((TBCritMultiple.Text == string.Empty) || (!RealChange))
            {
                return;
            }
            sMainTowerParam Tmp      = TowerConfig.UpgradeParams[GetIndexByName(TBCritMultiple.Name)];
            object          TmpValue = Tmp.CritMultiple;

            ValidateAndChange(TBCritMultiple.Text, ref TmpValue);
            Tmp.CritMultiple = (double)TmpValue;
            TowerConfig.UpgradeParams[GetIndexByName(TBCritMultiple.Name)] = Tmp;
        }
        /// <summary>
        /// Adds the new up level.
        /// </summary>
        /// <param name="Radius">The radius.</param>
        /// <param name="Cooldown">The cooldown.</param>
        /// <param name="InsertPos">The insert pos.</param>
        public void AddNewUpLevel(int Radius = 0, int Cooldown = 0, int InsertPos = 1)
        {
            sMainTowerParam AddValue = sMainTowerParam.CreateDefault();

            AddValue.AttackRadius = Radius;
            AddValue.Cooldown     = Cooldown;
            AddValue.Cost         = TowerConfig.UpgradeParams[0].Cost;//by deafult
            AddValue.Damage       = TowerConfig.UpgradeParams[0].Damage;
            #region Currently it's don't change with level, wrote for future
            AddValue.CritChance      = TowerConfig.UpgradeParams[0].CritChance;
            AddValue.CritMultiple    = TowerConfig.UpgradeParams[0].CritMultiple;
            AddValue.NumberOfTargets = TowerConfig.UpgradeParams[0].NumberOfTargets;
            #endregion
            TowerConfig.UpgradeParams.Insert(InsertPos, AddValue);
        }
 /// <summary>
 /// Critical strike parametr changing
 /// </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 CBEnableCrit_CheckedChanged(object sender, EventArgs e)
 {
     if (!RealChange)
     {
         return;
     }
     PCriticalStrikeSettings.Enabled = CBEnableCrit.Checked;
     if (!CBEnableCrit.Checked)
     {
         sMainTowerParam Tmp = TowerConfig.UpgradeParams[0];
         Tmp.CritChance               = 0;
         Tmp.CritMultiple             = 0;
         TowerConfig.UpgradeParams[0] = Tmp;
         TBCritMultiple.Text          = "0";
         mTBCritChance.Text           = "0";
     }
 }
 /// <summary>
 /// Loads tower picture for rendering on the map
 /// </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 BLoadTowerBitmap_Click(object sender, EventArgs e)
 {
     OFDialog.Filter = "Bitmap|*.bmp|Png picture|*.png";
     if (OFDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             sMainTowerParam Tmp = TowerConfig.UpgradeParams[0];
             Tmp.Picture = new Bitmap(OFDialog.FileName);
             TowerConfig.UpgradeParams[0] = Tmp;
             PBTowerBitmap.Size           = TowerConfig.UpgradeParams[0].Picture.Size;
             PBTowerBitmap.Image          = TowerConfig.UpgradeParams[0].Picture;
         }
         catch (Exception exp)
         {
             MessageBox.Show("Picture loading error: " + exp.Message);
         }
     }
 }
        /// <summary>
        /// Masked text boxes changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void maskedTextBoxChanged(object sender, EventArgs e)
        {
            if ((sender as MaskedTextBox) == null)
            {
                MessageBox.Show("BAD BAD BAD programmer again! The method is used incorrectly.");
                return;
            }
            if (((sender as MaskedTextBox).Text == string.Empty) || (!RealChange))
            {
                return;
            }
            int index = GetIndexByName((sender as MaskedTextBox).Name);

            if (index == -1)
            {
                return;
            }
            #region Value changing
            sMainTowerParam Tmp = TowerConfig.UpgradeParams[index];
            object          TmpValue;
            switch ((sender as MaskedTextBox).Name)
            {
                #region Tower Cost(and for upgrading too)
            case "mTBCost":
            case "mTBlCost":
            case "mTBuCost":
                TmpValue = Tmp.Cost;
                ValidateAndChange((sender as MaskedTextBox).Text, ref TmpValue);
                Tmp.Cost = (int)TmpValue;
                break;

                #endregion
                #region Damdage(and for upgrading too)
            case "mTBDamage":
            case "mTBlDamage":
            case "mTBuDamage":
                TmpValue = Tmp.Damage;
                ValidateAndChange((sender as MaskedTextBox).Text, ref TmpValue);
                Tmp.Damage = (int)TmpValue;
                break;

                #endregion
                #region Attack radius(and for upgrading too)
            case "mTBRadius":
            case "mTBlRadius":
            case "mTBuRadius":
                TmpValue = Tmp.AttackRadius;
                ValidateAndChange((sender as MaskedTextBox).Text, ref TmpValue);
                Tmp.AttackRadius = (int)TmpValue;
                break;

                #endregion
                #region Number of targets
            case "mTBNumberOfTargets":
                /*case "mTBlNumberOfTargets":
                *  case "mTBuNumberOfTargets":*/
                TmpValue = Tmp.NumberOfTargets;
                ValidateAndChange((sender as MaskedTextBox).Text, ref TmpValue);
                Tmp.NumberOfTargets = (int)TmpValue;
                break;

                #endregion
                #region Critical chance
            case "mTBCritChance":
                /*case "mTBlCritChance":
                *  case "mTBuCritChance":*/
                TmpValue = Tmp.CritChance;
                ValidateAndChange((sender as MaskedTextBox).Text, ref TmpValue);
                if (((byte)TmpValue > 0) && ((byte)TmpValue < 100))
                {
                    Tmp.CritChance = (byte)TmpValue;
                }
                break;

                #endregion
                #region Attack Cooldown
            case "mTBCooldown":
            case "mTBlCooldown":
            case "mTBuCooldown":
                TmpValue = Tmp.Cooldown;
                ValidateAndChange((sender as MaskedTextBox).Text, ref TmpValue);
                Tmp.Cooldown = (int)TmpValue;
                break;
                #endregion
            }
            TowerConfig.UpgradeParams[index] = Tmp;
            #endregion
        }