Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

scillgame/scill-csharp

Repository files navigation

SCILL - the C# library for the SCILL API

CI

SCILL gives you the tools to activate, retain and grow your user base in your app or game by bringing you features well known in the gaming industry: Gamification. We take care of the services and technology involved so you can focus on your game and content.

Some parts of this C# SDK are automatically generated by the Swagger Codegen project. You can find the OpenAPI specification in this repository: SCILL OpenAPI Specs.

Frameworks supported

  • .NET 4.0 or later
  • Windows Phone 7.1 (Mango)

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package MQTTnet40

About SCILL

SCILL is a fully customizable toolkit that enables you to integrate tailored challenges and full-fledged Battle Passes to your game, app and website. SCILL connects seamlessly to your user account and payment systems, adding new retention and monetization layers within minutes.

Learn more about SCILL here: https://www.scillgame.com.

Developer documentation can be found here: https://developers.scillgame.com

Getting Started

The API has two main entries: SCILLBackend and SCILLClient. The SCILLBackend class requires an API key to initialize and should only be used in safe environments like a backend. SCILLBackend is also used to generate an access token that is required when initializing the SCILLClient class. SCILLClient offers client side functionality like sending events and querying users challenges and battle passes.

More info about that can be found in our extensive developer documentation: https://developers.scillgame.com.

Both classes SCILLBackend and SCILLClient wrap OpenAPI auto generated APIs like ChallengesApi. You may use them directly, have a look in the source of SCILLBackend and SCILLClient on how to set the API key or Access Token required for the backend REST APIs.

Check out this code from our Unity example to understand how to use this API:

using System.Collections.Generic;
using System.Threading.Tasks;
using SCILL;
using SCILL.Api;
using SCILL.Model;
using UnityEngine;

public class SCILLManager : MonoBehaviour
{
    // Properties to be set in the Unity inspector
    public string APIKey;
    public string AppId;
    public SCILL.Environment environment;

    // Getter for the access token
    public string AccessToken => _accessToken;
    
    // In this case, we use a unique devide identifier. Multi device support requires a user account system like
    // Steam, Playfab, etc.
    public string UserId => SystemInfo.deviceUniqueIdentifier;
    
    // Default session id. This is just an example value.
    public string SessionId => "1234";

    // Getter for the singleton instance of this class
    public static SCILLManager Instance; // **<- reference link to SCILL
    
    // Simple wrappers to get SCILL product APIs
    public EventsApi EventsApi => _scillClient.EventsApi;
    public ChallengesApi ChallengesApi => _scillClient.ChallengesApi;
    public BattlePassesApi BattlePassesApi => _scillClient.BattlePassesApi;
    public SCILLClient SCILLClient => _scillClient;

    // Local instances of SCILLClient. Please note, that SCILLBackend should not be used in game clients in production!
    private SCILLBackend _scillBackend;
    private SCILLClient _scillClient;
    private string _accessToken;
    
    private void Awake()
    {
        // Create an instance of this class and make sure it stays (also survives scene changes)
        if (Instance == null) {
            Instance = this;
            
            // This part should be done in the backend if possible to not expose the API key
            _scillBackend = new SCILLBackend(this.APIKey, environment);
            _accessToken = _scillBackend.GetAccessToken(UserId);

            _scillClient = new SCILLClient(_accessToken, AppId, environment);
            
            DontDestroyOnLoad(gameObject);
        }
        else {
            Destroy(gameObject);
        }
    }

    /// <summary>
    /// Unity method called every frame
    /// </summary>
    private void Update()
    {
    }

    // Basic convenience function to send an event. Users global UserId and sessionId
    public async void SendEventAsync(string eventName, string eventType = "single", EventMetaData metaData = null)
    {
        // Please note, in some cases you should change session ids. This is just a simple example where we don't need
        // to do that
        Debug.Log("Sending event " + eventName);
        var payload = new EventPayload(UserId, SessionId, eventName, eventType, metaData);
        var response = await EventsApi.SendEventAsync(payload);
        Debug.Log(response);
    }

    // Basic wrapper for getting personal challenges
    public async Task<List<ChallengeCategory>> GetPersonalChallengesAsync()
    {
        return await ChallengesApi.GetPersonalChallengesAsync(AppId);
    }
}

Build from source

Run the following command to generate the DLL

  • [Mac/Linux] /bin/sh build.sh
  • [Windows] build.bat

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using SCILL;
using SCILL.Api;
using SCILL.Model;