// constructor (SPAWN)
 public Battlefield()
 {
     herd  = new Herd();  // Instantiate herd (list) of Dinosaur objects
     fleet = new Fleet(); // Instantiate fleet (list) of Robot objects
 }
Exemplo n.º 2
0
        public void ChooseOpponent(Fleet fleet)
        {
            // Dinosaurs go first, switch case to choose which dinosaur attacks which robot
            Console.WriteLine($"Choose dinosaur:\n1) {dinosaur1.type}\n2) {dinosaur2.type}\n3) {dinosaur3.type}");
            string userInput      = Console.ReadLine();
            string validUserInput = GameVerification.VerifySwitchCase(userInput, 1, 3); // Verify

            switch (validUserInput)
            {
            case "1":
                Console.WriteLine($"Choose robot to attack:\n1) {fleet.robot1.name}\n2) {fleet.robot2.name}\n3) {fleet.robot3.name}");
                userInput      = Console.ReadLine();
                validUserInput = GameVerification.VerifySwitchCase(userInput, 1, 3);     // Verify
                // Verify that dinosaur has power (is alive)
                switch (validUserInput)
                {
                case "1":
                    dinosaur1.Attack(fleet.robot1);
                    GameVerification.CheckIfRobotIsDead(fleet.robot1);
                    break;

                case "2":
                    dinosaur1.Attack(fleet.robot2);
                    GameVerification.CheckIfRobotIsDead(fleet.robot2);
                    break;

                case "3":
                    dinosaur1.Attack(fleet.robot3);
                    GameVerification.CheckIfRobotIsDead(fleet.robot3);
                    break;
                }
                break;

            case "2":
                Console.WriteLine($"Choose robot to attack:\n1) {fleet.robot1.name}\n2) {fleet.robot2.name}\n3) {fleet.robot3.name}");
                userInput      = Console.ReadLine();
                validUserInput = GameVerification.VerifySwitchCase(userInput, 1, 3);     // Verify
                switch (validUserInput)
                {
                case "1":
                    dinosaur2.Attack(fleet.robot1);
                    GameVerification.CheckIfRobotIsDead(fleet.robot1);
                    break;

                case "2":
                    dinosaur2.Attack(fleet.robot2);
                    GameVerification.CheckIfRobotIsDead(fleet.robot2);
                    break;

                case "3":
                    dinosaur2.Attack(fleet.robot3);
                    GameVerification.CheckIfRobotIsDead(fleet.robot3);
                    break;
                }
                break;

            case "3":
                Console.WriteLine($"Choose robot to attack:\n1) {fleet.robot1.name}\n2) {fleet.robot2.name}\n3) {fleet.robot3.name}");
                userInput      = Console.ReadLine();
                validUserInput = GameVerification.VerifySwitchCase(userInput, 1, 3);     // Verify
                switch (validUserInput)
                {
                case "1":
                    dinosaur3.Attack(fleet.robot1);
                    GameVerification.CheckIfRobotIsDead(fleet.robot1);
                    break;

                case "2":
                    dinosaur3.Attack(fleet.robot2);
                    GameVerification.CheckIfRobotIsDead(fleet.robot2);
                    break;

                case "3":
                    dinosaur3.Attack(fleet.robot3);
                    GameVerification.CheckIfRobotIsDead(fleet.robot3);
                    break;
                }
                break;
            }
        }