Inheritance: PlayFabRequestCommon
コード例 #1
0
		/// <summary>
		/// Adds the specified items to the specified character's inventory
		/// </summary>
		public static void GrantItemsToCharacter(GrantItemsToCharacterRequest request, GrantItemsToCharacterCallback resultCallback, ErrorCallback errorCallback)
		{
			if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");

			string serializedJSON = JsonConvert.SerializeObject(request, Util.JsonFormatting, Util.JsonSettings);
			Action<string,string> callback = delegate(string responseStr, string errorStr)
			{
				GrantItemsToCharacterResult result = null;
				PlayFabError error = null;
				ResultContainer<GrantItemsToCharacterResult>.HandleResults(responseStr, errorStr, out result, out error);
				if(error != null && errorCallback != null)
				{
					errorCallback(error);
				}
				if(result != null)
				{
					
					if(resultCallback != null)
					{
						resultCallback(result);
					}
				}
			};
			PlayFabHTTP.Post(PlayFabSettings.GetURL()+"/Server/GrantItemsToCharacter", serializedJSON, "X-SecretKey", PlayFabSettings.DeveloperSecretKey, callback);
		}
コード例 #2
0
ファイル: PfItemBasics.cs プロジェクト: noxplague/UnitySDK
 private Action GrantCharacterItem(string itemId)
 {
     Action output = () =>
     {
         var grantRequest = new ServerModels.GrantItemsToCharacterRequest();
         grantRequest.PlayFabId = pfLoginExample.playFabId;
         grantRequest.CharacterId = characterId;
         grantRequest.ItemIds = new List<string>() { itemId };
         PlayFabServerAPI.GrantItemsToCharacter(grantRequest, GrantCharacterItemCallback, SharedFailCallback("GrantItemsToCharacter"));
     };
     return output;
 }
コード例 #3
0
		/// <summary>
		/// Adds the specified items to the specified character's inventory
		/// </summary>
        public static async Task<PlayFabResult<GrantItemsToCharacterResult>> GrantItemsToCharacterAsync(GrantItemsToCharacterRequest request)
        {
            if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");

            object httpResult = await PlayFabHTTP.DoPost(PlayFabSettings.GetURL() + "/Server/GrantItemsToCharacter", request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
            if(httpResult is PlayFabError)
            {
                PlayFabError error = (PlayFabError)httpResult;
                if (PlayFabSettings.GlobalErrorHandler != null)
                    PlayFabSettings.GlobalErrorHandler(error);
                return new PlayFabResult<GrantItemsToCharacterResult>
                {
                    Error = error,
                };
            }
            string resultRawJson = (string)httpResult;

            var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings);
            var resultData = serializer.Deserialize<PlayFabJsonSuccess<GrantItemsToCharacterResult>>(new JsonTextReader(new StringReader(resultRawJson)));
			
			GrantItemsToCharacterResult result = resultData.data;
			
			
            return new PlayFabResult<GrantItemsToCharacterResult>
                {
                    Result = result
                };
        }