Esempio n. 1
0
        private void AddWeapon(WeaponData data)
        {
            if (ItemManager.WeaponData.ContainsKey(data.Name))
            {
                DialogResult result = MessageBox.Show(data.Name + " already exists. Do you want to overwrite it?",
                                                      "Existing Weapon", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result != DialogResult.Yes)
                    return;

                ItemManager.WeaponData[data.Name] = data;
                LoadWeapons();
                return;
            }

            DetailList.Items.Add(data.ToString());

            ItemManager.WeaponData.Add(data.Name, data);
        }
Esempio n. 2
0
 private void CancelButtonClick(object sender, EventArgs e)
 {
     Weapon = null;
     CloseForm();
 }
Esempio n. 3
0
        private void OkButtonClick(object sender, EventArgs e)
        {
            if (!IsValid() || AllowedList.Items.Count <= 0)
            {
                MessageBox.Show("Name and/or Type cannot be empty, there must be at least one allowed class!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var allowed = (from object c in AllowedList.Items select c.ToString()).ToList();
            Weapon = new WeaponData
            {
                Name = NameBox.Text,
                Type = TypeBox.Text,
                Price = (int) PriceBox.Value,
                Weight = (float) WeightBox.Value,
                Hands = (Hands) HandsBox.SelectedIndex,
                AttackValue = (int) AttackValueBox.Value,
                AttackModifier = (int) AttackModifierBox.Value,
                DamageValue = (int) DamageValueBox.Value,
                DamageModifier = (int) DamageModifierBox.Value,
                AllowedClasses = allowed.ToArray()
            };

            CloseForm();
        }