Converting a C♯ object to Construct 2 Dictionary format
First Pass: Visual Studio
Now you are ready to use the Construct2Convert.ToDictionary() inside a Controller Action to convert objects or collections, like arrays, to the Construct 2 Dictionary data format, example:
// An example object with the data to be sent to the game
PlayerData playerData = new PlayerData();
playerData.PlayerName = "John";
playerData.HiScore = 999;
// Use WebAPI2Construct to transform your data in a Construct 2 readable format
var playerDataJSONDictionary = Construct2Convert.ToDictionary(playerData);
return Ok(playerDataJSONDictionary); // Send the data to the game
Second Pass: Construct 2
1. When in Construct 2, use an AJAX object Request URL action to request the data to ASP.NET WEB API project that still runing in Visual Studio, or hosted in a web server.
2. Catch the data in the game using the AJAX On completed event.
3. Use a Dictionary object Load action to load the data from the AJAX.LastData variable.
4. After that you be able to read your data from inside the Dictionary.
Why using Construct 2 Dictionaries?
Using a Dictionary you will be able to send more complex data to the game at the same time.
Learn more at WebAPI2Construct project's website at GitHub