Beispiel #1
0
        /// <summary>
        /// Battlesequence
        /// </summary>
        /// <param name="aPlayer">The player which will enter the sequence</param>
        public void BattleSequence(Player.Player aPlayer)
        {
            int
                tempWWD2 = Console.WindowWidth / 2,
                tempWHD2 = Console.WindowHeight / 2;
            bool
                tempHasFled = false;

            EnemyManager.Reset();
            if (!myIsBossRoom)
            {
                EnemyManager.SetEnemies(myEnemies);
            }
            else
            {
                EnemyManager.AddEnemy(myBoss);
            }
            while (!EnemyManager.AreEnemiesDefeated() && !tempHasFled)
            {
                float
                    tempDamageToDeal = 0;
                int
                    tempAoECount    = 0,
                    tempSpellChoice = 0;
                bool
                    tempShouldBeStunned = false;
                switch (aPlayer.ChooseBattleAction())
                {
                case Player.BattleActions.OFFENSIVE:
                    aPlayer.PrintUI();
                    Console.SetCursorPosition(tempWWD2 - 13, tempWHD2 - 12);
                    Console.Write(Language.GetMethodViolence());
                    Console.SetCursorPosition(tempWWD2 - 13, tempWHD2 - 10);
                    Console.Write("[1] " + Language.GetAttack());
                    Console.SetCursorPosition(tempWWD2 - 13, tempWHD2 - 9);
                    Console.Write("[2] " + Language.GetSpells());
                    switch (Utility.GetDigitInput(-12, -7, 2))
                    {
                    case 1:
                        aPlayer.PrintUI();
                        Console.SetCursorPosition(tempWWD2 - 13, tempWHD2 - 12);
                        Console.Write(Language.GetChooseAttack());
                        Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 10);
                        Console.Write("[1] " + Language.GetSlash());
                        Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 9);
                        Console.Write("[2] " + Language.GetSweep());
                        Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 8);
                        Console.Write("[3] " + Language.GetSlap());
                        switch (Utility.GetDigitInput(-19, -6, 3, 1))
                        {
                        case 1:
                            tempDamageToDeal = aPlayer.GetDamage();
                            break;

                        case 2:
                            tempDamageToDeal = aPlayer.GetDamage() * 0.55f;
                            tempAoECount     = 2;
                            break;

                        case 3:
                            tempDamageToDeal    = aPlayer.GetDamage() * 0.2f;
                            tempShouldBeStunned = true;
                            break;
                        }
                        break;

                    case 2:
                        aPlayer.PrintUI();
                        Console.SetCursorPosition(tempWWD2 - 13, tempWHD2 - 12);
                        Console.Write(Language.GetChooseSpell());
                        Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 10);
                        Console.Write("[1] " + Language.GetFirebolt());
                        Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 9);
                        Console.Write("[2] " + Language.GetFlamestrike());
                        Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 8);
                        Console.Write("[3] " + Language.GetFireball());
                        switch (Utility.GetDigitInput(-19, -6, 3, 1))
                        {
                        case 1:
                            if (aPlayer.GetMana() - 20 >= 0)
                            {
                                tempDamageToDeal = aPlayer.GetSpellDamage();
                                tempSpellChoice  = 1;
                                aPlayer.SetMana(20);
                            }
                            else
                            {
                                Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 4);
                                Console.Write(Language.GetInsufficientMana());
                                Thread.Sleep(1500);
                            }
                            break;

                        case 2:
                            if (aPlayer.GetMana() - 60 >= 0)
                            {
                                tempDamageToDeal = aPlayer.GetSpellDamage() * 0.55f;
                                tempAoECount     = 2;
                                tempSpellChoice  = 2;
                                aPlayer.SetMana(60);
                            }
                            else
                            {
                                Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 4);
                                Console.Write(Language.GetInsufficientMana());
                                Thread.Sleep(1500);
                            }
                            break;

                        case 3:
                            if (aPlayer.GetMana() - 120 >= 0)
                            {
                                tempDamageToDeal    = aPlayer.GetSpellDamage() * 5;
                                tempShouldBeStunned = true;
                                tempSpellChoice     = 3;
                                tempAoECount        = myEnemies.Count;
                                aPlayer.SetMana(120);
                            }
                            else
                            {
                                Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 4);
                                Console.Write(Language.GetInsufficientMana());
                                Thread.Sleep(1500);
                            }
                            break;
                        }
                        break;
                    }

                    if (tempAoECount == 0 && tempDamageToDeal > 0)
                    {
                        aPlayer.PrintUI();
                        Console.SetCursorPosition(tempWWD2 - 13, tempWHD2 - 12);
                        Console.WriteLine(Language.GetChooseEnemy());
                        if (!myIsBossRoom)
                        {
                            for (int i = 0; i < myEnemies.Count; i++)
                            {
                                string tempTypeString = string.Empty;
                                if (myEnemies[i].GetEnemyType() == EnemyType.ARCHER)
                                {
                                    tempTypeString = Language.GetArcher();
                                }
                                else if (myEnemies[i].GetEnemyType() == EnemyType.SKELETON)
                                {
                                    tempTypeString = Language.GetSkeleton();
                                }
                                Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 10 + i);
                                Console.Write("[" + (i + 1).ToString() + "] '" + tempTypeString + "'; " + Language.GetHealth() + " - " + Math.Round(myEnemies[i].GetHealth(), 2).ToString() + "; " + Language.GetArmour() + " - " + myEnemies[i].GetArmourRating().ToString());
                            }
                        }
                        else
                        {
                            Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 10);
                            Console.Write("[1] '" + myBoss.GetName() + "'; " + Language.GetHealth() + " - " + Math.Round(myBoss.GetHealth(), 2).ToString() + "; " + Language.GetArmour() + " - " + myBoss.GetArmourRating().ToString());
                        }
                        if (Utility.GetDigitInput(-2, -9 + myEnemies.Count, (myIsBossRoom ? 1 : myEnemies.Count), out int tempInputValue) <= myEnemies.Count && !myIsBossRoom)
                        {
                            aPlayer.PrintUI();
                            aPlayer.DealDamage(myEnemies[tempInputValue - 1], tempDamageToDeal, tempShouldBeStunned, tempSpellChoice);
                        }
                        else
                        {
                            aPlayer.PrintUI();
                            aPlayer.DealDamage(myBoss, tempDamageToDeal, tempShouldBeStunned, tempSpellChoice);
                        }
                    }
                    else
                    {
                        if (!myIsBossRoom && tempDamageToDeal > 0)
                        {
                            List <int> tempHitEnemiesIndex = new List <int>();
                            for (int i = 0; i < tempAoECount; i++)
                            {
                                int tempRandomIndex = Utility.GetRNG().Next(0, myEnemies.Count);
                                while (tempHitEnemiesIndex.Contains(tempRandomIndex))
                                {
                                    tempHitEnemiesIndex.Remove(tempRandomIndex);
                                    tempRandomIndex = Utility.GetRNG().Next(0, myEnemies.Count);
                                }
                                tempHitEnemiesIndex.Add(tempRandomIndex);
                                aPlayer.PrintUI();
                                aPlayer.DealDamage(myEnemies[tempRandomIndex], tempDamageToDeal, tempShouldBeStunned, tempSpellChoice);
                            }
                        }
                        else if (tempDamageToDeal > 0)
                        {
                            aPlayer.PrintUI();
                            aPlayer.DealDamage(myBoss, tempDamageToDeal, tempShouldBeStunned, tempSpellChoice);
                        }
                    }
                    if (tempSpellChoice == 3)
                    {
                        aPlayer.PrintUI();
                        aPlayer.TakeDamage(aPlayer.GetMaxHealth() * 0.6f, out float tempDamageTaken);
                        Console.SetCursorPosition(tempWWD2 - 18, tempWHD2 - 12);
                        Console.Write(Language.GetBurnSkin());
                        Console.SetCursorPosition(tempWWD2 - 10, tempWHD2 - 10);
                        Console.Write(Language.GetTakeDamagePt1());
                        Utility.PrintInColour(tempDamageTaken.ToString(), ConsoleColor.DarkRed);
                        Console.Write(Language.GetTakeDamagePt2());
                        Thread.Sleep(2000);
                    }
                    break;

                case Player.BattleActions.DEFENSIVE:
                    aPlayer.PrintUI();
                    Console.SetCursorPosition(tempWWD2 - 13, tempWHD2 - 12);
                    Console.Write(Language.GetChooseDefence());
                    Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 10);
                    Console.Write("[1] " + Language.GetRaiseShield());
                    Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 9);
                    Console.Write("[2] " + Language.GetHealingTouch());
                    Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 8);
                    Console.Write("[3] " + Language.GetSuperStun());
                    switch (Utility.GetDigitInput(-19, -6, 3, 1))
                    {
                    case 1:
                        aPlayer.PrintUI();
                        Console.SetCursorPosition(tempWWD2 - Language.GetRaiseDefencePt1().Length / 2, tempWHD2 - 11);
                        Console.Write(Language.GetRaiseDefencePt1());
                        Console.SetCursorPosition(tempWWD2 - Language.GetRaiseDefencePt2().Length / 2, tempWHD2 - 10);
                        Console.Write(Language.GetRaiseDefencePt2());
                        aPlayer.SetIsDefending(true);
                        break;

                    case 2:
                        aPlayer.PrintUI();
                        if (aPlayer.GetMana() - 30 < aPlayer.GetMana())
                        {
                            Console.SetCursorPosition(tempWWD2 - Language.GetBeginTouch().Length / 2, tempWHD2 - 11);
                            Console.Write(Language.GetBeginTouch());
                            Thread.Sleep(2000);
                            Console.SetCursorPosition(tempWWD2 - Language.GetMagicallyHeal().Length / 2, tempWHD2 - 9);
                            Console.Write(Language.GetMagicallyHeal());
                            float tempHealingAmount = 25 * (1 + aPlayer.GetWisdom() / 100f);
                            aPlayer.SetHealth(tempHealingAmount);
                            Console.SetCursorPosition(tempWWD2 - Language.GetRegain().Length / 2, tempWHD2 - 7);
                            Console.Write(Language.GetRegain());
                            Utility.PrintInColour(tempHealingAmount.ToString(), ConsoleColor.Green);
                            Console.Write(" " + Language.GetHealthLowerCase() + "!");
                            aPlayer.SetMana(20);
                        }
                        else
                        {
                            Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 4);
                            Console.Write(Language.GetInsufficientMana());
                        }
                        break;

                    case 3:
                        aPlayer.PrintUI();
                        if (aPlayer.GetMana() - 80 < aPlayer.GetMana())
                        {
                            Console.SetCursorPosition(tempWWD2 - Language.GetThrowPebblesPt1().Length / 2, tempWHD2 - 11);
                            Console.Write(Language.GetThrowPebblesPt1());
                            Console.SetCursorPosition(tempWWD2 - Language.GetThrowPebblesPt2().Length / 2, tempWHD2 - 10);
                            Console.Write(Language.GetThrowPebblesPt2());
                            if (myIsBossRoom)
                            {
                                myBoss.SetStunDuration(2);
                            }
                            else
                            {
                                foreach (Enemy tempEnemy in myEnemies)
                                {
                                    tempEnemy.SetStunDuration(2);
                                }
                            }
                            aPlayer.SetMana(80);
                        }
                        else
                        {
                            Console.SetCursorPosition(tempWWD2 - 20, tempWHD2 - 4);
                            Console.Write(Language.GetInsufficientMana());
                        }
                        break;
                    }
                    Thread.Sleep(2000);
                    break;

                case Player.BattleActions.USEITEM:
                    aPlayer.OpenInventory();
                    break;

                case Player.BattleActions.FLEE:
                    if (myIsBossRoom)
                    {
                        aPlayer.PrintUI();
                        Console.SetCursorPosition(tempWWD2 - Language.GetBossFlee().Length / 2, tempWHD2 - 11);
                        Console.Write(Language.GetBossFlee());
                        Thread.Sleep(1500);
                    }
                    else
                    {
                        tempHasFled = true;
                    }
                    break;

                case Player.BattleActions.ABSTAIN:
                    aPlayer.PrintUI();
                    Console.SetCursorPosition(tempWWD2 - Language.GetNoAttackPt1().Length / 2, tempWHD2 - 11);
                    Console.Write(Language.GetNoAttackPt1());
                    Console.SetCursorPosition(tempWWD2 - Language.GetNoAttackPt2().Length / 2, tempWHD2 - 10);
                    Console.Write(Language.GetNoAttackPt2());
                    Thread.Sleep(2000);
                    break;
                }
                EnemyManager.Update(aPlayer);
                aPlayer.Update();
            }
            if (!tempHasFled)
            {
                aPlayer.PrintUI();
                Console.SetCursorPosition(tempWWD2 - Language.GetAllDefeated().Length / 2, tempWHD2 - 12);
                if (myIsBossRoom)
                {
                    Console.Write(myBoss.GetName() + Language.GetBossDefeated());
                }
                else
                {
                    Console.Write(Language.GetAllDefeated());
                }
                aPlayer.SubtractStamina(10);
                Thread.Sleep(2000);
                aPlayer.PrintUI();
                LootSequence(aPlayer);
            }
            else
            {
                aPlayer.PrintUI();
                Console.SetCursorPosition(tempWWD2 - 18, tempWHD2 - 12);
                Console.Write(Language.GetFlee());
                aPlayer.SubtractStamina(30);
                Thread.Sleep(2000);
            }
        }