Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
975 B

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