/// <summary> /// Controls whether the Finch can be hurt or not and gives the user a prompt if they have scored a hit. /// </summary> static void DisplayVulnerbilityStatus(Finch myFinch, Monitor hitTracker, FinchOperator myFinchOperator) { // Checks for hits upon entering the method: hitTracker.IsHit = Monitor.HitDetection(myFinch); hitTracker.IsFrozen = Monitor.FreezeDetection(myFinch); // Statment to indicate a hit while shields are up. if (hitTracker.IsHit == true && hitTracker.IsFrozen == false) { Console.WriteLine(); Console.WriteLine("\tThe blast is deflected! You need to freeze him first."); FinchOperator.LEDSettings(myFinch, myFinchOperator); myFinch.wait(1000); } // Statment to indicate a hit while shields are down. if (hitTracker.IsFrozen == true) { Console.WriteLine(); Console.WriteLine("\tThat got him! Strike now while he is stunned!"); // Sets the finch to vulnerable so it can take hits: myFinchOperator.IsVulnerable = true; // Turns off the LED to indicate shields are down. FinchOperator.LEDSettings(myFinch, myFinchOperator); // Enters this method to determine if a hit is suffered or not. ShieldsDown(myFinch, hitTracker, myFinchOperator); } }
/// <summary> /// Screen that runs the gameplay: /// </summary> /// <param name="myFinch"></param> /// <param name="myFinchOperator"></param> /// <param name="difficulty"></param> static void DisplayGameInProgress(Finch myFinch, FinchOperator myFinchOperator) { // Instantiates a new hit tracker: Monitor hitTracker = new Monitor(); int timeInLoop = 0; //Variables: myFinchOperator.isDefeated = false; // Resets Finch Operator to default hitpoints. myFinchOperator.HitsSuffered = 0; DisplayHeader("DARTH FINCH"); Console.WriteLine(); Console.WriteLine("\t\tInitializing..."); // Just in case the user attempts to run the game without a Finch - it doesn't crash, but it doesn't make sense either. if (!myFinch.connect()) { DisplayHeader("DARTH FINCH"); Console.WriteLine("\tNo finch detected. Please connect a Finch before proceeding!"); DisplayContinuePrompt(); FinchOperator.EstablishFinchConnection(myFinch); } // Little indicator that the game has begun: FinchOperator.PlayImpMarchShort(myFinch); // Main Gameplay Loop: while (!myFinchOperator.isDefeated && timeInLoop <= myFinchOperator.TimeAvailable) { DisplayHeader("DARTH FINCH:"); Console.WriteLine("\tDarth Finch is active!"); Console.WriteLine("\tTime Remaining:" + $"[{myFinchOperator.TimeAvailable - timeInLoop}]"); DisplayHealthStatus(myFinchOperator); //hitTracker.IsFrozen = Monitor.FreezeDetection(myFinch); //hitTracker.IsHit = Monitor.HitDetection(myFinch); DisplayVulnerbilityStatus(myFinch, hitTracker, myFinchOperator); myFinch.wait(500); myFinchOperator.isDefeated = CheckHealth(myFinchOperator); FinchOperator.LEDSettings(myFinch, myFinchOperator); // FinchOperator.MotorSettings(myFinch, myFinchOperator); Disabling this for the time being. myFinch.wait(500); timeInLoop++; } }
/// <summary> /// Method that controls hits while shields are down. /// </summary> /// <param name="myFinch"></param> /// <param name="hitTracker"></param> /// <param name="myFinchOperator"></param> static void ShieldsDown(Finch myFinch, Monitor hitTracker, FinchOperator myFinchOperator) { myFinch.wait(myFinchOperator.vulnerabilityDuration); hitTracker.IsHit = Monitor.HitDetection(myFinch); if (hitTracker.IsHit == true) { Console.WriteLine(); Console.WriteLine("\tNice hit! He'll feel that for sure."); myFinchOperator.HitsSuffered += 1; myFinch.wait(500); } else { Console.WriteLine(); Console.WriteLine("\tThe moment to strike has passed. Try again!"); myFinch.wait(500); } myFinchOperator.IsVulnerable = false; FinchOperator.LEDSettings(myFinch, myFinchOperator); }