Ejemplo n.º 1
0
        static void DisplayMenu(Finch tim)
        {
            bool       breaking = false;
            bool       setup = false;
            double     ambientTemp = 0, tolerance = 0;
            int        ambientLight = 0;
            string     uInput;
            MenuOption uInputAsEnum;

            while (!breaking)
            {
                GD.DisplayNewScreen("Main Menu");
                Console.WriteLine("Select Option:");
                foreach (MenuOption option in Enum.GetValues(typeof(MenuOption)))
                {
                    Console.WriteLine(option);
                }

                do
                {
                    Console.Write(">");
                    uInput = GI.GetString(true);
                } while (!Enum.TryParse <MenuOption>(uInput, out uInputAsEnum));

                switch (uInputAsEnum)
                {
                case MenuOption.SETUP:
                    tolerance = DisplaySetupTim(tim, out ambientTemp, out ambientLight);
                    setup     = true;
                    break;

                case MenuOption.ACTIVATE:
                    if (setup)
                    {
                        DisplayActivateTim(tim, tolerance, ambientTemp, ambientLight);
                    }
                    else
                    {
                        Console.WriteLine("Please run setup first.");
                        GD.DisplayAnyKey();
                    }

                    break;

                case MenuOption.EXIT:
                    breaking = true;
                    break;

                default:
                    break;
                }
            }
            tim.disConnect();
        }
Ejemplo n.º 2
0
        public static void DisplayInventory(List <VideoGame> inventory, Generic_Display GD)
        {
            GD.DisplayNewScreen("Inventory");

            Console.Write("Title".PadRight(20));
            Console.Write("Publisher".PadRight(20));
            Console.Write("Price".PadRight(20));
            Console.Write("Online".PadRight(20));
            Console.WriteLine();
            Console.WriteLine();

            foreach (VideoGame game in inventory)
            {
                string price = game.Price.ToString();
                Console.Write(game.Title.PadRight(20));
                Console.Write(game.Publisher.PadRight(20));
                Console.Write($"${price}".PadRight(20));
                if (game.Multiplayer)
                {
                    Console.Write("Multiplayer".PadRight(20));
                }
                else
                {
                    Console.Write("Singleplayer".PadRight(20));
                }
                Console.WriteLine();
            }

            GD.DisplayAnyKey();
        }
Ejemplo n.º 3
0
        static void DisplayUserAddFurryMonsters(List <FurryMonster> furryMonsters, Generic_Display display)
        {
            Generic_Input    input = new Generic_Input();
            FurryMonsterType monsterType;
            string           uInput;
            int year, month, day;

            display.DisplayNewScreen("Monster Maker");

            FurryMonster furryMonster = new FurryMonster();

            Console.WriteLine("Enter monster name:");
            furryMonster.Name = input.GetString(false);

            Console.WriteLine("Enter monster color:");
            furryMonster.Color = input.GetString(false);

            Console.WriteLine("Does monster have claws (true or false):");
            furryMonster.HasClaws = input.GetBool();

            Console.WriteLine("Enter monster length in meters:");
            furryMonster.Length = input.GetValidInt();

            Console.WriteLine("When was the monster born.");
            Console.WriteLine("Year:");
            do
            {
                year = input.GetValidInt();
            } while (year < 0 || year > 2017);

            Console.WriteLine("Month:");
            do
            {
                month = input.GetValidInt();
            } while (month < 0 || month > 12);

            Console.WriteLine("Day:");
            do
            {
                day = input.GetValidInt();
            } while (day < 0 || day > 31);

            furryMonster.DateOfBirth = new DateTime(year, month, day);

            Console.WriteLine("Enter monster type (Cat, Dog, Horse, Rat):");
            do
            {
                Console.Write(">");
                uInput = Console.ReadLine();
            } while (!Enum.TryParse <FurryMonsterType>(uInput, out monsterType));
            furryMonster.MonsterType = monsterType;

            furryMonsters.Add(furryMonster);

            Console.WriteLine();
            furryMonster.Greeting(furryMonster);

            display.DisplayAnyKey();
        }
Ejemplo n.º 4
0
        static void DisplayUserAddSeaMonsters(List <SeaMonster> seaMonsters, Generic_Display display)
        {
            Generic_Input  input = new Generic_Input();
            SeaMonsterType monsterType;
            string         uInput;
            int            year, month, day;

            display.DisplayNewScreen("Monster Maker");

            SeaMonster seaMonster = new SeaMonster();

            Console.WriteLine("Enter monster name:");
            seaMonster.Name = input.GetString(false);

            Console.WriteLine("Enter monster color:");
            seaMonster.Color = input.GetString(false);

            Console.WriteLine("Does monster have scales (true or false):");
            seaMonster.HasScales = input.GetBool();

            Console.WriteLine("Enter monster length in meters:");
            seaMonster.Length = input.GetValidInt();

            Console.WriteLine("When was the monster born.");
            Console.WriteLine("Year:");
            do
            {
                year = input.GetValidInt();
            } while (year < 0 || year > 2017);

            Console.WriteLine("Month:");
            do
            {
                month = input.GetValidInt();
            } while (month < 0 || month > 12);

            Console.WriteLine("Day:");
            do
            {
                day = input.GetValidInt();
            } while (day < 0 || day > 31);

            seaMonster.DateOfBirth = new DateTime(year, month, day);

            Console.WriteLine("Enter monster type (Fish, Cephalopod, Crustation, Jelly):");
            do
            {
                uInput = Console.ReadLine();
            } while (!Enum.TryParse <SeaMonsterType>(uInput, out monsterType));
            seaMonster.MonsterType = monsterType;

            seaMonsters.Add(seaMonster);

            Console.WriteLine();
            seaMonster.Greeting(seaMonster);

            display.DisplayAnyKey();
        }
Ejemplo n.º 5
0
        static void DisplayAllFurryMonsterInfo(List <FurryMonster> furryMonsters, Generic_Display display)
        {
            display.DisplayNewScreen("Main Application");

            foreach (FurryMonster furryMonster in furryMonsters)
            {
                DisplayFurryMonsterInfo(furryMonster);
            }

            display.DisplayAnyKey();
        }
Ejemplo n.º 6
0
        static void DisplayAllSeaMonsterInfo(List <SeaMonster> seaMonsters, Generic_Display display)
        {
            display.DisplayNewScreen("Main Application");

            foreach (SeaMonster seaMonster in seaMonsters)
            {
                DisplaySeaMonsterInfo(seaMonster);
            }

            display.DisplayAnyKey();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// display main program loop
        /// </summary>
        static void DisplayMainLoop(Generic_Display GD, Generic_Input GI, Generic_Alter GA)
        {
            //declare constants
            //
            int[,] NOSECOLORS = new int[4, 3] {
                { 0, 0, 0 }, { 255, 0, 0 }, { 0, 0, 255 }, { 0, 255, 0 }
            };
            int[] SPEEDS = new int[4] {
                0, 127, 191, 255
            };

            GD.DisplayNewScreen("Main App Loop");

            //instantiate SuperTina
            //
            Finch      superTina = InstantiateFinch();
            FinchLevel superTinaLevel;

            Console.WriteLine("\nPlease enter the shield level for Super Tina (1-3)");
            superTinaLevel = InputFinchLevelValid();
            Console.WriteLine($"\nSuper Tinas shields are at {superTinaLevel} power level");

            int[] SuperTinaNoseColor = new int[3];
            SuperTinaNoseColor = GA.SpliceIntMultiArray(NOSECOLORS, (int)superTinaLevel, 3);
            int SuperTinaSpeed = SPEEDS[(int)superTinaLevel];

            //declare variables
            //
            bool breakLoop = false;

            //activate SuperTina
            //
            Console.WriteLine("\nSuper Tina is ready for battle.");
            GD.DisplayAnyKey();

            superTina.setMotors(SuperTinaSpeed, SuperTinaSpeed);
            superTina.setLED(SuperTinaNoseColor[0], SuperTinaNoseColor[1], SuperTinaNoseColor[2]);

            //main loop
            //
            while (!breakLoop)
            {
                breakLoop = DisplayActivateTim(superTina, NOSECOLORS, SPEEDS, superTinaLevel, GD, GI, GA);
            }

            superTina.disConnect();
        }
Ejemplo n.º 8
0
        static bool DisplayActivateTim(Finch superTina, int[,] NOSECOLORS, int[] SPEEDS, FinchLevel superTinaLevel, Generic_Display GD, Generic_Input GI, Generic_Alter GA)
        {
            double currentTemp, currentLight, ambientTemp, ambientLight, min, max;

            int[] levelArray = new int[3];
            bool  breaking   = false;

            ambientTemp  = superTina.getTemperature();
            ambientLight = AverageLight(superTina);
            min          = ambientTemp - 1;
            max          = ambientLight + 3;

            Console.WriteLine($"Shields at {superTinaLevel} level.");

            while (!breaking)
            {
                currentTemp  = superTina.getTemperature();
                currentLight = AverageLight(superTina);
                superTina.wait(200);

                switch (superTinaLevel)
                {
                case FinchLevel.HIGH:
                    if (currentTemp < min && currentLight > max)     //freeze ray and lazer
                    {
                        superTinaLevel--;
                        superTina.setMotors(SPEEDS[(int)superTinaLevel], SPEEDS[(int)superTinaLevel]);
                        Hit(superTina, GA.SpliceIntMultiArray(NOSECOLORS, (int)superTinaLevel, 3));
                        Console.WriteLine($"Shield levels at {superTinaLevel}!\n");
                    }
                    break;

                case FinchLevel.MEDIUM:
                    if (currentLight > max)     //just lazer
                    {
                        superTinaLevel--;
                        superTina.setMotors(SPEEDS[(int)superTinaLevel], SPEEDS[(int)superTinaLevel]);
                        Hit(superTina, GA.SpliceIntMultiArray(NOSECOLORS, (int)superTinaLevel, 3));
                        Console.WriteLine($"Shield levels at {superTinaLevel}!\n");
                    }
                    break;

                case FinchLevel.LOW:
                    if (currentTemp < min)     //just freeze ray
                    {
                        superTinaLevel--;
                        superTina.setMotors(SPEEDS[(int)superTinaLevel], SPEEDS[(int)superTinaLevel]);
                        Hit(superTina, GA.SpliceIntMultiArray(NOSECOLORS, (int)superTinaLevel, 3));
                        Console.WriteLine($"Shield levels at {superTinaLevel}!\n");
                    }
                    else if (currentLight > max)     //just lazer
                    {
                        superTinaLevel--;
                        superTina.setMotors(SPEEDS[(int)superTinaLevel], SPEEDS[(int)superTinaLevel]);
                        Hit(superTina, GA.SpliceIntMultiArray(NOSECOLORS, (int)superTinaLevel, 3));
                        Console.WriteLine($"Shield levels at {superTinaLevel}!\n");
                    }
                    break;

                case FinchLevel.EMPTY:
                    breaking = true;
                    break;

                default:
                    break;
                }

                superTina.wait(200);
            }

            Console.WriteLine("SuperTina is dead. The world has been destroyed. All is lost, even hope.");

            GD.DisplayAnyKey();
            return(breaking);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// display a title screen with menu
        /// </summary>
        /// <returns>MainMenuOption user selected</returns>
        static bool MainMenu(List <SeaMonster> seaMonsters, List <FurryMonster> furryMonsters, Generic_Display display)
        {
            //declare vars
            //
            int            selected = 0;
            ConsoleKeyInfo uKey;
            bool           breaking = false;
            bool           exit     = false;

            string[] options = new string[5]
            {
                "Make Sea Monster"
                , "Display Sea Monster Info"
                , "Make Furry Monster"
                , "Display Furry Monster Info"
                , "Exit"
            };

            Console.CursorVisible = false;

            //menu loop
            //
            do
            {
                Console.Clear();

                Console.WriteLine("~ MOSNTER MENU ~");
                Console.WriteLine("\nARROWS TO NAVIGATE\nENTER TO SELECT\n");

                //print options
                //
                for (int i = 0; i < options.Length; i++)
                {
                    if (selected == i)
                    {
                        Console.Write("(*) ");
                        Console.WriteLine(options[i]);
                    }
                    else
                    {
                        Console.Write("( ) ");
                        Console.WriteLine(options[i]);
                    }
                }

                //get input and determine selected option
                //
                uKey = Console.ReadKey(true);

                if (uKey.Key.ToString() == "DownArrow") //user moves down
                {
                    selected++;
                    if (selected > options.Length - 1)
                    {
                        selected = 0;
                    }
                }
                else if (uKey.Key.ToString() == "UpArrow") //user moves up
                {
                    selected--;
                    if (selected < 0)
                    {
                        selected = Convert.ToInt16(options.Length - 1);
                    }
                }
                else if (uKey.Key.ToString() == "Enter") //user selects option
                {
                    breaking = true;
                }
            } while (!breaking);

            switch (options[selected])
            {
            case "Make Sea Monster":
                DisplayUserAddSeaMonsters(seaMonsters, display);
                break;

            case "Display Sea Monster Info":
                DisplayAllSeaMonsterInfo(seaMonsters, display);
                break;

            case "Make Furry Monster":
                DisplayUserAddFurryMonsters(furryMonsters, display);
                break;

            case "Display Furry Monster Info":
                DisplayAllFurryMonsterInfo(furryMonsters, display);
                break;

            case "Exit":
                exit = true;
                display.DisplayNewScreen("Goodbye");

                foreach (SeaMonster monster in seaMonsters)
                {
                    monster.GoodBye(monster);
                }

                foreach (FurryMonster monster in furryMonsters)
                {
                    monster.GoodBye(monster);
                }

                display.DisplayAnyKey();

                display.DisplayCloseScreen("Sea Monster Classes", new string[1] {
                    "Eric Grant"
                });
                break;

            default:
                break;
            }

            Console.CursorVisible = true;
            return(exit);
        }