Template for unity games made by Assistive Cards
"Casual Game Music" and "Casual Game Sounds" packs are not licensed under the GNU General Public License v3.0
This is a documentation for GameAPI, which is the combination of Assistive Cards SDK, Settings API and Language Manager scripts. This module will be accessible from anywhere in game. GameAPI consists of methods for retrieving assets data, storing user preferences and translating UI elements at runtime.
Returns an object of type Status which holds information about network connection.
async Task<AssistiveCardsSDK.AssistiveCardsSDK.Status> CheckConnectionStatus()
Example usage;
AssistiveCardsSDK.AssistiveCardsSDK.Status status = new AssistiveCardsSDK.AssistiveCardsSDK.Status();
status = await CheckConnectionStatus();
Takes in a language code of type string and returns an object of type Packs which holds an array of Pack objects in the specified language.
async Task<AssistiveCardsSDK.AssistiveCardsSDK.Packs> GetPacks(string language)
Example usage;
AssistiveCardsSDK.AssistiveCardsSDK.Packs packs = new AssistiveCardsSDK.AssistiveCardsSDK.Packs();
packs = await GetPacks("en");
Takes in a language code and a pack slug of type string as parameters. Returns an object of type Cards which holds an array of Card objects in the specified pack and language.
async Task<AssistiveCardsSDK.AssistiveCardsSDK.Cards> GetCards(string language, string packSlug)
Example usage;
AssistiveCardsSDK.AssistiveCardsSDK.Cards cards = new AssistiveCardsSDK.AssistiveCardsSDK.Cards();
cards = await GetCards("en", "animals");
Takes in a language code of type string and returns an object of type Activities which holds an array of Activity objects in the specified language.
async Task<AssistiveCardsSDK.AssistiveCardsSDK.Activities> GetActivities(string language)
Example usage;
AssistiveCardsSDK.AssistiveCardsSDK.Activities activities = new AssistiveCardsSDK.AssistiveCardsSDK.Activities();
activities = await GetActivities("en");
Returns an object of type Languages which holds an array of Language objects.
async Task<AssistiveCardsSDK.AssistiveCardsSDK.Languages> GetLanguages()
Example usage;
AssistiveCardsSDK.AssistiveCardsSDK.Languges languages = new AssistiveCardsSDK.AssistiveCardsSDK.Languages();
languages = await GetLanguages();
Takes in an object of type Packs as the first parameter and a pack slug of type string as the second parameter. Filters the given array of packs and returns an object of type Pack corresponding to the specified pack slug.
AssistiveCardsSDK.AssistiveCardsSDK.Pack GetPackBySlug(AssistiveCardsSDK.AssistiveCardsSDK.Packs packs, string packSlug)
Example usage;
AssistiveCardsSDK.AssistiveCardsSDK.Pack pack = new AssistiveCardsSDK.AssistiveCardsSDK.Pack();
pack = GetPackBySlug(packs, "animals");
Takes in an object of type Cards as the first parameter and a card slug of type string as the second parameter. Filters the given array of cards and returns an object of type Card corresponding to the specified card slug.
AssistiveCardsSDK.AssistiveCardsSDK.Card GetCardBySlug(AssistiveCardsSDK.AssistiveCardsSDK.Cards cards, string cardSlug)
Example usage;
AssistiveCardsSDK.AssistiveCardsSDK.Card card = new AssistiveCardsSDK.AssistiveCardsSDK.Card();
card = GetCardBySlug(cards, "bee");
Takes in an object of type Activities as the first parameter and an activity slug of type string as the second parameter. Filters the given array of activities and returns an object of type Activity corresponding to the specified activity slug.
AssistiveCardsSDK.AssistiveCardsSDK.Activity GetActivityBySlug(AssistiveCardsSDK.AssistiveCardsSDK.Activities activities, string slug)
Example usage;
AssistiveCardsSDK.AssistiveCardsSDK.Activity activity = new AssistiveCardsSDK.AssistiveCardsSDK.Activity();
activity = GetActivityBySlug(activities, "practicing-speaking");
Takes in an object of type Languages as the first parameter and a language code of type string as the second parameter. Filters the given array of languages and returns an object of type Language corresponding to the specified language code.
AssistiveCardsSDK.AssistiveCardsSDK.Language GetLanguageByCode(AssistiveCardsSDK.AssistiveCardsSDK.Languages languages, string languageCode)
Example usage;
AssistiveCardsSDK.AssistiveCardsSDK.Language language = new AssistiveCardsSDK.AssistiveCardsSDK.Language();
language = GetLanguageByCode(languages, "en");
Takes in a pack slug of type string as the first parameter and an image size of type integer as the second parameter. Returns an object of type Texture2D corresponding to the specified pack slug and image size.
async Task<Texture2D> GetPackImage(string packSlug, int imgSize)
Example usage;
Texture2D texture;
texture = await GetPackImage("animals", 512);
Takes in a pack slug of type string as the first parameter, a card slug of type string as the second parameter and an image size of type integer as the third parameter. Returns an object of type Texture2D corresponding to the specified pack slug, card slug and image size.
async Task<Texture2D> GetCardImage(string packSlug, string cardSlug, int imgSize)
Example usage;
Texture2D texture;
texture = await GetCardImage("animals", "bee", 512);
Takes in an activity slug of type string and returns an object of type Texture2D corresponding to the specified activity slug.
Note that the image size is 1200x800
async Task<Texture2D> GetActivityImage(string activitySlug)
Example usage;
Texture2D texture;
texture = await GetActivityImage("brushing-teeth");
Takes in an avatar ID of type string as the first parameter and an image size of type integer as the second parameter. Returns an object of type Texture2D corresponding to the specified avatar ID and image size.
Note that avatar types have a maximum of 33 assets for the category "boy", 27 assets for the category "girl" and 29 assets for the category "misc". e.g. boy13, girl23, misc05
async Task<Texture2D> GetAvatarImage(string avatarId, int imgSize)
Example usage;
Texture2D texture;
texture = await GetAvatarImage("girl23",512);
Returns an object of type Apps which holds an array of App objects.
async Task<AssistiveCardsSDK.AssistiveCardsSDK.Apps> GetApps()
Example usage;
AssistiveCardsSDK.AssistiveCardsSDK.Apps apps = new AssistiveCardsSDK.AssistiveCardsSDK.Apps();
apps = await GetApps();
Takes in an app slug of type string as the first parameter and an optional image size of type integer as the second parameter. Returns an object of type Texture2D corresponding to the specified app slug and image size.
Default image size is 1024x1024
async Task<Texture2D> GetAppIcon(string appSlug, int imgSize)
Example usage;
Texture2D texture;
texture = await GetAppIcon("leeloo", 683);
Returns an object of type Games which holds an array of Game objects.
public AssistiveCardsSDK.AssistiveCardsSDK.Games GetGames()
Example usage;
AssistiveCardsSDK.AssistiveCardsSDK.Games games = new AssistiveCardsSDK.AssistiveCardsSDK.Games();
games = GetGames();
Takes in a game slug of type string as the first parameter and an optional image size of type integer as the second parameter. Returns an object of type Texture2D corresponding to the specified game slug and image size.
Default image size is 1024x1024
public async Task<Texture2D> GetGameIcon(string gameSlug, int imgSize)
Example usage;
Texture2D texture;
texture = await GetGameIcon("memory", 256);
Takes in a language code of type string as the first parameter, a pack slug of type string as the second parameter and an optional image size of type integer as the third parameter. Returns an array of Texture2D objects corresponding to the specified language, pack slug and image size.
Default image size is 256x256
async Task<Texture2D[]> GetCardImagesByPack(string languageCode, string packSlug, int imgSize)
Example usage;
Texture2D[] textures;
texture = await GetCardImagesByPack("en", "school", 512);
Takes in a category of type string as the first parameter and an optional image size of type integer as the second parameter. Returns an array of Texture2D objects corresponding to the specified category and image size.
Default image size is 256x256
async Task<Texture2D[]> GetAvatarImagesByCategory(string category, int imgSize)
Example usage;
Texture2D[] textures;
texture = await GetAvatarImagesByCategory("misc",512);
Takes in a nickname of type string and stores it in PlayerPrefs.
public void SetNickname(string nickname)
Retrieves the nickname data stored in PlayerPrefs.
Default value is "".
public string GetNickname()
Takes in a language of type string and stores it in PlayerPrefs.
public void SetLanguage(string language)
Retrieves the language data stored in PlayerPrefs.
Default value is system language.
public string GetLanguage()
Takes in an avatarID of type string and stores it in PlayerPrefs.
public void SetAvatarImage(string avatarID)
Retrieves a sprite corresponding to the avatarID data stored in PlayerPrefs.
Default value is "default".
public async Task<Sprite> GetAvatarImage()
Takes in a period of type string and stores it in PlayerPrefs.
public void SetReminderPreference(string period)
Retrieves the reminder period preference data stored in PlayerPrefs.
Default value is "Weekly".
public string GetReminderPreference()
Takes in a single parameter of type integer named isUsabilityTipsActive and stores it in PlayerPrefs.
public void SetUsabilityTipsPreference(int isUsabilityTipsActive)
Retrieves the usability tips preference data stored in PlayerPrefs.
Default value is 1.
public int GetUsabilityTipsPreference()
Takes in a single parameter of type integer named isPromotionsNotificationActive and stores it in PlayerPrefs.
public void SetPromotionsNotificationPreference(int isPromotionsNotificationActive)
Retrieves the promotions notification preference data stored in PlayerPrefs.
Default value is 0.
public int GetPromotionsNotificationPreference()
Takes in a single parameter of type string named TTSPreference and stores it in PlayerPrefs.
public void SetTTSPreference(string TTSPreference)
Retrieves the TTS preference data stored in PlayerPrefs.
Default value is locale of the system language.
async public Task<string> GetTTSPreference()
Takes in a single parameter of type integer named isHapticsActive and stores it in PlayerPrefs.
public void SetHapticsPreference(int isHapticsActive)
Retrieves the haptics preference data stored in PlayerPrefs.
Default value is 1.
public int GetHapticsPreference()
Takes in a single parameter of type integer named isPressInActive and stores it in PlayerPrefs.
public void SetActivateOnPressInPreference(int isPressInActive)
Retrieves the activate on press in preference data stored in PlayerPrefs.
Default value is 0.
public int GetActivateOnPressInPreference()
Takes in a single parameter of type integer named isVoiceGreetingActive and stores it in PlayerPrefs.
public void SetVoiceGreetingPreference(int isVoiceGreetingActive)
Retrieves the voice greeting on start preference data stored in PlayerPrefs.
Default value is 1.
public int GetVoiceGreetingPreference()
Takes in a single parameter of type string named isPremium and stores it in PlayerPrefs.
public void SetPremium(string isPremium)
Retrieves the premium status data stored in PlayerPrefs.
Default value is 0.
public string GetPremium()
Takes in a single parameter of type string named isSubscribed and stores it in PlayerPrefs.
public void SetSubscription(string isSubscribed)
Retrieves the subscription status data stored in PlayerPrefs.
Default value is 0.
public string GetSubscription()
Takes in a single parameter of type integer named isSFXOn and stores it in PlayerPrefs.
public void SetSFXPreference(int isSFXOn)
Retrieves the SFX preference data stored in PlayerPrefs.
Default value is 1.
public int GetSFXPreference()
Takes in a single parameter of type integer named isMusicOn and stores it in PlayerPrefs.
public void SetMusicPreference(int isMusicOn)
Retrieves the music preference data stored in PlayerPrefs.
Default value is 1.
public int GetMusicPreference()
Takes in a single parameter of type integer named isTTSOn and stores it in PlayerPrefs.
public void SetTTSStatusPreference(int isTTSOn)
Retrieves the TTS status preference data stored in PlayerPrefs.
Default value is 1.
public int GetTTSStatusPreference()
Takes in a single parameter of type integer named totalExp and stores it in PlayerPrefs.
public void SetExp(int totalExp)
Retrieves the total experience point stored in PlayerPrefs.
Default value is 0.
public int GetExp()
Takes in a single parameter of type integer named exp and adds it to the total experience point stored in PlayerPrefs.
public void AddExp(int exp)
Takes in a single parameter of type integer named exp,fits it into a range and adds it to the total experience point stored in PlayerPrefs.
public void RemoveExp(int exp)
Takes in a single parameter of type integer named level and calculates the total experience point required.
public int CalculateExp(int level)
Takes in a single parameter of type integer named exp and calculates the corresponding level.
public int CalculateLevel(int exp)
Adds the amount of exp set via inspector to the total experience point of the current session.
public void AddSessionExp()
Subtracts the amount of exp set via inspector from the total experience point of the current session.
public void RemoveSessionExp()
Resets the total experience point of the current session to 0.
public void ResetSessionExp()
Deletes all the data stored in PlayerPrefs on sign out.
public void ClearAllPrefs()
Returns the language code corresponding to the language data stored in PlayerPrefs.
e.g. "en" for English, "tr" for Turkish etc.
public async Task<string> GetSystemLanguageCode()
Returns the locale corresponding to the language data stored in PlayerPrefs.
e.g. "en-US" for English, "tr-TR" for Turkish etc.
public async Task<string> GetSelectedLocale()
Returns the list of all available locales corresponding to the language data stored in PlayerPrefs.
e.g. "en-US", "en-GB", "en-AU", "en-CA", "en-CB", "en-IN", "en-NZ" for English, "fr-FR", "fr-CA" for French etc.
public async Task<List<string>> GetSystemLanguageLocales()
Takes in a single parameter of type string named UITextID and returns the translation corresponding to the selected language which is stored in PlayerPrefs.
Use this method for plain texts.
public async Task<string> Translate(string UITextID)
Takes in a first parameter of type string named UITextID and a second parameter of type string named variable. Returns the translation corresponding to the selected language which is stored in PlayerPrefs.
Use this method for texts with variables.
public async Task<string> Translate(string UITextID, string variable)
Takes in a single parameter of type string named orientationMode and forces the screen orientation accordingly.
e.g. "portrait", to force portrait orientation, "landscape" to force landscape orientaiton.
public void ForceOrientation(string orientationMode)
Plays an audio clip according to the music preference data stored in PlayerPrefs.
public void PlayMusic()
Takes in a single parameter of type string named clipName and plays the corresponding audio clip, according to the SFX preference data stored in PlayerPrefs.
public void PlaySFX(string clipName)
Makes the device vibrate for 50ms.
public void VibrateWeak()
Makes the device vibrate for 100ms.
public void VibrateStrong()
Makes the device vibrate three times, 50ms each.
public void VibrateWeakTriple()
Takes in a single parameter of type string named text and passes it to TTS GameObject's Speak() function.
public void Speak(string text)