public override bool Move(Direction dir) { if (base.Move(dir)) { // We successfully moved! // Let's print our new location. LookCommand.Print(Location); return(true); } return(false); }
/// <summary> /// Starts and runs the game until the user ends the game. /// </summary> /// <param name="world">The world to run.</param> static void GameLoop(World world) { // We want to print the current location when the game starts, // so the player knows where he is. LookCommand.Print(world.Player.Location); while (true) { // The execute method tells us if we should update the world or not, // since we don't want to update the world if the command was invalid // or it was just inspecting something. if (PromptCommand(world).Execute(world.Player)) { world.Tick(); } Spacer(); } }