Пример #1
0
        public static void Main()
        {
            /*Instatiate both player and enemy. ChooseClass is called when
             * creating player object to decide which inherited member to assign.*/
            Npc    enemyNpc1   = new Npc();
            Player firstPlayer = Player.ChooseClass();

            if (firstPlayer.Health > 0)
            {
                NpcTimer(firstPlayer, enemyNpc1);
            }

            while (GameFunctions.gameOn)
            {
                if (firstPlayer.Health <= 0)
                {
                    Console.Clear();
                    Console.WriteLine($"The {enemyNpc1.NpcRace} {enemyNpc1.NpcClass} has killed you. You got {GameFunctions.killCounter} kills! Type 'Exit' or 'Restart'.");
                    string exitText = Console.ReadLine();
                    GameFunctions.Outcome(exitText, firstPlayer, enemyNpc1);
                }
                else if (enemyNpc1.Health <= 0)
                {
                    GameFunctions.AddToEnemyLog($"{enemyNpc1.NpcRace} {enemyNpc1.NpcClass} died!");
                    enemyNpc1.DropItem(firstPlayer);
                    GameFunctions.NewEnemy(enemyNpc1);
                }
                else
                {
                    CombatMenu(firstPlayer, enemyNpc1);
                    firstPlayer.PlayerChoice(enemyNpc1);
                }
            }
        }
Пример #2
0
        public void NpcChoice(Player name)
        {
            if (HitOrHeal())
            {
                if (IsAccuracySuccessful())
                {
                    short dmg = GameFunctions.RndNext(11, 16);
                    name.Health -= dmg;

                    //clamp health to not go below 0
                    if (name.Health < 0)
                    {
                        name.Health = 0;
                    }
                    else //Gives each foe a unique roleplay element.
                    {
                        if (NpcClass == NpcClasses.Warrior)
                        {
                            GameFunctions.AddToEnemyLog($"The {NpcRace} {NpcClass} slashed their sword at you for {dmg} damage!");
                        }
                        else if (NpcClass == NpcClasses.Rogue)
                        {
                            GameFunctions.AddToEnemyLog($"The {NpcRace} {NpcClass} threw a knife at you for {dmg} damage!");
                        }
                        else if (NpcClass == NpcClasses.Mage)
                        {
                            GameFunctions.AddToEnemyLog($"The {NpcRace} {NpcClass} hurled a fireball at you for {dmg} damage!");
                        }
                    }
                }
                else
                {
                    GameFunctions.AddToEnemyLog($"{NpcRace} {NpcClass} missed!");
                }
            }
            else
            {
                short heal      = GameFunctions.RndNext(12, 16);
                short newHealth = (short)(Health + heal);

                //Clamp health to not go above 100
                if (newHealth > 100)
                {
                    newHealth = 100;
                }

                //Swap placeholder health(newHealth) back into health
                Health = newHealth;
                GameFunctions.AddToEnemyLog($"{NpcRace} {NpcClass} healed by {heal}.");
            }
        }
Пример #3
0
        public void DropItem(Player player)
        {
            if (GameFunctions.RndNextDouble() > _dropChance)
            {
                switch (GameFunctions.RndNext(1, 3))
                {
                case 1:
                    GameFunctions.AddToEnemyLog($"The {NpcRace} dropped a {player.HealItemsType}!");
                    player.HealItems++;
                    break;

                case 2:
                    GameFunctions.AddToEnemyLog($"The {NpcRace} dropped a potion labeled 'Special Attack!'");
                    player.SpecialMoves++;
                    break;
                }
            }
        }