コード例 #1
0
ファイル: ArmorSet.cs プロジェクト: celpel/Coding-Portfolio
        public void SetSkillLists()
        {
            Dictionary <string, Skill> playerSkills = new Dictionary <string, Skill>(); // dictionary of skill name + skill

            foreach (Armor armor in Armor)
            {
                foreach (Skill skill in armor.ActiveSkills)
                {
                    if (playerSkills.ContainsKey(skill.Name))
                    {
                        playerSkills[skill.Name].Multiplier += skill.Multiplier;
                    }
                    else
                    {
                        playerSkills.Add(skill.Name, new Skill
                        {
                            Name       = skill.Name,
                            S_Type     = skill.S_Type,
                            Damage     = skill.Damage,
                            Element    = skill.Element,
                            Multiplier = skill.Multiplier
                        });
                    }
                }
            }

            ActiveSkills = new List <Skill>();

            ActiveSkills.AddRange(playerSkills.Values);

            ActiveSkills = ActiveSkills.OrderByDescending(a => SkillManager.CalculateDamage(a.Damage, a.Multiplier)).ToList();

            playerSkills = new Dictionary <string, Skill>();

            // this is editting the ReserveSkill passive itself. if you want to have it
            // so you can unequip/equip these skills, you need to have playerSkills.Add(passive.name, new Skill {...});
            foreach (Skill passive in ReserveSkills)
            {
                if (playerSkills.ContainsKey(passive.Name))
                {
                    playerSkills[passive.Name].Multiplier += passive.Multiplier;
                }
                else
                {
                    playerSkills.Add(passive.Name, passive);
                }
            }

            ReserveSkills = new List <Skill>();

            foreach (KeyValuePair <string, Skill> kvp in playerSkills)
            {
                ReserveSkills.Add(kvp.Value);
            }
        }
コード例 #2
0
 public override string ToString()
 {
     if (Damage > 0)
     {
         return($"[{SkillManager.CalculateDamage(Damage, Multiplier)}] {Name} +{Multiplier}");
     }
     else
     {
         return($"{Name} +{Multiplier}");
     }
 }
コード例 #3
0
        private void button1_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                if (rm.ReserveRelics.Count < 50)
                {
                    var v = new Random();
                    RelicInformation.Text = "";

                    Relic r = new Relic();

                    r.Name      = "";
                    r.Damage    = 0;
                    r.Elements  = new List <int>();
                    r.RelicType = v.Next(0, 3);

                    foreach (Skill s in selectedArmor.ActiveSkills)
                    {
                        r.Name   += $"[{SkillManager.ElementToString(s.Element)}]";
                        r.Damage += (int)(SkillManager.CalculateDamage(s.Damage, s.Multiplier) * .05);
                        r.Elements.Add(s.Element);
                    }

                    r.Damage = r.Damage / 2;

                    rm.Current = r;
                    rm.ReserveRelics.Add(rm.Current);

                    UpdateCurrentRelic(r);

                    DeleteArmorInRelicDisplay();

                    UpdateRelics();
                }
                else
                {
                    MessageBox.Show("Unable to create new relic. You have too many already.");
                }
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("You need to select armor first before you can craft a relic.");
            }
        }
コード例 #4
0
        private void EnemyAttack()
        {
            if (eTurn == d.enemies.Count)
            {
                eTurn = 0;
            }

            Enemy attacker = d.enemies[eTurn];

            if (attacker.hp > 0)
            {
                Skill s = attacker.active[r.Next(0, attacker.active.Count)];

                CombatLog.AppendText($"{attacker.name} used {s.Name}");
                CombatLog.AppendText(Environment.NewLine);

                int h = r.Next(0, 100);

                if (h < 95)
                {
                    int damage = SkillManager.CalculateDamage(s.Damage, s.Multiplier);

                    damage -= p.resistances[s.Element];

                    bool crit = IsCritHit();

                    if (crit)
                    {
                        damage = (damage * 2); // crit damage
                        tp.HalfTurn();
                    }
                    else
                    {
                        tp.FullTurn();
                    }

                    string log;

                    if (PlayerHealth.Value - damage <= 0)
                    {
                        timer.Stop();
                        PlayerHealth.Value = 0;
                        tp.turnEnd         = true;
                        log = "You died! Returning you back to the Select Dungeon screen...";
                        MessageBox.Show(log);
                        Run();
                    }
                    else
                    {
                        log = $"It hit for {damage} damage.";

                        int v = PlayerHealth.Value - damage;

                        if (v >= PlayerHealth.Maximum)
                        {
                            PlayerHealth.Value = PlayerHealth.Maximum;
                        }
                        else
                        {
                            PlayerHealth.Value -= damage;
                        }

                        CombatLog.AppendText(log);
                        CombatLog.AppendText(Environment.NewLine);
                        CombatLog.AppendText(Environment.NewLine);
                    }
                }
                else
                {
                    CombatLog.AppendText("The attack missed.");
                    CombatLog.AppendText(Environment.NewLine);
                    CombatLog.AppendText(Environment.NewLine);
                    tp.Miss();
                }

                CheckTurnEnemies();
            }
            eTurn++;
        }
コード例 #5
0
        private void ReduceBar(ProgressBar bar, int index, Skill skill, TextBox e_box)
        {
            Enemy target = d.enemies[index];

            // generalize this for boss battle
            bool critWeak = false;

            int damage = SkillManager.CalculateDamage(skill.Damage, skill.Multiplier) + p.stats[Stat.ATTACK];

            if (p.elementalAttackModifier[skill.Element] == 1)
            {
                damage += (int)(damage * .25);
            }

            int c = r.Next(0, 100);

            if (c < 25)
            {
                damage = (damage * 2) + p.stats[Stat.CRITS]; // crit damge + critboost
                CombatLog.AppendText("A critical was hit.");
                CombatLog.AppendText(Environment.NewLine);
                critWeak = true;
            }

            if (d.enemies[index].weakness.Contains(skill.Element))
            {
                damage = (damage * 2) + p.stats[Stat.CRITS]; // treated like crits too
                CombatLog.AppendText($"A weakness was hit! {target.name} was weak to {SkillManager.ElementToString(skill.Element)}!");

                if (d.IsNewWeakness(target.image, skill.Element))
                {
                    d.NewWeaknessFound(target, skill.Element);
                    e_box.Text = target.weakName;
                    UpdateTextBoxes();
                }

                CombatLog.AppendText(Environment.NewLine);
                critWeak = true;
            }

            if (d.isBoss)
            {
                DamageBoss(target, damage);
                CombatLog.AppendText($"It hit for {damage} damage.");
                CombatLog.AppendText(Environment.NewLine);
                CombatLog.AppendText(Environment.NewLine);
            }
            else
            {
                DamageEnemy(target, bar, damage, index);
            }

            if (critWeak)
            {
                tp.HalfTurn();
            }
            else
            {
                tp.FullTurn();
            }

            if (!d.isBoss)
            {
                CheckHP();
            }
            CheckTurnPlayer();
        }