|
10 years ago | |
---|---|---|
.. | ||
KongregateAPI.cs | 10 years ago | |
README.md | 10 years ago |
A pure code implementation of the Kongregate statistics API for Unity as a single C# file. The statistics API is used for counting items (such as level completions, enemies killed, high score, etc) on Kongregate games. Games implementing the API also get a bigger share of ad revenue from the website, where eligible.
While the Kongregate API is relatively simple to implement, most of the implementation examples out there use JavaScript or require you to manually create GameObjects. This implementation minimizes the amount of work needed for setup and use.
Main
game class), create an instance of the KongregateAPI:
KongregateAPI kongregate = KongregateAPI.Create();
kongregate.SubmitStats(name, value);For example:
kongregate.SubmitStats("high-score", 1000); kongregate.SubmitStats("tanks-destroyed", 1);
Create()
(Static): creates a KongregateAPI
instance and returns it (automatically creating a GameObject
for itself so it can receive events).SubmitStats(string name, int value)
: submit statistics to the Kongregate API.isConnected
: returns whether the user is properly connected to the Kongregate site API. Read-only.userId
: id of the current user. Read-only.userName
: name of the current user. Read-only.gameAuthToken
: game authorization token. Read-only.In general, you don't need to do anything special for your code to work on Kongregate. Just implement the above code and you're good.
Notice, however, that:
kongregate
object is not instantiated). The API only works after your game is properly published.?debug_level=4
to the URL of the game, and reload the page. This makes the JavaScript console (F12 on Chrome) output what the API is receiving from your game.