protected override void Update()
    {
        base.Update();

        if (_visibleDinosaurs.Count > 1)
        {
            /* If we have more than two dinosaurs, try to pair them in battles. */
            Dinosaur availableDinosaur = null;
            foreach (var dinosaur in _visibleDinosaurs)
            {
                if (!dinosaur.InBattle)
                {
                    if (availableDinosaur == null)
                    {
                        availableDinosaur = dinosaur;
                    }
                    else
                    {
                        availableDinosaur.Attack(dinosaur);
                        availableDinosaur = null;
                    }
                }
            }
        }
    }
示例#2
0
        static void Jurassic(Hero player, Hero partner)
        {
            player.Location = "Jurassic Forest";
            Dinosaur dino1 = new Dinosaur("Dino");

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine($"{player.Location}");
            Console.WriteLine("You emerge from an ancient jungle temple to find a Tyranosaurus Rex writhing in anger, as it charges toward you in a torrential hurricane of speed and power.");
            dino1.Attack(player);
            player.Attack(dino1);
            dino1.EatGrass();
            Console.WriteLine("Press Enter to fight the Dinosaur!");
            ConsoleKey key = Console.ReadKey(true).Key;

            while (key != ConsoleKey.Enter)
            {
                key = Console.ReadKey(true).Key;
            }
            while (dino1.health > 0 && player.health > 0)
            {
                dino1.Attack(player);
                player.Attack(dino1);
            }
            if (player.health > 0)
            {
                Console.WriteLine("You killed the dinosaur!");
                if (player.health < 25)
                {
                    Console.WriteLine("Your health is less than 25, you have been given a Power up");
                    player.Power(player);
                }
                player.DinoDone = true;
            }
            else
            {
                Console.WriteLine("You have been killed by the dinosaur :(");
            }
        }
示例#3
0
    protected override void Update()
    {
        base.Update();

        if (_visibleDinosaurs.Count > 1)
        {
            Dinosaur availableDinosaur = null;
            foreach (var dinosaur in _visibleDinosaurs)
            {
                if (!dinosaur.InBattle)
                {
                    if (availableDinosaur == null)
                    {
                        availableDinosaur = dinosaur;
                    }
                    else
                    {
                        availableDinosaur.Attack(dinosaur);
                        availableDinosaur = null;
                    }
                }
            }
        }
    }