Exemplo n.º 1
0
        public ClassesForm(string gameName)
        {
            InitializeComponent();

            _classes = new List<EntityClass>();
            _gameName = gameName;
            _saved = true;

            string[] files = Directory.GetFiles(Application.StartupPath + @"\Games\" + _gameName + @"\stats");

            _stats = new List<Stat>();

            Stat stat;

            foreach (string file in files)
            {
                stat = GlobalFunctions.LoadStat(file);

                if (stat != null)
                {
                    cbStats.Items.Add(stat.Name);
                    _stats.Add(stat);
                }
            }

            files = Directory.GetFiles(Application.StartupPath + @"\Games\" + _gameName + @"\classes");

            EntityClass entityClass;

            foreach (string file in files)
            {

                entityClass = GlobalFunctions.LoadClass(file);

                if (entityClass != null)
                {
                    cbClasses.Items.Add(entityClass.Name);
                    _classes.Add(entityClass);
                }
            }

            cbDiceType.Items.AddRange(Enum.GetNames(typeof(DieType)));

            // Since we need a valid entityclass object to add stat modifiers, we'll create a temp class at the start
            // instead of when we add one to the list, as we do with the lists classes like stats

            _class = new EntityClass();
            _saved = true;
        }
Exemplo n.º 2
0
        private void cbClasses_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbClasses.SelectedIndex > -1)
            {

                _class = _classes[cbClasses.SelectedIndex];

                txtClassName.Text = _class.Name;
                txtClassDescription.Text = _class.Description;
                cbDiceType.SelectedIndex = GetIndexForType(_class.HPDice);
                cbModifiers.Items.Clear();

                int val;

                foreach (Stat stat in _stats)
                {
                    val = _class.GetStatModifier(stat.Abbreviation);
                    if (val != 0)
                    {
                        cbModifiers.Items.Add(stat.Name + ": " + val.ToString());
                    }
                }

                btnAdd.Enabled = false;
                btnUpdate.Enabled = true;

            }
        }
Exemplo n.º 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            SaveControlsData();

            _classes.Add(_class);
            cbClasses.Items.Add(txtClassName.Text);
            SetupForNewEntry();

            _saved = false;
            _class = new EntityClass();
        }