ARCed.Database.Enemies.TreasureSelectDialog.SetTreasure C# (CSharp) Method

SetTreasure() public method

Sets the values of the control based on current settings
public SetTreasure ( int prob, int itemId, int weaponId, int armorId ) : void
prob int Probablity of obtaining treasure
itemId int ID of item to be obtained
weaponId int ID of weapon to be obtained
armorId int ID of armor to be obtained
return void
        public void SetTreasure(int prob, int itemId, int weaponId, int armorId)
        {
            this.numericUpDownPropability.Value = prob;
            if (itemId > 0 && itemId < this.comboBoxItem.Items.Count)
            {
                this.radioButtonItem.Checked = true;
                this.comboBoxItem.SelectedIndex = itemId - 1;
            }
            else if (weaponId > 0 && weaponId < this.comboBoxWeapon.Items.Count)
            {
                this.radioButtonWeapon.Checked = true;
                this.comboBoxWeapon.SelectedIndex = weaponId - 1;
            }
            else if (armorId > 0 && armorId < this.comboBoxArmor.Items.Count)
            {
                this.radioButtonArmor.Checked = true;
                this.comboBoxArmor.SelectedIndex = armorId - 1;
            }
        }

Usage Example

Example #1
0
 private void ButtonTreasureClick(object sender, EventArgs e)
 {
     using (var dialog = new TreasureSelectDialog())
     {
         dialog.SetTreasure(this._enemy.treasure_prob, this._enemy.item_id,
             this._enemy.weapon_id, this._enemy.armor_id);
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             this._enemy.treasure_prob = dialog.TreasureProbablity;
             this._enemy.item_id = this._enemy.weapon_id = this._enemy.armor_id = 0;
             if (dialog.ItemId > 0)
                 this._enemy.item_id = dialog.ItemId;
             else if (dialog.WeaponId > 0)
                 this._enemy.weapon_id = dialog.WeaponId;
             else if (dialog.ArmorId > 0)
                 this._enemy.armor_id = dialog.ArmorId;
             this.RefreshTreasure();
         }
     }
 }