LeaderboardScoreData.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. // <copyright file="LeaderboardScoreData.cs" company="Google Inc.">
  2. // Copyright (C) 2015 Google Inc. All Rights Reserved.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. // </copyright>
  16. #if (UNITY_ANDROID || (UNITY_IPHONE && !NO_GPGS))
  17. namespace GooglePlayGames.BasicApi
  18. {
  19. using System.Collections.Generic;
  20. using UnityEngine.SocialPlatforms;
  21. /// <summary>
  22. /// Leaderboard score data. This is the callback data
  23. /// when loading leaderboard scores. There are several SDK
  24. /// API calls needed to be made to collect all the required data,
  25. /// so this class is used to simplify the response.
  26. /// </summary>
  27. public class LeaderboardScoreData
  28. {
  29. private string mId;
  30. private ResponseStatus mStatus;
  31. private ulong mApproxCount;
  32. private string mTitle;
  33. private IScore mPlayerScore;
  34. private ScorePageToken mPrevPage;
  35. private ScorePageToken mNextPage;
  36. private List<PlayGamesScore> mScores = new List<PlayGamesScore>();
  37. internal LeaderboardScoreData(string leaderboardId)
  38. {
  39. mId = leaderboardId;
  40. }
  41. internal LeaderboardScoreData(string leaderboardId, ResponseStatus status)
  42. {
  43. mId = leaderboardId;
  44. mStatus = status;
  45. }
  46. public bool Valid
  47. {
  48. get
  49. {
  50. return mStatus == ResponseStatus.Success ||
  51. mStatus == ResponseStatus.SuccessWithStale;
  52. }
  53. }
  54. public ResponseStatus Status
  55. {
  56. get
  57. {
  58. return mStatus;
  59. }
  60. internal set
  61. {
  62. mStatus = value;
  63. }
  64. }
  65. public ulong ApproximateCount
  66. {
  67. get
  68. {
  69. return mApproxCount;
  70. }
  71. internal set
  72. {
  73. mApproxCount = value;
  74. }
  75. }
  76. public string Title
  77. {
  78. get
  79. {
  80. return mTitle;
  81. }
  82. internal set
  83. {
  84. mTitle = value;
  85. }
  86. }
  87. public string Id
  88. {
  89. get
  90. {
  91. return mId;
  92. }
  93. internal set
  94. {
  95. mId = value;
  96. }
  97. }
  98. public IScore PlayerScore
  99. {
  100. get
  101. {
  102. return mPlayerScore;
  103. }
  104. internal set
  105. {
  106. mPlayerScore = value;
  107. }
  108. }
  109. public IScore[] Scores
  110. {
  111. get
  112. {
  113. return mScores.ToArray();
  114. }
  115. }
  116. internal int AddScore(PlayGamesScore score)
  117. {
  118. mScores.Add(score);
  119. return mScores.Count;
  120. }
  121. public ScorePageToken PrevPageToken
  122. {
  123. get
  124. {
  125. return mPrevPage;
  126. }
  127. internal set
  128. {
  129. mPrevPage = value;
  130. }
  131. }
  132. public ScorePageToken NextPageToken
  133. {
  134. get
  135. {
  136. return mNextPage;
  137. }
  138. internal set
  139. {
  140. mNextPage = value;
  141. }
  142. }
  143. public override string ToString()
  144. {
  145. return string.Format("[LeaderboardScoreData: mId={0}, " +
  146. " mStatus={1}, mApproxCount={2}, mTitle={3}]",
  147. mId, mStatus, mApproxCount, mTitle);
  148. }
  149. }
  150. }
  151. #endif