コード例 #1
0
ファイル: Program.cs プロジェクト: DahliaEvans/SuperFinch
        static FinchShields GetUserShieldLevel()
        {
            string       userShieldLevelString;
            FinchShields shieldLevel = 0;
            bool         validInput  = false;

            do
            {
                userShieldLevelString = Console.ReadLine().ToUpper();

                switch (userShieldLevelString)
                {
                case "HIGH":
                    shieldLevel = FinchShields.HIGH;
                    validInput  = true;
                    break;

                case "MEDIUM":
                    shieldLevel = FinchShields.MEDIUM;
                    validInput  = true;
                    break;

                case "LOW":
                    shieldLevel = FinchShields.LOW;
                    validInput  = true;
                    break;

                default:
                    Console.WriteLine("Invalid input! Please enter HIGH, MEDIUM, or LOW.");
                    break;
                }
            } while (!validInput);

            return(shieldLevel);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: DahliaEvans/SuperFinch
        static void Main(string[] args)
        {
            Sam.connect();
            DisplayWelcomeScreen();
            FinchShields shieldLevel = GetUserShieldLevel();
            int          speed       = 0;

            ambientTemperature = GetTempature();

            switch (shieldLevel)
            {
            case FinchShields.HIGH:
                speed = 100;
                break;

            case FinchShields.MEDIUM:
                speed = 75;
                break;

            case FinchShields.LOW:
                speed = 50;
                break;

            default:
                break;
            }

            DisplayContinuePrompt();
            Console.Clear();
            MoveSamForward(speed);
            Console.WriteLine("Super Finch is marching forward into battle!");

            do
            {
                switch (shieldLevel)
                {
                case FinchShields.HIGH:
                    Sam.setLED(0, 255, 0);
                    break;

                case FinchShields.MEDIUM:
                    Sam.setLED(0, 0, 255);
                    break;

                case FinchShields.LOW:
                    Sam.setLED(255, 0, 0);
                    break;

                default:
                    break;
                }

                shieldLevel = HitDetection(shieldLevel);
            } while (shieldLevel != FinchShields.FAILED);

            Sam.setMotors(0, 0);
            Console.WriteLine("Game Over!");
            DisplayContinuePrompt();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: DahliaEvans/SuperFinch
        static FinchShields HitDetection(FinchShields shieldLevel)
        {
            const int laserLevel = 100;
            double    freezeTemp = ambientTemperature - 0.5;

            switch (shieldLevel)
            {
            case FinchShields.HIGH:
                if (GetAverageLight() >= laserLevel && GetTempature() <= freezeTemp)
                {
                    Hit();
                    shieldLevel = FinchShields.MEDIUM;
                    Console.WriteLine("Shields at MEDIUM level.");
                }
                break;

            case FinchShields.MEDIUM:
                if (GetAverageLight() >= laserLevel)
                {
                    Hit();
                    shieldLevel = FinchShields.LOW;
                    Console.WriteLine("Shields at LOW level.");
                }
                break;

            case FinchShields.LOW:
                if (GetAverageLight() >= laserLevel || GetTempature() <= freezeTemp)
                {
                    Hit();
                    shieldLevel = FinchShields.FAILED;
                    Console.WriteLine("Shields at FAILED level.");
                }
                break;

            case FinchShields.FAILED:
                break;

            default:
                break;
            }
            return(shieldLevel);
        }