Esempio n. 1
0
        //used when a player attacks an enemy
        public static int AttackEnemy(Entity enemy, Entity player)
        {
            int playerAttack = player.UseAttack();
            int chance       = ConsoleEffects.RandomNumber(1, 5);

            if (chance <= 3)
            {
                enemy.Health -= player.Attack;
                Console.WriteLine("\r\n" + player.Name + " hit " + enemy.Name + " for " + playerAttack + ".");
                CheckHealth(enemy);
                ConsoleEffects.TypeLine(enemy.Name + " has " + enemy.Health + " health.\r\n\r\n");
                return(enemy.Health);
            }
            //double attack
            else if (chance == 4)
            {
                Console.WriteLine("\r\n" + player.Name + " hit " + enemy.Name + " for " + playerAttack + ".");
                System.Threading.Thread.Sleep(500);
                //possible random to decide damage
                int secondPlayerAttack = player.UseAttack();
                enemy.Health -= (playerAttack + secondPlayerAttack);
                ConsoleEffects.ColorTextGreen(player.Name + " hits for a second attacks. " + player.Name + " hit " + enemy.Name + " for " + secondPlayerAttack + ".");
                CheckHealth(enemy);
                ConsoleEffects.TypeLine(enemy.Name + " has " + enemy.Health + " health.\r\n\r\n");

                return(enemy.Health);
            }
            else if (chance == 5)
            {
                Console.WriteLine(enemy.Name + " dodged the attack.\r\n\r\n");
                return(enemy.Health);
            }
            return(enemy.Health);
        }