public static void Main(string[] args) { Game.Game game = new Game.Game(); game.Playing = true; game.Setup(); game.BuildRooms(); Console.ForegroundColor = ConsoleColor.Cyan; game.Look(game.CurrentRoom); Console.ForegroundColor = ConsoleColor.White; while (game.Playing) { string userChoice = game.GetUserInput().ToLower(); string[] userAction = userChoice.Split(' '); Room nextRoom; game.CurrentRoom.Exits.TryGetValue(userAction[0], out nextRoom); if (userAction[0] == "l" || userAction[0] == "look") { System.Console.WriteLine("\n"); game.Look(game.CurrentRoom); } else if (userAction[0] == "h" || userAction[0] == "help") { game.Help(); } else if (userAction[0] == "t" || userAction[0] == "take" && userAction[1] != null) { game.TakeItem(userAction[1]); } else if (userAction[0] == "i" || userAction[0] == "inventory") { game.CurrentPlayer.ShowInventory(game.CurrentPlayer); } else if (userAction[0] == "q" || userAction[0] == "quit") { game.Playing = game.Quit(game.Playing); } else if (userAction[0] == "u" || userAction[0] == "use") { game.UseItem(userAction[1]); game.Look(game.CurrentRoom); } else if (nextRoom != null) { game.CurrentRoom = nextRoom; System.Console.WriteLine("\n"); game.CurrentPlayer.Score += 10; game.Look(game.CurrentRoom); } else { Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine("\nAfter attempting...you realize this is not the action you wanted to take. You should try again.\n"); Console.ForegroundColor = ConsoleColor.White; } } }
public static void Main(string[] args) { Console.BackgroundColor = ConsoleColor.White; Game.Game game = new Game.Game(); game.Playing = true; game.Setup(); game.BuildRooms(); game.Look(game.CurrentRoom); while (game.Playing) { game.CheckScore(); Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; string userChoice = game.GetUserInput().ToLower(); string[] userAction = userChoice.Split(' '); if (userChoice == "clear") { Console.Clear(); } Room nextRoom; game.CurrentRoom.Exits.TryGetValue(userAction[0], out nextRoom); if (game.CurrentRoom.Zombies > 0) { Console.WriteLine("Zombie attacks, deals 1 damage"); game.CurrentPlayer.Health--; } if (userAction[0] == "look" || userAction[0] == "l") { game.Look(game.CurrentRoom); } else if (userAction[0] == "quit" || userAction[0] == "q") { game.Playing = game.Quit(game.Playing); } else if (userAction[0] == "help" || userAction[0] == "h") { game.Help(); } else if (userAction[0] == "restart" || userAction[0] == "r") { game.PromptReset(); } else if (userAction[0] == "take" && userAction[1] != null) { game.TakeItem(userAction[1]); } else if (userAction[0] == "inventory" || userAction[0] == "inv" || userAction[0] == "i") { game.CurrentPlayer.ShowInventory(game.CurrentPlayer); } else if (userAction[0] == "use" || userAction[0] == "u") { game.UseItem(userAction[1]); game.Look(game.CurrentRoom); } else if (nextRoom != null) { game.CurrentRoom = nextRoom; Console.WriteLine("\n\n\n"); game.Look(game.CurrentRoom); } else { Console.WriteLine("Not sure what you are trying to do..."); } } }
public static void Main(string[] args) { Game.Game game = new Game.Game(); game.Playing = true; game.Setup(); game.BuildRooms(); game.Look(game.CurrentRoom); while (game.Playing) { string userChoice = game.GetUserInput().ToLower(); string[] userAction = userChoice.Split(' '); Room nextRoom; game.CurrentRoom.Exits.TryGetValue(userAction[0], out nextRoom); if (game.CurrentRoom.Name == "LOSER!!!, ") { game.End(); } if (game.CurrentRoom.Name == "YOU WIN!!, ") { game.End(); } if (userAction[0] == "l" || userAction[0] == "look") { Console.WriteLine("\n"); game.Look(game.CurrentRoom); } else if (userAction[0] == "h" || userAction[0] == "help") { game.Help(); } else if (userAction[0] == "t" || userAction[0] == "take" && userAction[1] != null) { game.TakeItem(userAction[1]); } else if (userAction[0] == "i" || userAction[0] == "inventory") { game.CurrentPlayer.ShowInventory(game.CurrentPlayer); } else if (userAction[0] == "q" || userAction[0] == "quit") { game.Playing = game.Quit(game.Playing); } else if (userAction[0] == "u" || userAction[0] == "use") { game.UseItem(userAction[1]); game.Look(game.CurrentRoom); } else if (userAction[0] == "r" || userAction[0] == "reset") { game.Reset(); } else if (nextRoom != null) { game.CurrentRoom = nextRoom; System.Console.WriteLine("\n"); game.Look(game.CurrentRoom); } else { System.Console.WriteLine("Poor Choice"); } } }