Ejemplo n.º 1
0
        public int ChooseTarget(Herd dinosaurHerd)
        {
            Console.WriteLine("Choose " + name + "'s (HP " + health + ")  target: ");
            int targetNum = 1;

            //displays targets
            foreach (Dinosaur dinosaur in dinosaurHerd.dinosaurList)
            {
                Console.WriteLine(targetNum + ") " + dinosaur.type + " (" + dinosaur.health + " HP)");
                targetNum++;
            }

            //Input validation
            bool validInput = int.TryParse(Console.ReadLine(), out int targetChoice);

            while (!(validInput))
            {
                Console.WriteLine("Invalid target, try again..\nPlease enter a number according to target.");
                validInput = int.TryParse(Console.ReadLine(), out targetChoice);
            }

            return(targetChoice);
        }
Ejemplo n.º 2
0
 public Battlefield()
 {
     robotFleet   = new Fleet();
     dinosaurHerd = new Herd();
 }