BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / Oculus / Platform / Samples / VrHoops / Scripts / AchievementsManager.cs

AchievementsManager.cs

Project Import
timfa Tim Falken · pushed by timfa · 6 years ago
b77834a1 History
AchievementsManager.cs 975 B Download Raw
1namespace Oculus.Platform.Samples.VrHoops
2{
3 using UnityEngine;
4 using System.Collections;
5 using Oculus.Platform;
6 using Oculus.Platform.Models;
7
8 public class AchievementsManager
9 {
10 // API NAME defined on the dashboard for the achievement
11 private const string LIKES_TO_WIN = "LIKES_TO_WIN";
12
13 // true if the local user hit the achievement Count setup on the dashboard
14 private bool m_likesToWinUnlocked;
15
16 public bool LikesToWin
17 {
18 get { return m_likesToWinUnlocked; }
19 }
20
21 public void CheckForAchievmentUpdates()
22 {
23 Achievements.GetProgressByName(new string[]{ LIKES_TO_WIN }).OnComplete(
24 (Message<AchievementProgressList> msg) =>
25 {
26 foreach (var achievement in msg.Data)
27 {
28 if (achievement.Name == LIKES_TO_WIN)
29 {
30 m_likesToWinUnlocked = achievement.IsUnlocked;
31 }
32 }
33 }
34 );
35 }
36
37 public void RecordWinForLocalUser()
38 {
39 Achievements.AddCount(LIKES_TO_WIN, 1);
40 CheckForAchievmentUpdates();
41 }
42 }
43}