Esempio n. 1
0
        private void JewelryCreator_Click(object sender, EventArgs e)
        {
            string BuffString(Buff buff)
            {
                return($"new Buff(BuffType.{buff.type}, {buff.value}) ");
            }

            if (jewelryName.Text == "")
            {
                return;
            }
            string name = jewelryName.Text;

            Buff strength         = new Buff(BuffType.Constant, 0);
            Buff agility          = new Buff(BuffType.Constant, 0);
            Buff wisdom           = new Buff(BuffType.Constant, 0);
            Buff intelligence     = new Buff(BuffType.Constant, 0);
            Buff endurance        = new Buff(BuffType.Constant, 0);
            Buff vitality         = new Buff(BuffType.Constant, 0);
            Buff defense          = new Buff(BuffType.Constant, 0);
            Buff health           = new Buff(BuffType.Constant, 0);
            Buff movementDistance = new Buff(BuffType.Constant, 0);
            Buff dodge            = new Buff(BuffType.Constant, 0);
            Buff mana             = new Buff(BuffType.Constant, 0);
            Buff carryCapacity    = new Buff(BuffType.Constant, 0);
            Buff weight           = new Buff(BuffType.Constant, 0);

            try
            {
                foreach (var buff in jewelryBuffs)
                {
                    int value = (int)(Controls.Find("n" + buff, false).First() as NumericUpDown).Value;
                    if (value == 0)
                    {
                        continue;
                    }
                    BuffType type = (BuffType)Enum.Parse(typeof(BuffType), (string)(Controls.Find("l" + buff, false).First() as ListBox).SelectedItem);
                    switch (buff)
                    {
                    case "Strength":
                        strength = new Buff(type, value);
                        break;

                    case "Agility":
                        agility = new Buff(type, value);
                        break;

                    case "Wisdom":
                        wisdom = new Buff(type, value);
                        break;

                    case "Intelligence":
                        intelligence = new Buff(type, value);
                        break;

                    case "Endurance":
                        endurance = new Buff(type, value);
                        break;

                    case "Vitality":
                        vitality = new Buff(type, value);
                        break;

                    case "Defense":
                        defense = new Buff(type, value);
                        break;

                    case "Health":
                        health = new Buff(type, value);
                        break;

                    case "MovementDistance":
                        movementDistance = new Buff(type, value);
                        break;

                    case "Dodge":
                        dodge = new Buff(type, value);
                        break;

                    case "Mana":
                        mana = new Buff(type, value);
                        break;

                    case "CarryCapacity":
                        carryCapacity = new Buff(type, value);
                        break;

                    case "Weight":
                        weight = new Buff(type, value);
                        break;

                    default:
                        throw new Exception();
                    }
                }
            }
            catch (Exception)
            {
                return;
            }
            if ((string)jewelryMaterial.SelectedItem == "")
            {
                return;
            }
            Material material = Material.Materials.First(m => m.name == (string)jewelryMaterial.SelectedItem);

            if ((string)jewelryQuality.SelectedItem == "")
            {
                return;
            }
            Quality quality = (Quality)Enum.Parse(typeof(Quality), (string)jewelryQuality.SelectedItem);

            if (jewelryType.SelectedItem is null)
            {
                return;
            }
            JewelryType jtype   = jewelryType.SelectedItem as JewelryType;
            Jewelry     jewelry = Jewelry.New(strength, intelligence, wisdom, agility, endurance, vitality, defense, health, movementDistance,
                                              dodge, mana, carryCapacity, weight, name, quality, material, jtype);

            output.Text = $"Jewelry.New({BuffString(strength)},{BuffString(intelligence)},{BuffString(wisdom)},{BuffString(agility)},{BuffString(endurance)},\"{name}\", " +
                          $"Quality.{quality}, Material.Materials.First(m => m.name == \"{material.name}\"), Item.GetJewelryType(\"{jtype}\"));";
            jewelry.Player = player;
            player.troop.jewelries.Add(jewelry);
            playerView.Render();
        }