Smooth Windows 10 migration for desktop RPG Tale of Wuxia from BianFeng
Tale of Wuxia (侠客风云传) is a traditional desktop Win32 role-playing game (RPG) that was created by Heluo Studio. BianFeng, who bought the IP, wanted to publish this game in the Windows Store to attract new gamers, open a new distribution channel, and increase brand exposure. Although the game is developed on Unity, a widely-used engine, BianFeng determined that upgrading from version 4.x to 5.x for Universal Windows Platform (UWP) was too difficult. By using the Microsoft Desktop Bridge, BianFeng was able to convert the game in short time.
Game poster
Core team:
- Yunpeng Wang – General Manager, BianFeng
- Xin Huang – Chief Programmer, BianFeng
- Yizhi Yang – Chief Planning, BianFeng
- Yingguang Mei – Technical Evangelist, Microsoft
- Leon Liang – Senior Technical Evangelist, Microsoft
- David Yan – Technical Evangelist, Microsoft
BianFeng and Microsoft teams
Customer profile
Established in 1999, BianFeng came from two leading card-game companies in China: GameABC and GameTea. In 2013, it was acquired by Zhejiang Daily Media Group for ¥3.2 billion. From then on, BianFeng began to expend its business, which covers not only card games but also online chess and E-sports platforms, board games, web games, wireless terminals, and other interactive entertainment content and services. BianFeng won the title of “Top 10 China brand game enterprise” at the 2016 China Game Industry Annual Conference with revenue of more than ¥400 million from more than 10 million monthly active users (MAU).
Tales of Wuxia is a client offline game that comes from a famous series and combines role cultivation and RPG-style play. It tells the story of an ambitious young man who travels from afar to Luoyang to show admiration and respect for Master Shrimp. The Win32 version has been available on Steam (侠客风云传 Tale of Wuxia) for 10 months with more than 40,000 downloads. BianFeng plans a large website promotion for the Windows 10 version.
Problem statement
BianFeng sees the Windows Store as a new distribution channel that they can use to attract more gamers and as a new chance for their desktop games, like Wuxia, to attract more revenue.
To ensure compatibility on many platforms, such as Win32, iOS, and Android, BianFeng wisely adopted Unity, a popular cross-platform game engine. But they realized that the Unity version would be a big issue when they decided to publish the game to the Windows Store. The Unity 4.x engine used by Wuxia doesn’t support Windows 10; BianFeng had to upgrade the engine to Unity 5.2 or later if they couldn’t find another solution. Upgrading Unity across major versions means a heavy workload, which might include rewriting shaders, replacing game physics, upgrading animation, fixing plugins, and so on. BianFeng estimated that this job would cost a senior engineer more than 30 days.
Using the Desktop Bridge not only helped BianFeng migrate smoothly but also saved a great deal of time and money.
Solution, steps, and delivery
With the Desktop Bridge, the team migrated Wuxia to UWP in short time. They also integrated Live Tiles into the game to maintain high retention. All jobs include the following four steps.
Step 1: Set up
- Download the Desktop App Converter tool from the Windows Store.
- Download the Desktop App Converter base images (*.wim).
- Run Desktop App Converter as administrator.
- From the tool console window, run
Set-ExecutionPolicy bypass
. - Set up the converter by running
DesktopAppConverter.exe -Setup -BaseImage .\BaseImage-14393.wim -Verbose
. - Reboot.
The base image file should be matched with the build of Windows 10 on the host computer. In this case, the team chose BaseImage-14393.wim for Windows 10 build 14393.
Step 2: Convert
- Copy all the game files to a separate directory.
-
From the tool console window, create the Windows 10 app package by running the following command:
DesktopAppConverter.exe -Installer E:\XiaKeExe -Destination E:\Output -PackageName "76C7AEE9.17933E72A5ED1" -Publisher "CN=B19F025D-990F-467C-B5C2-E5F402A0BDFA" -Version 1.0.0.0 -appid "XiaKe" -makeappx -AppExecutable game.exe -packagearch x86
We get an AppX package and two directories for log files and package resources at the end of conversion.
Development tips
- In most case, the gaming package is green. We should take advantage of this feature and skip the process of using a third-party installer to create an MSI package. In this case, the team used the parameter
-Installer E:\XiaKeExe
to point to the root directory of the game app’s files with no-installer conversion. - Do remember to specify the string for
-appid
. This step will set the AppID in the Windows app package manifest. If it is not specified, AppID will be set to the value passed for PackageName. However, PackageName sometimes is only a number, which will cause a compile-time error. In this case, the team use the parameter-appid "XiaKe"
to get around the problem. - For the version number, like “major_number.minor_number.build_number.revision_number”, keep the revision number at “0”.
Step 3: Enhance
Live Tiles is a very cool and significant UWP feature for a gaming app. A user might enter the game and become a gamer just because he likes the beautiful, dynamic icon that appears when he pins the app on the Start menu. (Such things do happen.) And the game publisher can use tile notifications to communicate new information to the players, such as game updates, advertising messages, and social-media keywords, which helps with retention. The team decided to integrate the Live Tiles feature into Wuxia.
Issue
We couldn’t call UWP APIs in the Unity project for the following reasons:
- The .NET version of the Win32 platform in Unity is only 2.0.
-
Because no other project will be created when the game is built targeting Win32 in Unity Editor, we can’t retarget the app to .NET 4.6.1.
Unity build settings
Solution
The team used UWPWrappers, a C++ open-source project comprising runtime component technology that can create a dynamic link library, to enable a bridge between UWP and the Unity C# project.
- Clone or download UWPWrappers from GitHub: Microsoft/DesktopBridgeToUWP-Samples.
-
Open the project and add a function named CreateTile() to UWPWrappers.cpp.
DllExport bool __stdcall CreateTile(int index) { try { String ^xml = "<tile><visual><binding template='TileSmall'><image placement='peek' src='Assets/Apps/icon0.jpg'/><image placement='background' src='Assets/AppSmallTile.scale-100.png' hint-removeMargin='true'/></binding><binding template='TileMedium'><image placement='peek' src='Assets/Apps/icon1.jpg'/><image placement='background' src='Assets/AppMedTile.scale-100.png' hint-removeMargin='true'/></binding><binding template='TileWide'><image placement='peek' src='Assets/Apps/icon2.jpg'/><image placement='background' src='Assets/AppWideTile.scale-100.png' hint-removeMargin='true'/></binding><binding template='TileLarge'><image placement='peek' src='Assets/Apps/icon3.jpg'/><image placement='background' src='Assets/AppLargeTile.scale-100.png' hint-removeMargin='true'/></binding><visual></tile>"; XmlDocument^ tileXml = ref new XmlDocument(); tileXml->LoadXml(xml); TileNotification^ tileNotification = ref new TileNotification(tileXml); TileUpdateManager::CreateTileUpdaterForApplication()->Update(tileNotification); } catch (Exception^ ex) { return false; } return true; }
- Build the project to create UWPWrappers.dll.
- Copy UWPWrappers.dll to the PackageFiles folder, ensuring that the DLL and the app executable are in the same directory.
-
Call CreateTile() in the Unity project.
[DllImport("UWPWrappers.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall)] extern static bool CreateTile(int n); void ReadSettingIni() { Debug.Log("ReadSettingIni "); string strRes = IniFile.IniReadValue("setting", "screenSize"); int iIndex = strRes.IndexOf(","); int iWidth = 1024; int iHeight = 576; bool bFullScreen = false; if (iIndex >= 0) { string strWidth = strRes.Substring(0, iIndex); if (int.TryParse(strWidth, out iWidth) == false) { iWidth = 1024; iHeight = 576; } string strHeight = strRes.Substring(iIndex + 1, strRes.Length - iIndex - 1); if (int.TryParse(strHeight, out iHeight) == false) { iWidth = 1024; iHeight = 576; } } string strFullScreen = IniFile.IniReadValue("setting", "fullscreen"); if (strFullScreen.ToLower() == "true") bFullScreen = true; else bFullScreen = false; iWidth = 1024; iHeight = Screen.height * 1024 / Screen.width; Debug.Log(string.Format("SetResolution {0}x{1} {2}", iWidth.ToString(), iHeight.ToString(), bFullScreen.ToString())); #if UNITY_ANDROID || UNITY_IPHONE Screen.SetResolution ( iWidth , iHeight , bFullScreen ); #else Screen.fullScreen = true; CreateTile(0); //Create Tile #endif }
- Copy tile resources (icon0.jpg, icon1.jpg, icon2.jpg, and icon3.jpg) to the PackageFiles/Assets/Apps folder to match the XML settings.
Step 4: Sign and publish
- In the app manifest, update DisplayName, PublisherDisplayName, and Description by hand.
-
From the command window, create the AppX package manually by running the following:
cd "C:\Program Files (x86)\Windows Kits\10\bin\x86" .\makeappx.exe pack /d "E:\Output\76C7AEE9.17933E72A5ED1\PackageFiles" /p "E:\Output\76C7AEE9.17933E72A5ED1\XiaKe.appx" /l
-
Create a certificate using MakeCert.exe:
.\MakeCert.exe -r -h 0 -n "CN=B19F025D-990F-467C-B5C2-E5F402A0BDFA" -eku 1.3.6.1.5.5.7.3.3 -pe -sv E:\cert\my.pvk E:\cert\my.cer
-
Copy public and private key information into the certificate:
.\pvk2pfx.exe -pvk E:\cert\my.pvk -spc E:\cert\my.cer -pfx E:\cert\my.pfx
-
Sign the app package with the certificate:
.\signtool.exe sign -f E:\cert\my.pfx -fd SHA256 -v E:\Output\76C7AEE9.17933E72A5ED1\XiaKe.appx
Video demo
Photos from the hackfest
A meeting during the hackfest
Task list board
Development during hackfest
Opportunities going forward
Microsoft has some upcoming chances to work with the BianFeng team:
- BianFeng plans to monetize Wuxia by adding in-app purchases. More UWP features including Microsoft payment would be integrated.
- Several other BianFeng titles are in the pipeline for the Windows Store, again using Desktop Bridge for the conversion.
Conclusion
After the hackfest, Ke Pan, Vice President of BianFeng, said
“The Desktop Bridge is a set of technologies that enables developers to convert their Windows desktop application (for example, Win32, Windows Forms, or WPF) or game into a UWP app or game.
“With this technology, we can migrate our Win32 games to UWP, which reaches every Windows 10 PC and tablet immediately. We can proudly guarantee the user a wonderful experience installing and updating our games with the deployment we’ve done.
“Distributing through the Windows Store gets us increased reach to millions of Windows 10 users, who can acquire apps and games and make in-app purchases with local payment options. We also can add UWP features to the packages of our games, such as Live Tile updates, to keep retention high.
“We really appreciate the support from the Microsoft DX team, who helped us solve all the major issues while converting our game. We can now easily generate UWP games and integrate UWP APIs.”
Generally, a gaming app is entirely different from a normal app because of the higher demands for graphics rendering and more-complicated logic processes, which leads to more jobs to meet compatibility requirements. This case study shows that Desktop Bridge is completely applicable for Win32 games. The customer can enjoy a quick and smooth migration experence with Desktop Bridge. The time we spent was only two days. In some cases, using Desktop Bridge is even more convenient than using a cross-platform game engine, such as when
- The target platforms of the engine includes Win32 but doesn’t include Windows 10 UWP.
- The engine upgrade for Windows 10 is very troublesome, such as Unity4.x.
And publishing to the Windows Store makes the client safer: Strict check mechanisms and integrated UWP APIs benefit both gameplay and monetization. Let’s look forward to more UWP games in the future.
Additional resources
- “Tale of Wuxia” in the Windows Store: 侠客风云传
- Desktop Bridge samples on GitHub: Microsoft/DesktopBridgeToUWP-Samples
- News coverage of 2016 China Game Industry Annual Conference: 中国游戏产业年会十强大奖花落谁家