Esempio n. 1
0
        public SkillsForm(string gameName)
        {
            InitializeComponent();

            _curID = 1;

            _gameName = gameName;

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

            _skills = new List<Skill>();

            foreach (string file in files)
            {
                Skill skill = GlobalFunctions.LoadSkill(file);

                if (skill != null)
                {
                    _skills.Add(skill);

                    cboSkills.Items.Add(skill.Name);

                    if (skill.ID > _curID)
                        _curID = skill.ID;
                }
            }

            //increment greatest skill id for next skill
            _curID++;

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

            _classes = new List<EntityClass>();

            foreach (string file in files)
            {

                EntityClass entityClass = GlobalFunctions.LoadClass(file);

                if (entityClass != null)
                {
                    _classes.Add(entityClass);

                    lstCostClasses.Items.Add(entityClass.Name);
                    lstClassBonus.Items.Add(entityClass.Name);
                }
            }

            _stats = new List<Stat>();

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

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

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

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

            _races = new List<Race>();

            foreach (string file in files)
            {
                Race race = GlobalFunctions.LoadRace(file);

                if (race != null)
                {
                    _races.Add(race);

                    lstRaceBonus.Items.Add(race.Name);
                }
            }

            _skill = new Skill(_curID);

            _costs = new Dictionary<string, string>();
            _classBonuses = new Dictionary<string, int>();
            _levelBonuses = new List<MinMaxBonus>();
            _raceBonuses = new Dictionary<string, int>();
            _statBonuses = new Dictionary<string, MinMaxBonus>();

            _opposingSkillControlSource = new List<KeyValuePair<string, int>>();

            _saved = true;
        }
Esempio n. 2
0
        private void cboSkills_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboSkills.SelectedIndex > -1)
            {
                _skill = _skills[cboSkills.SelectedIndex];

                FillOpposingSkillCombo(_skill.ID);

                SetupFormForEntry(false);

                txtName.Text = _skill.Name;
                txtDescription.Text = _skill.Description;
                chkAlwaysOn.Checked = _skill.AlwaysOn;
                txtIcon.Text = _skill.IconFilename;
                cboOpposingSkill.SelectedValue = _skill.OpposingSkill;

                Array types = Enum.GetValues(typeof(SkillType));

                for (int i = 0; i < types.Length; i++)
                {
                    if ((SkillType)types.GetValue(i) == _skill.Type)
                    {
                        cboType.SelectedIndex = i;
                        break;
                    }
                }

                //set tabs controls
                foreach (KeyValuePair<string, string> kvp in _skill.Costs)
                {
                    lstSkillCosts.Items.Add(kvp.Key + ": " + kvp.Value);
                    lstCostClasses.Items.Remove(kvp.Key);
                }

                if (_skill.ClassBonuses != null)
                {
                    foreach (KeyValuePair<string, int> kvp in _skill.ClassBonuses)
                    {
                        lstClassBonuses.Items.Add(kvp.Key + ": " + kvp.Value.ToString());
                        lstClassBonus.Items.Remove(kvp.Key);
                    }
                }

                if (_skill.LevelBonuses != null)
                {
                    foreach (MinMaxBonus bonus in _skill.LevelBonuses)
                    {
                        lstLevelBonuses.Items.Add(bonus.Min.ToString() + "-" + bonus.Max.ToString() + ": " + bonus.Amount.ToString());
                    }
                }

                if (_skill.RaceBonuses != null)
                {
                    foreach (KeyValuePair<string, int> kvp in _skill.RaceBonuses)
                    {
                        lstRaceBonuses.Items.Add(kvp.Key + ": " + kvp.Value.ToString());
                        lstRaceBonus.Items.Remove(kvp.Key);
                    }
                }

                if (_skill.StatBonuses != null)
                {
                    foreach (KeyValuePair<string, MinMaxBonus> kvp in _skill.StatBonuses)
                    {
                        lstStatBonuses.Items.Add(kvp.Key + ": " + kvp.Value.Min.ToString() + "-" + kvp.Value.Max.ToString() + " - " + kvp.Value.Amount.ToString());
                        lstStatBonus.Items.Remove(kvp.Key);
                    }
                }

                btnUpdate.Enabled = true;
            }
        }
Esempio n. 3
0
        private void btnAdd_Click_1(object sender, EventArgs e)
        {
            FillSkillObject();

            if (_skills == null)
                _skills = new List<Skill>();

            _skills.Add(_skill);
            cboSkills.Items.Add(_skill.Name);
            _curID++;
            _skill = new Skill(_curID);

            SetupFormForEntry();

            _saved = false;
        }