-
Notifications
You must be signed in to change notification settings - Fork 5
/
PlayServices.cs
62 lines (45 loc) · 1.49 KB
/
PlayServices.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;
public class PlayServices : MonoBehaviour {
// Use this for initialization
void Start () {
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
Social.localUser.Authenticate(succes => { });
}
// Update is called once per frame
void Update () {
}
public static void UnlockAnchievment(string id)
{
Social.ReportProgress(id, 100, success => { });
}
public static void IncrementAchievment(string id, int steps)
{
PlayGamesPlatform.Instance.IncrementAchievement(id, steps, success => { });
}
public static void ShowAchievments()
{
Social.ShowAchievementsUI();
}
public static void PostScore(long score, string leaderBoard)
{
Social.ReportScore(score, leaderBoard, (success => { }));
}
public static void ShowLeaderboard(string leaderboard)
{
PlayGamesPlatform.Instance.ShowLeaderboardUI(leaderboard);
}
public static long GetPlayerScore(string leaderboard)
{
long score = 0;
PlayGamesPlatform.Instance.LoadScores(leaderboard, LeaderboardStart.PlayerCentered, 1, LeaderboardCollection.Public,
LeaderboardTimeSpan.AllTime, (LeaderboardScoreData data) => { score = data.PlayerScore.value; });
return score;
}
}