コード例 #1
0
ファイル: Program.cs プロジェクト: MHLoppy/Rise_of_Music
        private static void SetPlayerColor()
        {
            CurrentGameXml currentGameXml = new CurrentGameXml();

            Console.WriteLine("Color Options");
            Console.WriteLine("--------------");
            Console.WriteLine("Red        (1)");
            Console.WriteLine("Blue       (2)");
            Console.WriteLine("Purple     (3)");
            Console.WriteLine("Green      (4)");
            Console.WriteLine("Yellow     (5)");
            Console.WriteLine("Light Blue (6)");
            Console.WriteLine("White      (7)");
            Console.WriteLine("Orange     (8)");
            
            // Loop until [1-8] is typed
            while (true)
            {
                Console.Write("What color will you play as? [1-8]: ");

                // Get the player number
                String playerNumber = Console.ReadKey().KeyChar.ToString();

                // If the player number chosen is valid
                if (playerNumber == "1" || playerNumber == "2" || playerNumber == "3" || playerNumber == "4" ||
                    playerNumber == "5" || playerNumber == "6" || playerNumber == "7" || playerNumber == "8")
                {
                    Console.WriteLine();
                    Console.WriteLine("Setting player color to: " + playerNumber);

                    switch (playerNumber)
                    {
                        case "1":
                            currentGameXml.PlayerColor = "Red";
                            break;
                        case "2":
                            currentGameXml.PlayerColor = "Blue";
                            break;
                        case "3":
                            currentGameXml.PlayerColor = "Purple";
                            break;
                        case "4":
                            currentGameXml.PlayerColor = "Green";
                            break;
                        case "5":
                            currentGameXml.PlayerColor = "Yellow";
                            break;
                        case "6":
                            currentGameXml.PlayerColor = "Light Blue";
                            break;
                        case "7":
                            currentGameXml.PlayerColor = "White";
                            break;
                        case "8":
                            currentGameXml.PlayerColor = "Orange";
                            break;
                    }

                    Program.playerNumber = playerNumber;

                    // Save to config file and break
                    currentGameXml.PlayerNumber = playerNumber;
                    currentGameXml.Save();
                    break;
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine("Error: Invalid choice.");
                }
            }
        }
コード例 #2
0
        private static void SetPlayerColor()
        {
            CurrentGameXml currentGameXml = new CurrentGameXml();

            Console.WriteLine("Color Options");
            Console.WriteLine("--------------");
            Console.WriteLine("Red        (1)");
            Console.WriteLine("Blue       (2)");
            Console.WriteLine("Purple     (3)");
            Console.WriteLine("Green      (4)");
            Console.WriteLine("Yellow     (5)");
            Console.WriteLine("Light Blue (6)");
            Console.WriteLine("White      (7)");
            Console.WriteLine("Orange     (8)");

            // Loop until [1-8] is typed
            while (true)
            {
                Console.Write("What color will you play as? [1-8]: ");

                // Get the player number
                String playerNumber = Console.ReadKey().KeyChar.ToString();

                // If the player number chosen is valid
                if (playerNumber == "1" || playerNumber == "2" || playerNumber == "3" || playerNumber == "4" ||
                    playerNumber == "5" || playerNumber == "6" || playerNumber == "7" || playerNumber == "8")
                {
                    Console.WriteLine();
                    Console.WriteLine("Setting player color to: " + playerNumber);

                    switch (playerNumber)
                    {
                    case "1":
                        currentGameXml.PlayerColor = "Red";
                        break;

                    case "2":
                        currentGameXml.PlayerColor = "Blue";
                        break;

                    case "3":
                        currentGameXml.PlayerColor = "Purple";
                        break;

                    case "4":
                        currentGameXml.PlayerColor = "Green";
                        break;

                    case "5":
                        currentGameXml.PlayerColor = "Yellow";
                        break;

                    case "6":
                        currentGameXml.PlayerColor = "Light Blue";
                        break;

                    case "7":
                        currentGameXml.PlayerColor = "White";
                        break;

                    case "8":
                        currentGameXml.PlayerColor = "Orange";
                        break;
                    }

                    Program.playerNumber = playerNumber;

                    // Save to config file and break
                    currentGameXml.PlayerNumber = playerNumber;
                    currentGameXml.Save();
                    break;
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine("Error: Invalid choice.");
                }
            }
        }