コード例 #1
0
ファイル: GamerScores.cs プロジェクト: StudioJD/unity-sdk
 /// <summary>Post a score.</summary>
 /// <returns>Promise resolved when the operation has completed. The attached value contains the new rank of the
 ///     player as well as whether the score was saved.</returns>
 /// <param name="score">The score (numeric value) to record.</param>
 /// <param name="board">The name of the board to post the score to. You may have as many boards as you like for your
 ///     game, and scores are scoped between them.</param>
 /// <param name="order">The order for this board. As board are not configured on the server, any client can create a
 ///     board dynamically. This parameter serves as as a description for the board and is used only upon
 ///     creation (that is, the first player posting to the named board).</param>
 /// <param name="scoreInfo">An optional string used to describe the score made by the user.</param>
 /// <param name="forceSave">When set to true, the score is saved even if its value is less than the past best score
 ///     for this player.</param>
 public Promise<PostedGameScore> Post(long score, string board, ScoreOrder order, string scoreInfo = null, bool forceSave = false)
 {
     UrlBuilder url = new UrlBuilder("/v2.6/gamer/scores").Path(domain).Path(board);
     switch (order) {
         case ScoreOrder.HighToLow: url.QueryParam("order", "hightolow"); break;
         case ScoreOrder.LowToHigh: url.QueryParam("order", "lowtohigh"); break;
     }
     url.QueryParam("mayvary", forceSave);
     HttpRequest req = Gamer.MakeHttpRequest(url);
     req.BodyJson = Bundle.CreateObject("score", score, "info", scoreInfo);
     return Common.RunInTask<PostedGameScore>(req, (response, task) => {
         task.PostResult(new PostedGameScore(response.BodyJson));
     });
 }