コード例 #1
0
        public StatsForm(Creature creature)
        {
            InitializeComponent();
            StartPosition = FormStartPosition.CenterScreen;

            //set secondary attribute textboxes to readonly
            tbArmorClass.ReadOnly    = true;
            tbInitiative.ReadOnly    = true;
            tbSpeed.ReadOnly         = true;
            tbPassiveWisdom.ReadOnly = true;

            //set the creature and the public Creature property for this form
            if (creature != null)
            {
                Creature = creature;
                Stat     = creature.GetCharaStatistic() ?? new CharaStatistic();

                DisplayCreatureOnLoad(creature);
            }
            else
            {
                MessageBox.Show("Cannot changes the stats of a character that doesn't exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                DialogResult = DialogResult.Cancel;
                Close();
            }

            BringToFront();
        }
コード例 #2
0
        public SkillsForm(CharaStatistic stat)
        {
            InitializeComponent();
            StartPosition = FormStartPosition.CenterScreen;

            if (stat != null)
            {
                Stat = stat;

                //these BindingLists are built from a dictionary and should always correspond
                //for example, ONE skill entry should ALWAYS correspond to ONE level entry
                //having an skill entry without a level entry or vice-versa is invalid
                _skills = BuildBindingList(Stat.Skills.Keys.ToList());
                _levels = BuildBindingList(Stat.Skills.Values.ToList());

                if (_skills.Count != _levels.Count)
                {
                    MessageBox.Show("Could not parse the Skills dictionary because the number of keys and values do not match.",
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    DialogResult = DialogResult.Cancel;

                    Close();
                }

                cbSkills.DataSource = Enum.GetValues(typeof(Skills));
                lbSkills.DataSource = _skills;
                lbLevels.DataSource = _levels;
            }
        }
コード例 #3
0
        public EquipmentForm(CharaStatistic stat)
        {
            InitializeComponent();
            StartPosition = FormStartPosition.CenterScreen;

            if (stat != null)
            {
                Stat = stat;

                //these BindingLists are built from a dictionary and should always correspond
                //for example, ONE equipment entry should ALWAYS correspond to ONE weight entry
                //having an equipment entry without a weight entry or vice-versa is invalid
                _equipment = BuildBindingList(Stat.Equipment.Keys.ToList());
                _weight    = BuildBindingList(Stat.Equipment.Values.ToList());

                if (_equipment.Count != _weight.Count)
                {
                    MessageBox.Show("Could not parse the Equipment dictionary because the number of keys and values do not match.",
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    DialogResult = DialogResult.Cancel;

                    Close();
                }

                lbEquipment.DataSource = _equipment;
                lbWeight.DataSource    = _weight;
            }
        }
コード例 #4
0
        public ProficienciesForm(CharaStatistic stat)
        {
            InitializeComponent();
            StartPosition = FormStartPosition.CenterScreen;

            if (stat != null)
            {
                Stat = stat;

                lbProficiencies.DataSource    = Stat.Proficiencies;
                lbProficiencies.DisplayMember = "Proficiencies";
            }
        }
コード例 #5
0
        public void WriteStatsToXML(string path, CharaStatistic stats)
        {
            if (!string.IsNullOrEmpty(path) && stats != null)
            {
                var serializer = new DataContractSerializer(typeof(CharaStatistic));

                using (var sw = new StreamWriter(path))
                {
                    using (var writer = new XmlTextWriter(sw))
                    {
                        writer.Formatting = Formatting.Indented;
                        serializer.WriteObject(writer, stats);
                        writer.Flush();
                    }
                }
            }
        }
コード例 #6
0
 public void RebuildProficiency(CharaStatistic statistic)
 {
     _proficiencies = statistic.Proficiencies;
 }