-
Notifications
You must be signed in to change notification settings - Fork 3
NGIO
File: /NGIO.cs
Static Class
A static wrapper for the NewgroundsIO library.
string: "A"
string: "M"
string: "W"
string: "Y"
string: "D"
string: "checking-local-version"
string: NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS
string: "initialized"
string: "items-preloaded"
string: "local-version-checked"
string: NewgroundsIO.SessionState.LOGIN_CANCELLED
string: NewgroundsIO.SessionState.LOGIN_FAILED
string: NewgroundsIO.SessionState.LOGIN_REQUIRED
string: NewgroundsIO.SessionState.LOGIN_SUCCESSFUL
string: "preloading-items"
string: "ready"
string: NewgroundsIO.SessionState.SERVER_UNAVAILABLE
string: NewgroundsIO.SessionState.SESSION_UNINITIALIZED
string: NewgroundsIO.SessionState.USER_LOGGED_OUT
string: NewgroundsIO.SessionState.WAITING_FOR_SERVER
string: NewgroundsIO.SessionState.WAITING_FOR_USER
Type: (string)
The current version of the Newgrounds.io gateway.
Type: (bool)
Returns true if we currently have a valid session ID.
Type: (bool)
Returns true if we currently have a valid session ID.
Type: (bool)
Will be set to true if this is an out-of-date copy of the game.
Type: (bool)
Will be true if we've called Init().
Type: (bool)
Will be true if we've finished logging in and preloading data.
Type: (NewgroundsIO.objects.ScoreBoard)
Stores the last scoreboard that was posted to.
Type: (string)
Contains the last connection status. Value will be one of the STATUS_XXXXX constants.
Type: (string)
Stores the last DateTime that was loaded from the API.
Type: (DateTime)
The last time a component or queue was executed
Type: (NewgroundsIO.results.ScoreBoard.getScores)
Stores the last scores that were loaded.
Type: (string)
Stores the last event that was logged
Type: (NewgroundsIO.objects.Medal)
Stores the last medal that was unlocked.
Type: (bool)
Stores wether the last server ping succeeded.
Type: (NewgroundsIO.objects.SaveSlot)
Stores the last saveSlot that had data loaded.
Type: (NewgroundsIO.objects.SaveSlot)
Stores the last saveSlot that had data saved.
Type: (NewgroundsIO.objects.Score)
Stores the last score that was posted to.
Type: (int)
Stores the last unix timestamp that was loaded API.
Type: (bool)
Will be set to false if the local copy of the game is being hosted illegally.
Type: (bool)
Will be true if the user opened the login page via OpenLoginPage().
Type: (int)
The user's overall Newgrounds medal score
Type: (Dictionary<int, NewgroundsIO.objects.Medal>)
A dictionary of any preloaded medals, keyed on medal ids
Type: (string)
This is the version number(string) of the newest available copy of the game.
Type: (NewgroundsIO.Core)
A reference to the NewgroundsIO.Core instance created in Init().
Type: (Dictionary<int, NewgroundsIO.objects.SaveSlot>)
A dictionary of any preloaded medals, keyed on the save slot number
Type: (Dictionary<int, NewgroundsIO.objects.ScoreBoard>)
A dictionary of any preloaded medals, keyed on scoreboard ids
Type: (NewgroundsIO.objects.Session)
Contains all information about the current user session.
Type: (NewgroundsIO.objects.Error)
Will be null unless there was an error in our session.
Type: (NewgroundsIO.objects.User)
Contains user information if the user is logged in. Otherwise null.
void CancelLogin()
If the user opened the NG login page, you can call this to cancel the login attempt.
NewgroundsIO.objects.Medal GetMedal(int medalID)
Gets a preloaded Medal object.
Parameters:
-
medalID (int)
The ID of the medal
Returns NewgroundsIO.objects.Medal
NewgroundsIO.objects.SaveSlot GetSaveSlot(int slotID)
Gets a preloaded SaveSlot object. (Use GetSaveSlotData to get actual save file)
Parameters:
-
slotID (int)
The desired slot number
Returns NewgroundsIO.objects.SaveSlot
NewgroundsIO.objects.ScoreBoard GetScoreBoard(int boardID)
Gets a preloaded ScoreBoard object.
Parameters:
-
boardID (int)
The ID of the score board
Returns NewgroundsIO.objects.ScoreBoard
short GetTotalSaveSlots()
Gets the number of non-empty save slots.
Returns short
void Init(string appID, string aesKey, Dictionary<string, object> options = null)
Initializes the NGIO wrapper. You must call this BEFORE using any other methods!
Parameters:
-
appID (string)
The App ID from your Newgrounds Project's "API Tools" page. -
aesKey (string)
The AES-128 encryption key from your Newgrounds Project's "API Tools" page. -
options (Dictionary<string, object>)
A dictionary of option names and values. Options are:- "debugMode" - Set to true to run in debug mode.
- "version" - A string in "X.X.X" format indicating the current version of this game.
- "checkHostLicense" - Set to true to check if the site hosting your game has been blocked.
- "preloadMedals" - Set to true to preload medals (will show if the player has any unlocked, and get their current medal score).
- "preloadeScoreBoards" - Set to true to preload Score Board information.
- "preloadeSaveSlots" - Set to true to preload Save Slot information.
- "autoLogNewView" - Set to true to automatcally log a new view to your stats.
void LoadAuthorUrl()
Loads "Your Website URL", as defined on your App Settings page, in a new browser tab.
void LoadMoreGames()
Loads the Games page on Newgrounds in a new browser tab.
void LoadNewgrounds()
Loads the Newgrounds frontpage in a new browser tab.
void LoadOfficialUrl()
Loads our "Official Version URL", as defined on your App Settings page, in a new browser tab.
void LoadReferral(string referralName)
Parameters:
- referralName (string)
void OpenLoginPage()
Opens the Newgrounds login page in a new browser tab.
void SkipLogin()
Call this if you want to skip logging the user in.
IEnumerator GetConnectionStatus(Action handler)
Parameters:
- handler (Action)
IEnumerator LogOut()
Logs the current use out of the game (locally and on the server) and resets the connection status.
IEnumerator KeepSessionAlive()
IEnumerator GetSaveSlotData(int slotID, Action callback)
Loads the actual save file from a save slot, and passes the string result to a callback function.
Parameters:
-
slotID (int)
The slot number to load from -
callback (Action)
A function to run when the file has been loaded
IEnumerator SetSaveSlotData(int slotID, string data, Action<NewgroundsIO.objects.SaveSlot> callback = null)
Loads the actual save file from a save slot and returns the save slot to an optional callback function when complete.
Parameters:
-
slotID (int)
The slot number to save to. -
data (string)
The (serialized) data you want to save. -
callback (Action<NewgroundsIO.objects.SaveSlot>)
A function to run when the file finished saving.
IEnumerator LogEvent(string eventName, Action callback = null)
Logs a custom event and returns the eventName to an optional callback function when complete.
Parameters:
-
eventName (string)
The name of the event to log. -
callback (Action)
A function to run when the event has logged.
IEnumerator GetDateTime(Action<string, int> callback = null)
Loads the current DateTime from the server and returns it to an optional callback function.
Parameters:
-
callback (Action<string, int>)
A function to run when the medal has unlocked.
IEnumerator UnlockMedal(int medalID, Action<NewgroundsIO.objects.Medal> callback = null)
Attempts to unlock a medal and returns the medal to an optional callback function when complete.
Parameters:
-
medalID (int)
The id of the medal you are unlocking. -
callback (Action<NewgroundsIO.objects.Medal>)
A function to run when the medal has unlocked.
IEnumerator PostScore(int boardID, int value, string tag = null, Action<NewgroundsIO.objects.ScoreBoard, NewgroundsIO.objects.Score> callback = null)
Posts a score and returns the score and scoreboard to an optional callback function when complete.
Parameters:
-
boardID (int)
The id of the scoreboard you are posting to. -
value (int)
The integer value of your score. -
tag (string)
An optional tag to attach to the score (use null for no tag). -
callback (Action<NewgroundsIO.objects.ScoreBoard, NewgroundsIO.objects.Score>)
A function to run when the score has posted.
IEnumerator GetScores(int boardID, string period = "D", string tag = null, bool social = false, Action<NewgroundsIO.objects.ScoreBoard, List<NewgroundsIO.objects.Score>, string, string, bool> callback = null)
Gets the best scores for a board and returns the board, score list, period, tag and social bool to an optional callback.
Parameters:
-
boardID (int)
The id of the scoreboard you loading from. -
period (string)
The time period to get scores from. Will match one of the PERIOD_XXXX constants. -
tag (string)
An optional tag to filter results by (use null for no tag). -
social (bool)
Set to true to only get scores from the user's friends. -
callback (Action<NewgroundsIO.objects.ScoreBoard, List<NewgroundsIO.objects.Score>, string, string, bool>)
A function to run when the scores have been loaded.