Example #1
0
        private void Battle()
        {
            if (EnemyType == false)
            {
                int previousHPPlayer = MainPlayer.EntityStats.charHP;
                int previousEnemyHP  = EnemyBandit.EntityStats.charHP;
                EnemyChosen = EnemyBandit.EntitySkills.PhysicalSkills[random.Next(0, EnemyBandit.EntitySkills.PhysicalSkills.Count)];
                int TurnLocker = 0;
                //If player dex is higher, player attacks first
                if ((MainPlayer.EntityStats.charDex > EnemyBandit.EntityStats.charDex) && (TurnLocker == 0))
                {
                    if (random.Next(0, 101) < PlayerChosen.SkillAccuracy)
                    {
                        if (AttackType == 1)
                        {
                            MainPlayerSprite.AnimateOnce(1);
                            EnemyBandit.EntityStats.charHP -= (MainPlayer.GenerateDamage() * PlayerChosen.SkillPower) / 10;
                            GameOuputLabel.Text             = MainPlayer.EntityName + " has used " + PlayerChosen.SkillName + " and dealt " + (previousEnemyHP - EnemyBandit.EntityStats.charHP) + " to " + EnemyBandit.EntityName + " leaving them on " + EnemyBandit.EntityStats.charHP;
                        }

                        if (AttackType == 2)
                        {
                            Console.WriteLine(PlayerChosen.SkillCost);
                            Console.WriteLine(MainPlayer.EntityStats.charMP);
                            if (PlayerChosen.SkillCost <= MainPlayer.EntityStats.charMP)
                            {
                                MainPlayerSprite.AnimateOnce(2);
                                EnemyBandit.EntityStats.charHP -= (MainPlayer.GenerateDamage() * PlayerChosen.SkillPower) / 10;
                                GameOuputLabel.Text             = MainPlayer.EntityName + " has used " + PlayerChosen.SkillName + " and dealt " + (previousEnemyHP - EnemyBandit.EntityStats.charHP) + " to " + EnemyBandit.EntityName + " leaving them on " + EnemyBandit.EntityStats.charHP;
                                MainPlayer.EntityStats.charMP  -= PlayerChosen.SkillCost;
                            }
                            else
                            {
                                GameOuputLabel.Text = MainPlayer.EntityName + " does not have the MP to cast that spell!";
                            }
                        }

                        if (AttackType == 3)
                        {
                            MainPlayerSprite.AnimateOnce(2);
                            MainPlayer.EntityStats.charHP += (MainPlayer.GenerateDamage() * PlayerChosen.SkillPower) / 10;
                            GameOuputLabel.Text            = MainPlayer.EntityName + " has used " + PlayerChosen.SkillName + " and healed " + (MainPlayer.EntityStats.charHP - previousHPPlayer) + " restoring them to " + MainPlayer.EntityStats.charHP;
                            previousHPPlayer = MainPlayer.EntityStats.charHP;
                        }
                        if (EnemyBandit.EntityStats.charHP <= 0)
                        {
                            GameOuputLabel.Text += "\n" + MainPlayer.EntityName + " has defeated " + EnemyBandit.EntityName;
                            TurnLocker           = 2;
                        }
                    }
                    else
                    {
                        GameOuputLabel.Text = MainPlayer.EntityName + " missed!";
                    }
                    TurnLocker = 1;
                }
                if ((MainPlayer.EntityStats.charDex > EnemyBandit.EntityStats.charDex) && (TurnLocker == 1))
                {
                    if (random.Next(0, 101) < EnemyChosen.SkillAccuracy)
                    {
                        EnemySprite.AnimateOnce(1);
                        MainPlayer.EntityStats.charHP -= ((EnemyBandit.GenerateDamage() * EnemyChosen.SkillPower) / 10) - MainPlayer.GenerateMigitation();
                        GameOuputLabel.Text           += "\n" + EnemyBandit.EntityName + " has used " + EnemyChosen.SkillName + " and dealt " + (previousHPPlayer - MainPlayer.EntityStats.charHP) + " to " + MainPlayer.EntityName + " leaving them on " + MainPlayer.EntityStats.charHP;
                        if (MainPlayer.EntityStats.charHP <= 0)
                        {
                            GameOuputLabel.Text += "\n" + EnemyBandit.EntityName + " has defeated " + MainPlayer.EntityName;
                            TurnLocker           = 2;
                        }
                    }
                    else
                    {
                        GameOuputLabel.Text += "\n" + EnemyBandit.EntityName + " missed!";
                    }
                }
                //If enemy dex is higher, enemy attacks first
                if ((EnemyBandit.EntityStats.charDex > MainPlayer.EntityStats.charDex) && (TurnLocker == 0))
                {
                    if (random.Next(0, 101) < EnemyChosen.SkillAccuracy)
                    {
                        EnemySprite.AnimateOnce(1);
                        MainPlayer.EntityStats.charHP -= ((EnemyBandit.GenerateDamage() * EnemyChosen.SkillPower) / 10) - MainPlayer.GenerateMigitation();
                        GameOuputLabel.Text            = EnemyBandit.EntityName + " has used " + EnemyChosen.SkillName + " and dealt " + (previousHPPlayer - MainPlayer.EntityStats.charHP) + " to " + MainPlayer.EntityName + " leaving them on " + MainPlayer.EntityStats.charHP;
                        if (MainPlayer.EntityStats.charHP <= 0)
                        {
                            GameOuputLabel.Text += "\n" + EnemyBandit.EntityName + " has defeated " + MainPlayer.EntityName;
                            TurnLocker           = 2;
                        }
                    }
                    else
                    {
                        GameOuputLabel.Text = EnemyBandit.EntityName + " missed!";
                    }
                    TurnLocker = 1;
                }
                if ((EnemyBandit.EntityStats.charDex > MainPlayer.EntityStats.charDex) && (TurnLocker == 1))
                {
                    if (random.Next(0, 101) < PlayerChosen.SkillAccuracy)
                    {
                        if (AttackType == 1)
                        {
                            MainPlayerSprite.AnimateOnce(1);
                            EnemyBandit.EntityStats.charHP -= (MainPlayer.GenerateDamage() * PlayerChosen.SkillPower) / 10;
                            GameOuputLabel.Text             = MainPlayer.EntityName + " has used " + PlayerChosen.SkillName + " and dealt " + (previousEnemyHP - EnemyBandit.EntityStats.charHP) + " to " + EnemyBandit.EntityName + " leaving them on " + EnemyBandit.EntityStats.charHP;
                        }
                        if (AttackType == 2)
                        {
                            if (PlayerChosen.SkillCost <= MainPlayer.EntityStats.charMP)
                            {
                                MainPlayerSprite.AnimateOnce(2);
                                EnemyBandit.EntityStats.charHP -= (MainPlayer.GenerateDamage() * PlayerChosen.SkillPower) / 10;
                                GameOuputLabel.Text             = MainPlayer.EntityName + " has used " + PlayerChosen.SkillName + " and dealt " + (previousEnemyHP - EnemyBandit.EntityStats.charHP) + " to " + EnemyBandit.EntityName + " leaving them on " + EnemyBandit.EntityStats.charHP;
                                MainPlayer.EntityStats.charMP  -= PlayerChosen.SkillCost;
                            }
                            else
                            {
                                GameOuputLabel.Text = MainPlayer.EntityName + " does not have the MP to cast that spell!";
                            }
                        }
                        if (AttackType == 3)
                        {
                            MainPlayerSprite.AnimateOnce(2);
                            MainPlayer.EntityStats.charHP += (MainPlayer.GenerateDamage() * PlayerChosen.SkillPower) / 10;
                            GameOuputLabel.Text            = MainPlayer.EntityName + " has used " + PlayerChosen.SkillName + " and healed " + (MainPlayer.EntityStats.charHP - previousHPPlayer) + " restoring them to " + MainPlayer.EntityStats.charHP;
                            previousHPPlayer = MainPlayer.EntityStats.charHP;
                        }
                        if (EnemyBandit.EntityStats.charHP <= 0)
                        {
                            GameOuputLabel.Text += "\n" + MainPlayer.EntityName + " has defeated " + EnemyBandit.EntityName;
                            TurnLocker           = 2;
                        }
                    }
                    else
                    {
                        GameOuputLabel.Text += "\n" + MainPlayer.EntityName + " missed!";
                    }
                }
            }
            if (EnemyType == true)
            {
                int previousHPPlayer = MainPlayer.EntityStats.charHP;
                int previousEnemyHP  = EnemySlime.EntityStats.charHP;
                EnemyChosen = EnemySlime.EntitySkills.MagicalSkills[random.Next(0, EnemySlime.EntitySkills.MagicalSkills.Count)];
                int TurnLocker = 0;
                //If player dex is higher, player attacks first
                if ((MainPlayer.EntityStats.charDex > EnemySlime.EntityStats.charDex) && (TurnLocker == 0))
                {
                    if (random.Next(0, 101) < PlayerChosen.SkillAccuracy)
                    {
                        if (AttackType == 1)
                        {
                            MainPlayerSprite.AnimateOnce(1);
                            EnemySlime.EntityStats.charHP -= (MainPlayer.GenerateDamage() * PlayerChosen.SkillPower) / 10;
                            GameOuputLabel.Text            = MainPlayer.EntityName + " has used " + PlayerChosen.SkillName + " and dealt " + (previousEnemyHP - EnemySlime.EntityStats.charHP) + " to " + EnemySlime.EntityName + " leaving them on " + EnemySlime.EntityStats.charHP;
                        }
                        if (AttackType == 2)
                        {
                            if (PlayerChosen.SkillCost <= MainPlayer.EntityStats.charMP)
                            {
                                MainPlayerSprite.AnimateOnce(2);
                                EnemySlime.EntityStats.charHP -= (MainPlayer.GenerateDamage() * PlayerChosen.SkillPower) / 10;
                                GameOuputLabel.Text            = MainPlayer.EntityName + " has used " + PlayerChosen.SkillName + " and dealt " + (previousEnemyHP - EnemySlime.EntityStats.charHP) + " to " + EnemySlime.EntityName + " leaving them on " + EnemySlime.EntityStats.charHP;
                                MainPlayer.EntityStats.charMP -= PlayerChosen.SkillCost;
                            }
                            else
                            {
                                GameOuputLabel.Text = MainPlayer.EntityName + " does not have the MP to cast that spell!";
                            }
                        }
                        if (AttackType == 3)
                        {
                            MainPlayerSprite.AnimateOnce(2);
                            MainPlayer.EntityStats.charHP += (MainPlayer.GenerateDamage() * PlayerChosen.SkillPower) / 10;
                            GameOuputLabel.Text            = MainPlayer.EntityName + " has used " + PlayerChosen.SkillName + " and healed " + (MainPlayer.EntityStats.charHP - previousHPPlayer) + " restoring them to " + MainPlayer.EntityStats.charHP;
                            previousHPPlayer = MainPlayer.EntityStats.charHP;
                        }
                        if (EnemySlime.EntityStats.charHP <= 0)
                        {
                            GameOuputLabel.Text += "\n" + MainPlayer.EntityName + " has defeated " + EnemySlime.EntityName;
                            TurnLocker           = 2;
                        }
                    }
                    else
                    {
                        GameOuputLabel.Text = MainPlayer.EntityName + " missed!";
                    }
                    TurnLocker = 1;
                }
                if ((MainPlayer.EntityStats.charDex > EnemySlime.EntityStats.charDex) && (TurnLocker == 1))
                {
                    if (random.Next(0, 101) < EnemyChosen.SkillAccuracy)
                    {
                        EnemySprite.AnimateOnce(2);
                        MainPlayer.EntityStats.charHP -= (EnemySlime.GenerateDamage() * EnemyChosen.SkillPower) / 10;
                        GameOuputLabel.Text           += "\n" + EnemySlime.EntityName + " has used " + EnemyChosen.SkillName + " and dealt " + (previousHPPlayer - MainPlayer.EntityStats.charHP) + " to " + MainPlayer.EntityName + " leaving them on " + MainPlayer.EntityStats.charHP;
                        if (MainPlayer.EntityStats.charHP <= 0)
                        {
                            GameOuputLabel.Text += "\n" + EnemySlime.EntityName + " has defeated " + MainPlayer.EntityName;
                            TurnLocker           = 2;
                        }
                    }
                    else
                    {
                        GameOuputLabel.Text += "\n" + EnemySlime.EntityName + " missed!";
                    }
                }
                //If enemy dex is higher, enemy attacks first
                if ((EnemySlime.EntityStats.charDex > MainPlayer.EntityStats.charDex) && (TurnLocker == 0))
                {
                    if (random.Next(0, 101) < EnemyChosen.SkillAccuracy)
                    {
                        EnemySprite.AnimateOnce(2);
                        MainPlayer.EntityStats.charHP -= (EnemySlime.GenerateDamage() * EnemyChosen.SkillPower) / 10;
                        GameOuputLabel.Text            = EnemySlime.EntityName + " has used " + EnemyChosen.SkillName + " and dealt " + (previousHPPlayer - MainPlayer.EntityStats.charHP) + " to " + MainPlayer.EntityName + " leaving them on " + MainPlayer.EntityStats.charHP;
                        if (EnemySlime.EntityStats.charHP <= 0)
                        {
                            GameOuputLabel.Text += "\n" + EnemySlime.EntityName + " has defeated " + MainPlayer.EntityName;
                            TurnLocker           = 2;
                        }
                    }
                    else
                    {
                        GameOuputLabel.Text = EnemySlime.EntityName + " missed!";
                    }
                    TurnLocker = 1;
                }
                if ((EnemySlime.EntityStats.charDex > MainPlayer.EntityStats.charDex) && (TurnLocker == 1))
                {
                    if (random.Next(0, 101) < PlayerChosen.SkillAccuracy)
                    {
                        if (AttackType == 1)
                        {
                            MainPlayerSprite.AnimateOnce(1);
                            EnemySlime.EntityStats.charHP -= (MainPlayer.GenerateDamage() * PlayerChosen.SkillPower) / 10;
                            GameOuputLabel.Text            = MainPlayer.EntityName + " has used " + PlayerChosen.SkillName + " and dealt " + (previousEnemyHP - EnemySlime.EntityStats.charHP) + " to " + EnemySlime.EntityName + " leaving them on " + EnemySlime.EntityStats.charHP;
                        }
                        if (AttackType == 2)
                        {
                            if (PlayerChosen.SkillCost <= MainPlayer.EntityStats.charMP)
                            {
                                MainPlayerSprite.AnimateOnce(2);
                                EnemySlime.EntityStats.charHP -= (MainPlayer.GenerateDamage() * PlayerChosen.SkillPower) / 10;
                                GameOuputLabel.Text            = MainPlayer.EntityName + " has used " + PlayerChosen.SkillName + " and dealt " + (previousEnemyHP - EnemySlime.EntityStats.charHP) + " to " + EnemySlime.EntityName + " leaving them on " + EnemySlime.EntityStats.charHP;
                                MainPlayer.EntityStats.charMP -= PlayerChosen.SkillCost;
                            }
                            else
                            {
                                GameOuputLabel.Text = MainPlayer.EntityName + " does not have the MP to cast that spell!";
                            }
                        }
                        if (AttackType == 3)
                        {
                            MainPlayerSprite.AnimateOnce(2);
                            MainPlayer.EntityStats.charHP += (MainPlayer.GenerateDamage() * PlayerChosen.SkillPower) / 10;
                            GameOuputLabel.Text            = MainPlayer.EntityName + " has used " + PlayerChosen.SkillName + " and healed " + (MainPlayer.EntityStats.charHP - previousHPPlayer) + " restoring them to " + MainPlayer.EntityStats.charHP;
                            previousHPPlayer = MainPlayer.EntityStats.charHP;
                        }
                        if (MainPlayer.EntityStats.charHP <= 0)
                        {
                            GameOuputLabel.Text += "\n" + EnemySlime.EntityName + " has defeated " + MainPlayer.EntityName;
                            TurnLocker           = 2;
                        }
                    }
                    else
                    {
                        GameOuputLabel.Text += MainPlayer.EntityName + " missed!";
                    }
                }
            }
            AttackPrompt = false;
            PlayerChosen = default(Abilities);
            EnemyChosen  = default(Abilities);
            RefreshAllLabels();
        }