/// ***************************************************************** /// * Talent Show > Mixing It Up * /// ***************************************************************** /// /// <param name="myFinch"></param> static void DisplayMixingItUp(Finch myFinch) { Console.CursorVisible = false; DisplayScreenHeader("Mix It Up"); Console.WriteLine("\tThe Finch robot will now do a little bit of everything!"); DisplayContinuePrompt(); for (int Mix = 0; Mix < 1; Mix++) { DisplayMusic(myFinch); myFinch.setLED(Mix, 255, Mix); myFinch.setMotors(255, 0); myFinch.wait(200); myFinch.setMotors(0, 255); myFinch.wait(200); myFinch.setMotors(-255, 0); myFinch.wait(200); myFinch.setMotors(0, -255); myFinch.wait(200); } myFinch.setMotors(0, 0); DisplayMenuPrompt("Talent Show Menu"); }
/// <summary> /// connects to the the finch and displays a connection confirmation, Returns bool isConnect /// </summary> /// <param name="myFinch"></param> private static bool GetConnectToFinch(Finch myFinch) { bool isConnected; // // connect to the finch // if (myFinch.connect()) { // // the finch displays lights // myFinch.setLED(255, 0, 0); myFinch.wait(300); myFinch.setLED(0, 255, 0); myFinch.wait(300); myFinch.setLED(0, 0, 255); myFinch.wait(300); myFinch.setLED(255, 255, 255); myFinch.wait(300); myFinch.setLED(0, 0, 0); isConnected = true; } else { isConnected = false; } return(isConnected); }
/// <summary> /// ***************************************************************** /// * Talent Show > Mixing It Up * /// ***************************************************************** /// </summary> /// <param name="myFinch">finch robot object</param> static void DisplayMixingItUp(Finch myFinch) { Console.CursorVisible = false; DisplayScreenHeader("Mixing It Up"); Console.WriteLine("\tTHE FINCH ROBOT WILL NOW MIX IT UP ON YA' "); DisplayContinuePrompt(); myFinch.setLED(255, 0, 0); myFinch.noteOn(261); myFinch.wait(1000); myFinch.noteOff(); myFinch.setLED(0, 255, 0); myFinch.setMotors(50, 200); for (int frequency = 0; frequency < 20000; frequency = frequency + 100) { myFinch.noteOn(frequency); myFinch.wait(2); myFinch.noteOff(); } myFinch.wait(3000); myFinch.setMotors(0, 0); myFinch.setMotors(-200, -200); myFinch.wait(1000); myFinch.setMotors(0, 0); myFinch.setLED(0, 0, 0); DisplayMenuPrompt("Talent Show Menu"); }
static void DisplayMixingItUp(Finch myFinch) { Console.CursorVisible = false; DisplayScreenHeader("Mixing It Up"); Console.WriteLine("\tThe Finch robot will now go crazy!"); DisplayContinuePrompt(); myFinch.setMotors(150, 150); myFinch.wait(500); myFinch.setMotors(-35, 35); myFinch.wait(500); myFinch.setMotors(150, 150); myFinch.wait(500); myFinch.setMotors(-35, 35); for (int lightSoundLevel = 25; lightSoundLevel < 255; lightSoundLevel++) { myFinch.setLED(lightSoundLevel, lightSoundLevel, lightSoundLevel); myFinch.noteOn(lightSoundLevel * 100); } DisplayMenuPrompt("Talent Show Menu"); }
/// <summary> /// ***************************************************************** /// * Talent Show > Light, Sound, And Move * /// ***************************************************************** /// </summary> /// <param name="finchRobot">finch robot object</param> private static void DisplayLightSoundAndMove(Finch finchRobot) { Console.CursorVisible = false; DisplayScreenHeader("DisplayLightSoundAndMove"); Console.WriteLine("\tThe Finch robot will now show off it's lights while doing a song and dance."); DisplayContinuePrompt(); for (int i = 0; i < 1; i++) { DisplayMusic(finchRobot); finchRobot.setLED(i, 255, i); finchRobot.setMotors(255, 255); finchRobot.wait(2000); finchRobot.setMotors(-255, -255); finchRobot.wait(200); finchRobot.setMotors(255, 128); finchRobot.wait(200); finchRobot.setMotors(128, 255); finchRobot.wait(200); } finchRobot.setMotors(0, 0); DisplayMenuPrompt("Talent Show Menu"); }
static void DisplayMasterBathroom(Finch finchi) { DisplayHeader("Master Bathroom"); string menuChoice; string messageMasterBathroom = ""; Console.WriteLine(); Console.WriteLine(); Console.WriteLine("\t1) Take a bath."); Console.WriteLine("\t2) Look in the mirror"); Console.WriteLine("\t3) Steal the towels."); Console.WriteLine("\t4) Back"); Console.WriteLine(); Console.Write("Enter Choice"); menuChoice = Console.ReadLine(); switch (menuChoice) { case "1": messageMasterBathroom = "Finchi does not think that this is the right time for this."; finchi.setLED(0, 255, 0); finchi.wait(300); finchi.setLED(0, 0, 255); finchi.wait(300); finchi.setLED(0, 0, 0); break; case "2": messageMasterBathroom = "Say Bloody Mary three times and see what happens! Aw... nothing happened... "; break; case "3": messageMasterBathroom = "Finchi can't take you anywhere..."; break; case "4": DisplaySecondFloor(finchi); break; default: DisplayMasterBathroom(finchi); break; } if (messageMasterBathroom != "") { Console.Clear(); Console.WriteLine(); Console.WriteLine(messageMasterBathroom); DisplayContinuePrompt(); DisplayMasterBathroom(finchi); } }
//------------// //Display LEDS// //------------// static void DisplayLeds(Finch myFinch) { DisplayHeader("Finch LEDs"); //for (int i = 0; i < 5; i++) //{ // myFinch.setLED(0, 0, 255); // myFinch.wait(500); // myFinch.setLED(0, 0, 0); // myFinch.wait(500); //} for (int lightLevel = 0; lightLevel < 255; lightLevel++) { myFinch.setLED(lightLevel, 0, 0); myFinch.wait(10); } for (int lightLevel = 255; lightLevel > 0; lightLevel--) { myFinch.setLED(lightLevel, 0, 0); myFinch.wait(10); } DisplayContinuePrompt(); DisplayTalentShow(myFinch); }
static void NominalIndicator(Finch sentryBot) { sentryBot.setLED(0, 255, 0); sentryBot.wait(500); sentryBot.setLED(0, 0, 0); sentryBot.wait(100); }
/// <summary> /// Plays the last few notes of Imperial March. WARNING: LONG CODE BLOCK! /// </summary> /// <param name="myFinch"></param> public static void PlayGameOverMarch(Finch myFinch) { // Just the last five notes: myFinch.noteOn(349); myFinch.wait(250); myFinch.noteOff(); myFinch.wait(10); myFinch.noteOn(415); myFinch.wait(500); myFinch.noteOff(); myFinch.wait(10); myFinch.noteOn(349); myFinch.wait(375); myFinch.noteOff(); myFinch.wait(10); myFinch.noteOn(261); myFinch.wait(125); myFinch.noteOff(); myFinch.wait(10); myFinch.noteOn(475); myFinch.wait(1000); myFinch.noteOff(); myFinch.wait(100); }
static void DisplayMixing(Finch myFinch) { // // Display of Finch's functions in mixing // Console.CursorVisible = false; DisplayScreenHeader("Mixing It Up"); Console.WriteLine("\tThe Finch robot will show off it's moves!"); DisplayContinuePrompt(); for (int looptwo = 0; looptwo < 8; looptwo++) { myFinch.setMotors(150, 150); // move myFinch.wait(200); myFinch.setMotors(0, 0); // stop myFinch.setLED(100, 100, 100); // turn on LEDs myFinch.noteOn(450); // turn on note myFinch.wait(200); myFinch.noteOff(); // turn off note myFinch.setLED(0, 0, 0); // turn off LEDs } DisplayMenuPrompt("Talent Show!"); }
/// **************************************** /// * Talent Show > Dance * /// **************************************** static void DisplayDance(Finch finchRobot) { Console.CursorVisible = false; DisplayScreenHeader("Dance"); Console.WriteLine("\tThe Finch robott will now show off a dance called \"Hop Step.\""); DisplayContinuePrompt(); for (int count = 0; count < 5; count++) { finchRobot.setMotors(100, 100); finchRobot.wait(700); finchRobot.setMotors(-255, -255); finchRobot.wait(200); finchRobot.setMotors(255, 255); finchRobot.wait(200); finchRobot.setMotors(0, 0); finchRobot.wait(200); finchRobot.setMotors(-100, 100); finchRobot.wait(800); finchRobot.setMotors(0, 0); } Console.Clear(); DisplayContinuePrompt(); }
static bool SentryVersusThresholdValue(double lowerTempThreshold, Finch finch, double upperLightThreshold) { if (finch.getTemperature() <= lowerTempThreshold) { for (int i = 0; i < 5; i++) { finch.noteOn(600); finch.wait(50); finch.noteOff(); } Console.WriteLine("Temperature Reached Threshold. Press Any Key To Continue."); Console.ReadKey(); return(true); } else if ((finch.getLeftLightSensor() + finch.getRightLightSensor()) / 2 >= upperLightThreshold) { for (int i = 0; i < 5; i++) { finch.noteOn(600); finch.wait(50); finch.noteOff(); } Console.WriteLine("Light Reached Threshold. Press Any Key To Continue."); Console.ReadKey(); return(true); } else { return(false); } }
static void DisplayGetData( int numberOfDataPoints, double dataPointFrequency, double[] temperatures, Finch finchRobot) { DisplayScreenHeader("Get Temperatures"); // give the user info and a prompt Console.WriteLine($"The Finch Robot is now going to take {numberOfDataPoints} data points."); finchRobot.wait(2000); Console.Clear(); for (int index = 0; index < numberOfDataPoints; index++) { temperatures[index] = finchRobot.getTemperature(); ConvertCelsiusToFahrenheit(temperatures[index]); int milliseconds = (int)(dataPointFrequency * 1000); finchRobot.wait(milliseconds); Console.WriteLine($"Temperature {index + 1}: {temperatures[index]}"); } DisplayContinuePrompt(); }
/// <summary> /// ***************************************************************** /// * Talent Show > Light and Sound * /// ***************************************************************** /// </summary> /// <param name="finchRobot">finch robot object</param> static void TalentShowDisplayLightAndSound(Finch finchRobot) { Console.CursorVisible = false; DisplayScreenHeader("Light and Sound"); Console.WriteLine("\tThe Finch robot will now show off its glowing talent!"); DisplayContinuePrompt(); for (int lightSoundLevel = 0; lightSoundLevel < 255; lightSoundLevel++) { finchRobot.setLED(lightSoundLevel, lightSoundLevel, lightSoundLevel); finchRobot.noteOn(lightSoundLevel * 100); } finchRobot.setLED(0, 255, 0); finchRobot.noteOn(262); finchRobot.wait(1000); finchRobot.setLED(255, 0, 0); finchRobot.noteOn(294); finchRobot.wait(1000); finchRobot.setLED(0, 0, 255); finchRobot.noteOn(392); finchRobot.wait(500); finchRobot.setLED(255, 0, 0); finchRobot.noteOn(494); finchRobot.wait(800); finchRobot.setLED(83, 162, 48); finchRobot.noteOn(294); finchRobot.wait(2000); finchRobot.setLED(0, 0, 0); finchRobot.noteOff(); DisplayMenuPrompt("Talent Show Menu"); }
static void LineSix(Finch finchRobot) { // G finchRobot.noteOn(784); finchRobot.wait(120); finchRobot.noteOff(); finchRobot.wait(50); // F# finchRobot.noteOn(740); finchRobot.wait(120); finchRobot.noteOff(); finchRobot.wait(50); // F finchRobot.noteOn(698); finchRobot.wait(120); finchRobot.noteOff(); finchRobot.wait(50); // D# finchRobot.noteOn(622); finchRobot.wait(120); finchRobot.noteOff(); finchRobot.wait(150); // E finchRobot.noteOn(659); finchRobot.wait(120); finchRobot.noteOff(); finchRobot.wait(150); }
///<summary> ///****************************************************** ///* Talent Show "Mix It Up" ///****************************************************** /// </summary> /// <param name="finchRobot">finch robot object</param> static void DisplayMixingItUp(Finch finchRobot) { Console.CursorVisible = false; DisplayScreenHeader("Mixing It Up"); Console.WriteLine("The Finch robot will now \"mix it up\" for you!"); DisplayContinuePrompt(); finchRobot.setLED(255, 0, 0); finchRobot.noteOn(50); finchRobot.wait(2000); finchRobot.noteOff(); finchRobot.setMotors(255, 255); finchRobot.wait(2000); finchRobot.setMotors(255, 0); finchRobot.wait(2000); finchRobot.setLED(0, 0, 0); finchRobot.setMotors(0, 0); finchRobot.noteOn(100); finchRobot.wait(1000); finchRobot.noteOff(); finchRobot.setLED(0, 255, 0); finchRobot.wait(5000); DisplayMenuPrompt("Talent Show Menu"); }
/// <summary> /// third choice /// </summary> /// <param name="secondsOfCrawl"></param> /// <param name="SneakyFinch"></param> static void StairWell(int secondsOfCrawl, Finch SneakyFinch) { bool hit; for (int seconds = 0; seconds < secondsOfCrawl * 10; seconds++) { SneakyFinch.setMotors(255, 255); Console.Clear(); Console.WriteLine(SneakyFinch.getRightLightSensor()); if (SneakyFinch.getLeftLightSensor() > 150) { hit = true; SneakyFinch.setMotors(-100, -25); SneakyFinch.setLED(255, 0, 0); SneakyFinch.wait(3000); SneakyFinch.setMotors(100, 25); SneakyFinch.wait(3000); } else { hit = false; SneakyFinch.setMotors(100, 25); SneakyFinch.setMotors(100, 100); } } }
static void TemperatureNominalIndicator(Finch finch) { finch.setLED(0, 255, 0); finch.wait(500); Console.WriteLine($"Current Temperature: {finch.getTemperature()}"); Console.WriteLine($"Current Light Level: {(finch.getLeftLightSensor() + finch.getRightLightSensor()) / 2}"); finch.setLED(0, 0, 0); finch.wait(500); }
/// ***************************************************************** /// * Talent Show > Dance * /// ***************************************************************** /// /// <param name="myFinch"></param> static void DisplayDance(Finch myFinch) { string shape; Console.CursorVisible = false; DisplayScreenHeader("Dance"); Console.WriteLine("\tWhich shape would you like the finch to go in?"); Console.WriteLine("a) Circle"); Console.WriteLine("b) Square"); shape = Console.ReadLine(); switch (shape) { case "a": Console.WriteLine("The finch will now move in a circle"); DisplayContinuePrompt(); for (int Pattern = 0; Pattern < 4; Pattern++) { //myFinch.setMotors(100, 100); //myFinch.wait(200); //myFinch.setMotors(-100, -100); //myFinch.wait(200); myFinch.setMotors(255, 50); myFinch.wait(1000); } break; case "b": Console.WriteLine("The finch will now move in a square"); DisplayContinuePrompt(); for (int pattern = 0; pattern < 1; pattern++) { myFinch.setMotors(255, 255); myFinch.wait(500); myFinch.setMotors(255, 50); myFinch.wait(550); myFinch.setMotors(255, 255); myFinch.wait(500); myFinch.setMotors(255, 50); myFinch.wait(550); myFinch.setMotors(255, 255); myFinch.wait(500); myFinch.setMotors(255, 50); myFinch.wait(550); myFinch.setMotors(255, 255); myFinch.wait(500); myFinch.setMotors(255, 50); myFinch.wait(550); } break; default: Console.WriteLine("Please enter (a) or (b)"); break; } myFinch.setMotors(0, 0); DisplayMenuPrompt("Talent Show Menu"); }
static void ExploreSounds(Finch finchRobot) { finchRobot.noteOn(523); finchRobot.wait(100); finchRobot.noteOn(587); finchRobot.wait(100); finchRobot.noteOn(659); finchRobot.wait(100); finchRobot.noteOn(698); finchRobot.wait(100); finchRobot.noteOn(784); finchRobot.wait(100); finchRobot.noteOn(880); finchRobot.wait(100); finchRobot.noteOn(988); finchRobot.wait(100); finchRobot.noteOn(1047); finchRobot.wait(100); finchRobot.noteOff(); for (int soundValue = 100; soundValue < 15000; soundValue = soundValue + 80) { finchRobot.noteOn(soundValue); finchRobot.wait(1); finchRobot.noteOff(); } }
// //Robot begins playing a series of notes // private static void RoboticSinging(Finch myFinch) { myFinch.setLED(255, 0, 0); myFinch.noteOn(233); myFinch.wait(2000); myFinch.noteOff(); myFinch.wait(10); myFinch.noteOn(233); myFinch.wait(2000); myFinch.noteOff(); }
static void DisplayMixing(Finch myFinch) { myFinch.setLED(200, 0, 0); myFinch.setMotors(200, 200); myFinch.wait(1000); myFinch.setMotors(0, 0); myFinch.noteOn(500); myFinch.wait(200); myFinch.noteOff(); myFinch.setLED(0, 0, 0); }
/// <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++; } }
//--------// //Movement// //--------// static void DisplayMoves(Finch myFinch) { DisplayHeader("Moves"); myFinch.setMotors(255, 255); myFinch.wait(1000); myFinch.setMotors(-255, -255); myFinch.wait(1000); myFinch.setMotors(0, 0); DisplayContinuePrompt(); DisplayTalentShow(myFinch); }
static void Hit() { Console.WriteLine("Hit!"); for (int i = 0; i < 3; i++) { Sam.setLED(255, 255, 255); Sam.noteOn(500); Sam.wait(500); Sam.setLED(0, 0, 0); Sam.noteOff(); Sam.wait(100); } }
static void DisplayDance(Finch myFinch) { DisplayScreenHeader("Finchy Moves"); myFinch.setMotors(255, 255); myFinch.wait(500); myFinch.setMotors(0, 0); myFinch.setMotors(-255, 255); myFinch.wait(1000); myFinch.setMotors(0, 0); DisplayContinuePrompt(); }
/// <summary> /// display disconect the Finch /// </summary> /// <param name="myFinch"></param> private static void DisconnectTheFinch(Finch myFinch) { for (int i = 0; i < 3; i++) { myFinch.setLED(255, 0, 0); myFinch.wait(250); myFinch.setLED(0, 0, 0); myFinch.wait(250); } myFinch.disConnect(); Console.WriteLine("The Finch is disconnected"); }
private static void AdvoidLightAndObsticales(Finch alma) { alma.connect(); int light; int lightThreshold = 8; DisplayHeader("Finch flees before the spotlight"); Console.WriteLine("Finch will Avoid the spotlight (flashlight) for 10 seconds. The Finch will also Avoid Obsitacls"); light = alma.getRightLightSensor(); for (int i = 0; i < 17; i++) { alma.setMotors(100, 100); alma.setLED(0, 255, 0); alma.wait(500); // //avoid light // if ((lightThreshold + light) < alma.getRightLightSensor()) { alma.setMotors(255, 0); alma.setLED(255, 0, 0); alma.wait(500); alma.setMotors(255, 255); alma.setLED(255, 0, 0); alma.wait(1500); alma.setMotors(0, 255); alma.setLED(255, 0, 0); alma.wait(500); } if (alma.isObstacleLeftSide()) { alma.setMotors(0, 255); alma.setLED(255, 0, 0); alma.wait(500); } else if (alma.isObstacleRightSide()) { alma.setMotors(255, 0); alma.setLED(255, 0, 0); } } alma.disConnect(); DisplayContinuePrompt(); }
static void DisplayAlarmSystemScreen(Finch finchRobot) { string alarmType; int maxLimit; double maxThreshold; double minThreshold; bool thresholdExceeded; DisplayScreenHeader("Alarm System"); alarmType = DisplayGetAlarmType(); maxLimit = DisplayGetMaxLimit(); DisplayGetThreshhold(finchRobot, alarmType, out minThreshold, out maxThreshold); Console.WriteLine(); Console.WriteLine("The Alarm is now set"); DisplayContinuePrompt(); finchRobot.setLED(255, 0, 255); thresholdExceeded = MonitorLevels(finchRobot, minThreshold, maxThreshold, maxLimit, alarmType); if (thresholdExceeded) { if (alarmType == "light") { Console.WriteLine("Maximum or minimum light level exceeded"); } else { Console.WriteLine("Maximum or minimum temperature level exceeded"); } finchRobot.setLED(255, 0, 0); for (int i = 0; i < 5; i++) { finchRobot.noteOn(10000); finchRobot.wait(1000); finchRobot.noteOff(); finchRobot.wait(300); } } else { Console.WriteLine(); Console.WriteLine("Maximum time exceeded"); } DisplayContinuePrompt(); finchRobot.noteOff(); finchRobot.setLED(0, 0, 0); }
static void DisplayMixingItUp(Finch finchRobot) { DisplayScreenHeader("Mixing It Up"); for (int lightSoundLevel = 0; lightSoundLevel < 255; lightSoundLevel++) { finchRobot.setLED(255, 0, 0); finchRobot.wait(500); finchRobot.setLED(0, 0, 0); finchRobot.setLED(255, 0, 255); finchRobot.wait(500); finchRobot.setLED(255, 0, 255); finchRobot.wait(500); finchRobot.setLED(0, 255, 255); finchRobot.wait(500); finchRobot.setLED(0, 255, 0); finchRobot.wait(500); finchRobot.setLED(0, 0, 255); finchRobot.noteOn(lightSoundLevel * 100); finchRobot.wait(500); finchRobot.setMotors(255, 255); finchRobot.wait(500); finchRobot.setMotors(0, 0); finchRobot.setMotors(-255, 255); finchRobot.wait(1000); finchRobot.setMotors(0, 0); } DisplayContinuePrompt(); }