コード例 #1
0
ファイル: Program.cs プロジェクト: werewolfred/castle-grimtol
 public static void Main(string[] args)
 {
     Console.Clear();
     Project.Game CastleGame = new Project.Game();
     CastleGame.Setup();
     while (Running)
     {
         CastleGame.GetInput();
     }
 }
コード例 #2
0
        public static void Main(string[] args)
        {
            Console.Clear();
            //some user input
            System.Console.WriteLine("Welcome to Castle Grimtol!\n\nThis game is not for the faint of heart. If you are pregnant or nursing or have high blood pressure, or are prone to fainting, you might want to find another game.\n\nReady to start the game? (Y/N)");
            bool loop = true;

            do
            {
                string playGame = Console.ReadLine().ToUpper();
                if (playGame == "Y")
                {
                    loop = false;
                    Player NewPlayer = new Player();
                    //start game
                    Console.Clear();
                    System.Console.WriteLine("What is your name?\n");
                    NewPlayer.Name = Console.ReadLine();
                    Game newGame = new Game(NewPlayer);
                    newGame.Setup();
                    Console.Clear();
                    Console.WriteLine($"Brave Young Warrior {NewPlayer.Name}, our forces are failing and the enemy grows stronger everyday. I fear if we don't act now our people will be driven from their homes. These dark times have left us with one final course of action. We must cut the head off of the snake by assasinating the Dark Lord of Grimtol... Our sources have identified a small tunnel that leads into the rear of the castle.\n\nOnce you sneak through the tunnel you will need to find a way to disguise yourself and kill the Dark Lord. We don't know exactly how so you'll need to use your wit and cunning to think of something.\n\nGood Luck brave one.\n\nPress ENTER to sneak through the tunnel");
                    Console.ReadLine();
                    Console.Clear();
                    Console.WriteLine("Whew! You successfully snuck through the tunnel.");
                    newGame.playGame = true;
                    newGame.Run();
                    // newGame.Go(direction);    ?
                }
                else if (playGame == "N")
                {
                    Console.Clear();
                    System.Console.WriteLine("That's ok. It's best to take care of your health.\n ...even if it does mean the total destruction of the kingdom of Grimtol.");
                    System.Console.WriteLine("\nPress any key to finish deserting the game");
                    Console.ReadKey();
                    loop = false;
                }
                else
                {
                    System.Console.WriteLine("\n...Wat?\n");
                }
            } while (loop);
            //MyGame.Go(directioin from the user)
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: awhip2635/castle-grimtol
        public static void Main(string[] args)
        {
            Project.Game MyGame = new Project.Game();
            MyGame.Setup();
            System.Console.WriteLine("Welcome to my game! What is your name?");
            string heroName = System.Console.ReadLine();

            Console.Clear();
            System.Console.WriteLine($"{heroName}, you have been trapped within a series of caverns! Find your way out!");
            MyGame.ListCommands();
            System.Console.WriteLine("Begin? Y/N");
            string userInput = System.Console.ReadLine().ToUpper();

            if (userInput == "Y")
            {
                MyGame.PlayGame();
                MyGame.Reset();
            }
            else
            {
                System.Console.WriteLine("Suit Yourself");
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: Ramsey-B/haunted-delivery
        public static void Main(string[] args)
        {
            Project.Game game = new Project.Game();
            game.Setup();
            bool quit = false;

            while (game.Playing)
            {
                game.Look();
                string   userChoice = game.UserInput().ToLower();
                string[] userAction = userChoice.Split(' ');
                switch (userAction[0])
                {
                case "l":
                case "look":
                    Console.Clear();
                    game.Look();
                    break;

                case "h":
                case "help":
                    Console.Clear();
                    Console.WriteLine("Look around room: l or look");
                    Console.WriteLine("Take item: t or take");
                    Console.WriteLine("View inventory: i or inventory");
                    Console.WriteLine("Use item: u or use");
                    Console.WriteLine("Quit: q or quit");
                    Console.WriteLine("To get a cheat: c or cheat");
                    Console.WriteLine("Select choice: enter number or name of choice");
                    Console.WriteLine("To answer puzzles, simple type and enter your answer. \n");
                    break;

                case "t":
                case "take":
                    Console.Clear();
                    string choice = "";
                    for (int i = 1; i < userAction.Length; i++)
                    {
                        choice += userAction[i] + " ";
                    }
                    game.TakeItem(choice.Trim());
                    break;

                case "i":
                case "inventory":
                    Console.Clear();
                    Console.WriteLine("Inventory: ");
                    game.CurrentPlayer.Inventory.ForEach(item =>
                    {
                        Console.WriteLine(item.Name + ":" + " " + item.Description);
                    });
                    Console.WriteLine();
                    break;

                case "u":
                case "use":
                    Console.Clear();
                    string useChoice = "";
                    for (int i = 1; i < userAction.Length; i++)
                    {
                        useChoice += userAction[i] + " ";
                    }
                    game.UseItem(useChoice.Trim());
                    break;

                case "q":
                case "quit":
                    Console.Clear();
                    Console.WriteLine("Are you sure you wanna give up??? Y/n");
                    string answer = Console.ReadLine().ToLower();
                    if (answer == "y" || answer == "yes")
                    {
                        quit         = true;
                        game.Playing = false;
                    }
                    break;

                case "c":
                case "cheat":
                    Console.Clear();
                    if (game.CurrentRoom.Cheat.Length > 0)
                    {
                        Console.WriteLine("cheat: " + game.CurrentRoom.Cheat);
                    }
                    else
                    {
                        Console.WriteLine("Well... to late now...");
                    }
                    break;

                case "go":
                case "g":
                    Console.Clear();
                    string goChoice = "";
                    for (int i = 1; i < userAction.Length; i++)
                    {
                        goChoice += userAction[i] + " ";
                    }
                    game.CheckChoice(goChoice.Trim());
                    break;

                default:
                    Console.Clear();
                    game.CheckChoice(userChoice.Trim());
                    break;
                }
                game.CheckRoom();
                if (game.Playing == false && quit == false)
                {
                    Console.WriteLine("Wanna play again??? Y/n");
                    string input = Console.ReadLine();
                    if (input == "y" || input == "yes")
                    {
                        game.Setup();
                        game.Playing = true;
                    }
                }
            }
            Console.Clear();
            Console.ResetColor();
        }
コード例 #5
0
        public static void Main(string[] args)
        {
            bool   gameOver     = false;
            string userInput    = "";
            bool   itemDropped  = false;
            bool   doughnutUsed = false;
            Game   game         = new Game();

            game.Setup();

            System.Console.Clear();
            //  game.Intro ();
            game.DrawHelp();

            while (!gameOver)
            {
                userInput = game.Prompt();
                string command = userInput;
                string options = "";
                if (userInput.Contains(" "))
                {
                    var parsedInput = userInput.Split(' ');
                    command = parsedInput[0];
                    options = parsedInput[1];
                }

                switch (command)
                {
                case "go":
                    game.Go(options);
                    break;

                case "use":
                    game.UseItem(options);
                    if (options == "doughnut")
                    {
                        doughnutUsed = true;
                    }
                    break;

                case "drop":
                    game.DontUseItem(options);
                    if (options == "red_rag" || options == "doughnut")
                    {
                        itemDropped = true;
                    }
                    break;

                case "look":
                    Console.Clear();
                    game.CurrentRoom.GetDescription();
                    break;

                case "inventory":
                    System.Console.WriteLine($@"
            Player's Inventory
            ------------------");
                    if (game.CurrentPlayer.Inventory.Count > 0)
                    {
                        foreach (Item itm in game.CurrentPlayer.Inventory)
                        {
                            System.Console.WriteLine($@" {itm.Name}");
                        }
                    }
                    else
                    {
                        System.Console.WriteLine("No items available for use");
                    }
                    game.Prompt();
                    break;

                case "help":
                    game.DrawHelp();
                    game.Prompt();
                    break;

                case "quit":

                    System.Console.WriteLine($@"
                    \~~~~~~~~~~~~~~~~~~~~~~~~~~~\
                     \   Thanks for Playing!     \
                      \~~~~~~~~~~~~~~~~~~~~~~~~~~~\

                    ");
                    gameOver = true;
                    break;

                default:
                    game.DrawHelp();
                    game.Prompt();
                    break;
                }

                if ((options == "red_rag" || options == "doughnut") && (itemDropped))
                {
                    gameOver = true;
                }
                if (doughnutUsed)
                {
                    gameOver = true;
                }
            } //Main{
        }