示例#1
0
        private void InitializeCharacter()
        {
            foreach (CoreAttribute stat in player.CharacterStats.CoreAttributes)
            {
                CoreStatTab newStat = new CoreStatTab(stat, this);
                newStat.Tag = stat;
                CoreStatPanel.Controls.Add(newStat);
                newStat.Dock = DockStyle.Bottom;
                newStat.Calculate();
                newStat.Show();
            }
            foreach (Stat save in player.CharacterStats.Saves)
            {
                SaveTab newSave = new SaveTab(save, this);
                newSave.Tag = save;
                foreach (Stat prof in player.CharacterStats.Proficiencies)
                {
                    if (prof.Name.Equals(newSave.cStat.Name))
                    {
                        newSave.Proficiency.Checked = true;
                    }
                }
                SavesPanel.Controls.Add(newSave);
                newSave.Dock = DockStyle.Bottom;
                newSave.Show();
            }
            foreach (Stat skill in player.CharacterStats.Skills)
            {
                SkillTab newSkill = new SkillTab(skill, this);
                newSkill.Tag = skill;
                foreach (Stat prof in player.CharacterStats.Proficiencies)
                {
                    if (prof.Name.Equals(newSkill.cStat.Name))
                    {
                        if (newSkill.Proficiency.Checked)
                        {
                            newSkill.Expertise.Checked = true;
                        }
                        else
                        {
                            newSkill.Proficiency.Checked = true;
                        }
                    }
                }
                SkillPanel.Controls.Add(newSkill);
                newSkill.Dock = DockStyle.Bottom;
                newSkill.Show();
            }

            StreamReader reader = new StreamReader("Movement.json");
            string       json   = reader.ReadToEnd();

            MovementTypes = JsonConvert.DeserializeObject <List <Stat> >(json);
            foreach (Stat speed in MovementTypes)
            {
                if (speed.Name.Equals("Normal"))
                {
                    player.CharacterStats.Speed.Add(speed);
                    MovementTab newspeed = new MovementTab(speed, this);
                    newspeed.Tag = speed;
                    MovementPanel.Controls.Add(newspeed);
                    newspeed.Dock = DockStyle.Bottom;
                    newspeed.Show();
                }
            }
            foreach (Attack atk in player.AttackList)
            {
                AttackTab newAtk = new AttackTab(atk, this);
                newAtk.Tag = atk;
                AttackPanel.Controls.Add(newAtk);
                newAtk.Dock = DockStyle.Bottom;
                newAtk.Show();
            }

            Refresh_Click(null, null);
        }
示例#2
0
        public void Refresh_Click(object sender, EventArgs e)
        {
            CharacterName.Text = player.CharacterName;
            player.CharacterStats.ProficiencyBonus.Reset();
            player.CharacterStats.ProficiencyBonus.Calculate();
            ProficiencyBonus.Text = "+" + player.CharacterStats.ProficiencyBonus.Value.ToString();

            Age.Text       = player.CharacterStats.Age;
            cHeight.Text   = player.CharacterStats.Height;
            Weight.Text    = player.CharacterStats.Weight;
            Alignment.Text = player.Alignment;
            player.CharacterStats.Size.Reset();
            player.CharacterStats.Size.Calculate();
            switch (player.CharacterStats.Size.Value)
            {
            case 0:
                cSize.Text = "Tiny";
                break;

            case 1:
                cSize.Text = "Small";
                break;

            case 2:
                cSize.Text = "Medium";
                break;

            case 3:
                cSize.Text = "Large";
                break;

            case 4:
                cSize.Text = "Huge";
                break;

            case 5:
                cSize.Text = "Gargantuan";
                break;

            default:
                cSize.Text = "";
                break;
            }

            PlayerName.Text = player.PlayerName;
            Religion.Text   = player.Religion;
            player.CharacterStats.MaxHitPoints.Reset();
            player.CharacterStats.MaxHitPoints.Calculate();
            MaxHP.Text = player.CharacterStats.MaxHitPoints.Value.ToString();

            CurrentHP.Text = player.CharacterStats.CurrentHitPoints.ToString();

            TempHP.Text = player.CharacterStats.TemporaryHitPoints.ToString();

            foreach (CoreStatTab statTab in CoreStatPanel.Controls)
            {
                ((CoreAttribute)statTab.Tag).Reset();
                statTab.Calculate();
            }
            player.CharacterStats.Initiative.Reset();
            player.CharacterStats.Initiative.Calculate();
            int totalInitiative = player.CharacterStats.Initiative.Value + player.CharacterStats.Dexterity.AbilityModifier;

            if (totalInitiative > 0)
            {
                Initiative.Text = "+" + totalInitiative.ToString();
            }
            else
            {
                Initiative.Text = totalInitiative.ToString();
            }
            player.CharacterStats.ArmorClass.Reset();
            player.CharacterStats.ArmorClass.Calculate();
            ArmorClass.Text = player.CharacterStats.ArmorClass.Value.ToString();
            foreach (SaveTab saveTab in SavesPanel.Controls)
            {
                ((Stat)saveTab.Tag).Reset();
                saveTab.Calculate();
            }

            foreach (SkillTab skillTab in SkillPanel.Controls)
            {
                ((Stat)skillTab.Tag).Reset();
                skillTab.Calculate();
            }
            List <MovementTab> removeList = new List <MovementTab>();
            bool firstThrough             = true;

            foreach (Stat speed in player.CharacterStats.Speed)
            {
                bool hasTab = false;
                foreach (MovementTab MoveTab in MovementPanel.Controls)
                {
                    if (firstThrough && !player.CharacterStats.Speed.Contains(MoveTab.Tag))
                    {
                        removeList.Add(MoveTab);
                    }
                    if (speed.Equals(MoveTab.Tag))
                    {
                        ((Stat)MoveTab.Tag).Reset();
                        MoveTab.Calculate();
                        hasTab = true;
                        if (!firstThrough)
                        {
                            break;
                        }
                    }
                }
                if (firstThrough)
                {
                    foreach (MovementTab remove in removeList)
                    {
                        MovementPanel.Controls.Remove(remove);
                    }
                }
                firstThrough = false;
                if (!hasTab)
                {
                    MovementTab newspeed = new MovementTab(speed, this);
                    newspeed.Tag = speed;
                    MovementPanel.Controls.Add(newspeed);
                    newspeed.Dock = DockStyle.Bottom;
                    newspeed.Calculate();
                    newspeed.Show();
                }
            }
            if (player.CharacterStats.Speed.Count == 0)
            {
                MovementPanel.Controls.Clear();
            }

            string levelString = "";

            foreach (PlayerClass pClass in player.PlayerClassList)
            {
                if (!string.IsNullOrEmpty(levelString))
                {
                    levelString += "\n";
                }
                levelString += "Lvl " + pClass.Level + " " + pClass.Name;
            }
            PlayerClassLabel.Text = levelString;
            TotalHitDice.Text     = "";
            //CurrentHitDice.Text = "";
            string hitDiceString = "";

            foreach (KeyValuePair <int, int> HitDie in player.HitDice)
            {
                if (!string.IsNullOrEmpty(hitDiceString))
                {
                    hitDiceString += "\\";
                }
                hitDiceString += HitDie.Value.ToString() + "d" + HitDie.Key.ToString();
            }
            TotalHitDice.Text    = hitDiceString;
            FeatDescription.Text = "";
            Feature selectedFeat = (Feature)FeatureListBox.SelectedItem;

            FeatureListBox.Items.Clear();
            foreach (Feature feat in player.FeatsNtraits)
            {
                FeatureListBox.Items.Add(feat);
            }
            if (FeatureListBox.Items.Count > 0)
            {
                if (selectedFeat != null && FeatureListBox.Items.Contains(selectedFeat))
                {
                    FeatureListBox.SelectedItem = selectedFeat;
                }
                else
                {
                    FeatureListBox.SelectedItem = FeatureListBox.Items[0];
                }
                Feature feat        = (Feature)FeatureListBox.SelectedItem;
                string  featureDesc = "";
                foreach (string featureline in feat.Description)
                {
                    featureDesc += featureline + "\n";
                }
                FeatDescription.Text = featureDesc;
            }

            Copper.Value   = player.Copper;
            Silver.Value   = player.Silver;
            Elisium.Value  = player.Elisium;
            Gold.Value     = player.Gold;
            Platinum.Value = player.Platinum;

            EquipmentDescription.Text = "";
            Equipment selectedEquip = (Equipment)EquipmentListBox.SelectedItem;

            EquipmentListBox.Items.Clear();
            foreach (Equipment equip in player.EquipmentList)
            {
                EquipmentListBox.Items.Add(equip);
            }
            if (EquipmentListBox.Items.Count > 0)
            {
                if (selectedEquip != null && EquipmentListBox.Items.Contains(selectedEquip))
                {
                    EquipmentListBox.SelectedItem = selectedEquip;
                }
                else
                {
                    EquipmentListBox.SelectedItem = EquipmentListBox.Items[0];
                }
                Equipment equip     = (Equipment)EquipmentListBox.SelectedItem;
                string    equipDesc = "";
                foreach (string equipline in equip.Description)
                {
                    equipDesc += equipline + "\n";
                }
                EquipmentDescription.Text = equipDesc;
            }
            firstThrough = true;
            bool             noneSelected = true;
            List <AttackTab> remList      = new List <AttackTab>();

            foreach (Attack atk in player.AttackList)
            {
                bool hasTab = false;
                foreach (AttackTab AtkTab in AttackPanel.Controls)
                {
                    if (firstThrough && !player.AttackList.Contains(AtkTab.Tag))
                    {
                        remList.Add(AtkTab);
                    }
                    if (atk.Equals(AtkTab.Tag))
                    {
                        AtkTab.Calculate();
                        hasTab = true;
                        if (AtkTab.Selected.Checked)
                        {
                            noneSelected = false;
                        }
                        if (!firstThrough)
                        {
                            break;
                        }
                    }
                }
                if (firstThrough)
                {
                    foreach (AttackTab remove in remList)
                    {
                        AttackPanel.Controls.Remove(remove);
                    }
                }
                firstThrough = false;
                if (!hasTab)
                {
                    AttackTab atkTab = new AttackTab(atk, this);
                    atkTab.Tag = atk;
                    AttackPanel.Controls.Add(atkTab);
                    atkTab.Dock = DockStyle.Bottom;
                    atkTab.Calculate();
                    atkTab.Show();
                }
            }
            if (noneSelected && AttackPanel.Controls.Count > 0)
            {
                ((AttackTab)AttackPanel.Controls[0]).Selected.Checked = true;
            }
        }