Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var showCheats = false;

            Console.Write("Show cheat colors? (Y/N)");
            ConsoleKeyInfo key;

            do
            {
                key = Console.ReadKey(true);
                if (key.Key == ConsoleKey.Y)
                {
                    showCheats = true;
                    break;
                }
                else if (key.Key == ConsoleKey.N)
                {
                    break;
                }
                else
                {
                    Console.Beep();
                }
            } while (true);
            Console.Clear();

            var wordList = new string[] {
                "and", "for", "off", "saw", "the", "you", "all", "can", "two", "was", "will", "any"
            };

            var wordList2 = new string[] {
                "are", "come", "four", "have", "her", "look", "one", "over", "said", "see", "she", "that"
            };

            var wordList3 = new string[] {
                "them", "this", "three", "want", "would", "where", "whose", "put"
            };

            Console.Write("which option(w1,e2,t3)");
            ConsoleKeyInfo num;

            do
            {
                num = Console.ReadKey(true);
                if (num.Key == ConsoleKey.W)
                {
                    Console.Clear();
                    var ws = WordSearch.CreateNew(10, 10, wordList);
                    for (var y = 0; y < ws.WordSearchLetters.GetLength(1); y++)
                    {
                        for (var x = 0; x < ws.WordSearchLetters.GetLength(0); x++)
                        {
                            if (showCheats && ws.HasHiddenWord(x, y))
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.White;
                            }
                            Console.Write($"{ws.WordSearchLetters[x, y]} ");
                        }
                        Console.WriteLine();
                    }
                    Console.ReadKey();
                    break;
                }
                else if (num.Key == ConsoleKey.E)
                {
                    Console.Clear();
                    var ws = WordSearch.CreateNew(10, 10, wordList2);
                    for (var y = 0; y < ws.WordSearchLetters.GetLength(1); y++)
                    {
                        for (var x = 0; x < ws.WordSearchLetters.GetLength(0); x++)
                        {
                            if (showCheats && ws.HasHiddenWord(x, y))
                            {
                                Console.ForegroundColor = ConsoleColor.Blue;
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.White;
                            }
                            Console.Write($"{ws.WordSearchLetters[x, y]} ");
                        }
                        Console.WriteLine();
                    }
                    Console.ReadKey();
                    break;
                }
                else if (num.Key == ConsoleKey.T)
                {
                    Console.Clear();
                    var ws = WordSearch.CreateNew(10, 10, wordList3);

                    for (var y = 0; y < ws.WordSearchLetters.GetLength(1); y++)
                    {
                        for (var x = 0; x < ws.WordSearchLetters.GetLength(0); x++)
                        {
                            if (showCheats && ws.HasHiddenWord(x, y))
                            {
                                Console.ForegroundColor = ConsoleColor.Green;
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.White;
                            }
                            Console.Write($"{ws.WordSearchLetters[x, y]} ");
                        }
                        Console.WriteLine();
                    }
                    Console.ReadKey();
                    break;
                }
                else
                {
                    Console.Beep();
                }
            } while (true);
        }