123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- using System;
- using System.Runtime.InteropServices;
- using Pico.Platform.Models;
- using UnityEngine;
- namespace Pico.Platform
- {
-
- public static class LeaderboardService
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static Task<LeaderboardList> Get(string leaderboardName)
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- return new Task<LeaderboardList>(CLIB.ppf_Leaderboard_Get(leaderboardName));
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static Task<LeaderboardEntryList> GetEntries(string leaderboardName, int pageSize, int pageIdx, LeaderboardFilterType filter, LeaderboardStartAt startAt)
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- return new Task<LeaderboardEntryList>(CLIB.ppf_Leaderboard_GetEntries(leaderboardName, pageSize, pageIdx, filter, startAt));
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static Task<LeaderboardEntryList> GetEntriesAfterRank(string leaderboardName, int pageSize, int pageIdx,
- ulong afterRank)
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- return new Task<LeaderboardEntryList>(
- CLIB.ppf_Leaderboard_GetEntriesAfterRank(leaderboardName, pageSize, pageIdx, afterRank));
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static Task<LeaderboardEntryList> GetEntriesByIds(string leaderboardName, int pageSize, int pageIdx,
- LeaderboardStartAt startAt, string[] userIDs)
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- return new Task<LeaderboardEntryList>(CLIB.ppf_Leaderboard_GetEntriesByIds(leaderboardName,
- pageSize, pageIdx, startAt, userIDs));
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static Task<bool> WriteEntry(string leaderboardName, long score, byte[] extraData = null,
- bool forceUpdate = false)
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- GCHandle hobj = GCHandle.Alloc(extraData, GCHandleType.Pinned);
- IntPtr pobj = hobj.AddrOfPinnedObject();
- var result = new Task<bool>(CLIB.ppf_Leaderboard_WriteEntry(leaderboardName, score, pobj,
- (uint) (extraData != null ? extraData.Length : 0), forceUpdate));
- if (hobj.IsAllocated)
- hobj.Free();
- return result;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static Task<bool> WriteEntryWithSupplementaryMetric(string leaderboardName, long score,
- long supplementaryMetric, byte[] extraData = null, bool forceUpdate = false)
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- GCHandle hobj = GCHandle.Alloc(extraData, GCHandleType.Pinned);
- IntPtr pobj = hobj.AddrOfPinnedObject();
- var result = new Task<bool>(CLIB.ppf_Leaderboard_WriteEntryWithSupplementaryMetric(leaderboardName, score,
- supplementaryMetric, pobj, (uint) (extraData != null ? extraData.Length : 0), forceUpdate));
- if (hobj.IsAllocated)
- hobj.Free();
- return result;
- }
- }
- }
|