/// <summary>
        /// Post the players score to the given social leaderboard.
        /// Pass leaderboard config data to dynamically create if necessary.
        /// You can optionally send a user-defined json string of data
        /// with the posted score. This string could include information
        /// relevant to the posted score.
        /// </summary>
        /// <remarks>
        /// Service Name - SocialLeaderboard
        /// Service Operation - PostScoreDynamic
        /// </remarks>
        /// <param name="in_leaderboardId">
        /// The leaderboard to post to
        /// </param>
        /// <param name="in_score">
        /// The score to post
        /// </param>
        /// <param name="in_data">
        /// Optional user-defined data to post with the score
        /// </param>
        /// <param name="in_leaderboardType">
        /// leaderboard type
        /// </param>
        /// <param name="in_rotationType">
        /// Type of rotation
        /// </param>
        /// <param name="in_rotationStart">
        /// Date to start rotation calculations (Date is converted to "dd-mm-yyyy" format)
        /// </param>
        /// <param name="in_retainedCount">
        /// Hpw many rotations to keep
        /// </param>
        /// <param name="in_success">
        /// The success callback.
        /// </param>
        /// <param name="in_failure">
        /// The failure callback.
        /// </param>
        /// <param name="in_cbObject">
        /// The user object sent to the callback.
        /// </param>
        /// <returns> The JSON returned in the callback is as follows:
        /// {
        ///   "status":200,
        ///   "data":{
        ///   }
        /// }
        /// </returns>
        public void PostScoreToDynamicLeaderboard(
            string in_leaderboardId,
            long in_score,
            string in_jsonData,
            SocialLeaderboardType in_leaderboardType,
            RotationType in_rotationType,
            DateTime in_rotationStart,
            int in_retainedCount,
            SuccessCallback in_success = null,
            FailureCallback in_failure = null,
            object in_cbObject         = null)
        {
            Dictionary <string, object> data = new Dictionary <string, object>();

            data[OperationParam.SocialLeaderboardServiceLeaderboardId.Value] = in_leaderboardId;
            data[OperationParam.SocialLeaderboardServiceScore.Value]         = in_score;
            if (Util.IsOptionalParameterValid(in_jsonData))
            {
                Dictionary <string, object> customData = JsonReader.Deserialize <Dictionary <string, object> >(in_jsonData);
                data[OperationParam.SocialLeaderboardServiceData.Value] = customData;
            }
            data[OperationParam.SocialLeaderboardServiceLeaderboardType.Value] = in_leaderboardType.ToString();
            data[OperationParam.SocialLeaderboardServiceRotationType.Value]    = in_rotationType.ToString();
            data[OperationParam.SocialLeaderboardServiceRotationStart.Value]   = in_rotationStart.ToString("d-MM-yyyy");
            data[OperationParam.SocialLeaderboardServiceRetainedCount.Value]   = in_retainedCount;

            ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject);
            ServerCall     sc       = new ServerCall(ServiceName.SocialLeaderboard, ServiceOperation.PostScoreDynamic, data, callback);

            m_brainCloudClientRef.SendRequest(sc);
        }
Esempio n. 2
0
        /// <summary>
        /// Post the players score to the given social leaderboard with a rotation type of DAYS.
        /// Pass leaderboard config data to dynamically create if necessary.
        /// You can optionally send a user-defined json string of data
        /// with the posted score. This string could include information
        /// relevant to the posted score.
        /// </summary>
        /// <remarks>
        /// Service Name - leaderboard
        /// Service Operation - PostScoreDynamic
        /// </remarks>
        /// <param name="leaderboardId">
        /// The leaderboard to post to
        /// </param>
        /// <param name="score">
        /// The score to post
        /// </param>
        /// <param name="data">
        /// Optional user-defined data to post with the score
        /// </param>
        /// <param name="leaderboardType">
        /// leaderboard type
        /// </param>
        /// <param name="rotationReset">
        /// Date to reset the leaderboard UTC
        /// </param>
        /// <param name="retainedCount">
        /// How many rotations to keep
        /// </param>
        /// <param name="numDaysToRotate">
        /// How many days between each rotation
        /// </param>
        /// <param name="success">
        /// The success callback.
        /// </param>
        /// <param name="failure">
        /// The failure callback.
        /// </param>
        /// <param name="cbObject">
        /// The user object sent to the callback.
        /// </param>
        public void PostScoreToDynamicLeaderboardDays(
            string leaderboardId,
            long score,
            string jsonData,
            SocialLeaderboardType leaderboardType,
            DateTime?rotationReset,
            int retainedCount,
            int numDaysToRotate,
            SuccessCallback success = null,
            FailureCallback failure = null,
            object cbObject         = null)
        {
            var data = new Dictionary <string, object>();

            data[OperationParam.SocialLeaderboardServiceLeaderboardId.Value] = leaderboardId;
            data[OperationParam.SocialLeaderboardServiceScore.Value]         = score;
            if (Util.IsOptionalParameterValid(jsonData))
            {
                var customData = JsonReader.Deserialize <Dictionary <string, object> >(jsonData);
                data[OperationParam.SocialLeaderboardServiceData.Value] = customData;
            }
            data[OperationParam.SocialLeaderboardServiceLeaderboardType.Value] = leaderboardType.ToString();
            data[OperationParam.SocialLeaderboardServiceRotationType.Value]    = "DAYS";

            if (rotationReset.HasValue)
            {
                data[OperationParam.SocialLeaderboardServiceRotationResetTime.Value] = Util.DateTimeToUnixTimestamp(rotationReset.Value);
            }

            data[OperationParam.SocialLeaderboardServiceRetainedCount.Value] = retainedCount;
            data[OperationParam.NumDaysToRotate.Value] = numDaysToRotate;

            var callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject);
            var sc       = new ServerCall(ServiceName.Leaderboard, ServiceOperation.PostScoreDynamic, data, callback);

            _client.SendRequest(sc);
        }
        /// <summary>
        /// Post the players score to the given social leaderboard.
        /// Pass leaderboard config data to dynamically create if necessary.
        /// You can optionally send a user-defined json string of data
        /// with the posted score. This string could include information
        /// relevant to the posted score.
        /// </summary>
        /// <remarks>
        /// Service Name - SocialLeaderboard
        /// Service Operation - PostScoreDynamic
        /// </remarks>
        /// <param name="in_leaderboardId">
        /// The leaderboard to post to
        /// </param>
        /// <param name="in_score">
        /// The score to post
        /// </param>
        /// <param name="in_data">
        /// Optional user-defined data to post with the score
        /// </param>
        /// <param name="in_leaderboardType">
        /// leaderboard type
        /// </param>
        /// <param name="in_rotationType">
        /// Type of rotation
        /// </param>
        /// <param name="in_rotationReset">
        /// Date to reset the leaderboard
        /// </param>
        /// <param name="in_retainedCount">
        /// Hpw many rotations to keep
        /// </param>
        /// <param name="in_success">
        /// The success callback.
        /// </param>
        /// <param name="in_failure">
        /// The failure callback.
        /// </param>
        /// <param name="in_cbObject">
        /// The user object sent to the callback.
        /// </param>
        /// <returns> The JSON returned in the callback is as follows:
        /// {
        ///   "status":200,
        ///   "data":{
        ///   }
        /// }
        /// </returns>
        public void PostScoreToDynamicLeaderboard(
            string in_leaderboardId,
            long in_score,
            string in_jsonData,
            SocialLeaderboardType in_leaderboardType,
            RotationType in_rotationType,
            DateTime? in_rotationReset,
            int in_retainedCount,
            SuccessCallback in_success = null,
            FailureCallback in_failure = null,
            object in_cbObject = null)
        {
            Dictionary<string, object> data = new Dictionary<string, object>();
            data[OperationParam.SocialLeaderboardServiceLeaderboardId.Value] = in_leaderboardId;
            data[OperationParam.SocialLeaderboardServiceScore.Value] = in_score;
            if (Util.IsOptionalParameterValid(in_jsonData))
            {
                Dictionary<string, object> customData = JsonReader.Deserialize<Dictionary<string, object>>(in_jsonData);
                data[OperationParam.SocialLeaderboardServiceData.Value] = customData;
            }
            data[OperationParam.SocialLeaderboardServiceLeaderboardType.Value] = in_leaderboardType.ToString();
            data[OperationParam.SocialLeaderboardServiceRotationType.Value] = in_rotationType.ToString();

            if (in_rotationReset.HasValue)
                data[OperationParam.SocialLeaderboardServiceRotationReset.Value] = in_rotationReset.Value.ToString("d-MM-yyyy HH:mm");

            data[OperationParam.SocialLeaderboardServiceRetainedCount.Value] = in_retainedCount;

            ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject);
            ServerCall sc = new ServerCall(ServiceName.SocialLeaderboard, ServiceOperation.PostScoreDynamic, data, callback);
            m_brainCloudClientRef.SendRequest(sc);
        }