private void AddCharacter(object sender, RoutedEventArgs e) { string name = TxtBoxName.Text; if (name.Length == 0) { MessageBox.Show("Имя персонажа должно содержать минимум 1 символ"); return; } int currHP, currMP, currCheerfulness, currFood, maxHP, maxMP, maxCheerfulness, maxFood; try { currHP = int.Parse(TxtBoxCurrentHP.Text); currMP = int.Parse(TxtBoxCurrentMP.Text); currCheerfulness = int.Parse(TxtBoxCurrentCheerfulness.Text); currFood = int.Parse(TxtBoxCurrentFood.Text); maxHP = int.Parse(TxtBoxMaxHP.Text); maxMP = int.Parse(TxtBoxMaxMP.Text); maxCheerfulness = int.Parse(TxtBoxMaxCheerfulness.Text); maxFood = int.Parse(TxtBoxMaxFood.Text); } catch(Exception) { MessageBox.Show("Поля статистики персонажа должны содержать только целые числа"); return; } CharacterInfo ci = new CharacterInfo(name, currHP, currMP, currCheerfulness, currFood, maxHP, maxMP, maxCheerfulness, maxFood, new Perks(), new Inventory()); _cb(ci); this.Close(); }
public CharacterCard(CharacterInfo ci) { InitializeComponent(); CharName = ci.Name; MaxHP = ci.MaxHP; MaxMP = ci.MaxMP; MaxCheerfulness = ci.MaxCheerfulness; MaxFood = ci.MaxFood; HP = ci.HP; MP = ci.MP; Cheerfulness = ci.Cheerfulness; Food = ci.Food; Perks = ci.Perks; Inventory = ci.Inventory; UpdatePerks(); UpdateInventory(); }
public void AddCharacter(CharacterInfo ci) { Characters.Add(new CharacterCard(ci)); }
private void AddCharacterCard(CharacterInfo ci) { _gm.Characters.Add(new CharacterCard(ci)); UpdateCharacterCards(); }