public static void GetUserVc(string playFabId) { var getRequest = new ServerModels.GetUserInventoryRequest(); getRequest.PlayFabId = playFabId; PlayFabServerAPI.GetUserInventory(getRequest, GetUserVcCallback, PfSharedControllerEx.FailCallback("GetUserInventory")); }
public static void PurchaseUserItem(string itemId, uint qty) { if (qty == 1) { string vcKey; int cost; if (PfSharedModelEx.globalClientUser.GetClientItemPrice(null, itemId, out vcKey, out cost)) { var purchaseRequest = new PurchaseItemRequest(); purchaseRequest.ItemId = itemId; purchaseRequest.VirtualCurrency = vcKey; purchaseRequest.Price = cost; PlayFabClientAPI.PurchaseItem(purchaseRequest, PurchaseUserItemCallback, PfSharedControllerEx.FailCallback("PurchaseItem")); } else { Debug.LogWarning("You cannot afford this item"); } } else { var multiRequest = new StartPurchaseRequest(); multiRequest.Items = new List <ItemPurchaseRequest>(); multiRequest.Items.Add(new ItemPurchaseRequest { ItemId = itemId, Quantity = qty }); PlayFabClientAPI.StartPurchase(multiRequest, StartPurchaseCallback, PfSharedControllerEx.FailCallback("StartPurchase")); } }
public static void GetPublisherData() { var getRequest = new ClientModels.GetPublisherDataRequest(); getRequest.Keys = PfSharedModelEx.defaultPublisherKeys; // TODO: Temporary - keys are mandatory, and we don't know what keys already exist. PlayFabClientAPI.GetPublisherData(getRequest, GetPublisherDataCallback, PfSharedControllerEx.FailCallback("GetPublisherData")); }
private static void OnUserLogin(string playFabId, string characterId, PfSharedControllerEx.Api eventSourceApi, bool requiresFullRefresh) { var catalogRequest = new ServerModels.GetCatalogItemsRequest(); PlayFabServerAPI.GetCatalogItems(catalogRequest, GetCatalogCallback, PfSharedControllerEx.FailCallback("GetCatalogItems")); GetUserInventory(playFabId); }
public void GetInventory() { var getRequest = new GetCharacterInventoryRequest(); getRequest.CharacterId = characterId; PlayFabClientAPI.GetCharacterInventory(getRequest, GetInventoryCallback, PfSharedControllerEx.FailCallback("GetCharacterInventory")); }
public static void GetTitleData() { var getRequest = new ClientModels.GetTitleDataRequest(); // getRequest.Keys = new System.Collections.Generic.List<string>() { filterKey }; PlayFabClientAPI.GetTitleData(getRequest, GetTitleDataCallback, PfSharedControllerEx.FailCallback("GetTitleData")); }
public static void CancelTrade(string tradeId) { var cancelRequest = new ClientModels.CancelTradeRequest(); cancelRequest.TradeId = tradeId; PlayFabClientAPI.CancelTrade(cancelRequest, CancelTradeCallback, PfSharedControllerEx.FailCallback("CancelTrade")); }
public static void GetUserReadOnlyData() { var getRequest = new ClientModels.GetUserDataRequest(); getRequest.PlayFabId = PfSharedModelEx.globalClientUser.playFabId; // You may ask for yourself specifically, any other playFabId you're aware of, or null to default to yourself // getRequest.Keys = new System.Collections.Generic.List<string>() { filterKey }; PlayFabClientAPI.GetUserReadOnlyData(getRequest, GetUserDataCallback, PfSharedControllerEx.FailCallback("GetUserReadOnlyData")); }
public void GetInventory() { var getRequest = new ServerModels.GetCharacterInventoryRequest(); getRequest.PlayFabId = playFabId; getRequest.CharacterId = characterId; PlayFabServerAPI.GetCharacterInventory(getRequest, GetInventoryCallback, PfSharedControllerEx.FailCallback("GetCharacterInventory")); }
public static void GetUserStatistics(string playFabId) { var request = new GetUserStatisticsRequest(); request.PlayFabId = playFabId; PlayFabServerAPI.GetUserStatistics(request, GetUserStatisticsCallback, PfSharedControllerEx.FailCallback("GetUserStatistics")); }
public static void ConsumeUserItem(string itemInstanceId) { var consumeRequest = new ConsumeItemRequest(); consumeRequest.ConsumeCount = 1; consumeRequest.CharacterId = null; // To indicate user inventory consumeRequest.ItemInstanceId = itemInstanceId; PlayFabClientAPI.ConsumeItem(consumeRequest, ConsumeItemCallback, PfSharedControllerEx.FailCallback("ConsumeItem")); }
public void ConsumeItem(string itemInstanceId) { var consumeRequest = new ConsumeItemRequest(); consumeRequest.ConsumeCount = 1; consumeRequest.CharacterId = characterId; consumeRequest.ItemInstanceId = itemInstanceId; PlayFabClientAPI.ConsumeItem(consumeRequest, ConsumeItemCallback, PfSharedControllerEx.FailCallback("ConsumeItem")); }
public void RevokeItem(string itemInstanceId) { var revokeRequest = new AdminModels.RevokeInventoryItemRequest(); revokeRequest.PlayFabId = playFabId; revokeRequest.CharacterId = characterId; revokeRequest.ItemInstanceId = itemInstanceId; PlayFabAdminAPI.RevokeInventoryItem(revokeRequest, RevokeItemCallback, PfSharedControllerEx.FailCallback("RevokeInventoryItem")); }
public static void AcceptTrade(string tradeId, string offeringPlayerId, List <string> acceptedInventoryInstanceIds) { var acceptRequest = new ClientModels.AcceptTradeRequest(); acceptRequest.TradeId = tradeId; acceptRequest.OfferingPlayerId = offeringPlayerId; acceptRequest.AcceptedInventoryInstanceIds = acceptedInventoryInstanceIds; PlayFabClientAPI.AcceptTrade(acceptRequest, AcceptTradeCallback, PfSharedControllerEx.FailCallback("CancelTrade")); }
public static void GetUserData(string playFabId) { var getRequest = new ServerModels.GetUserDataRequest(); getRequest.PlayFabId = playFabId; // getRequest.Keys = new System.Collections.Generic.List<string>() { filterKey }; PlayFabServerAPI.GetUserData(getRequest, GetUserDataCallback, PfSharedControllerEx.FailCallback("GetUserData")); }
public static void LoginWithEmail(string titleId, string devSecretKey, string email, string password) { PlayFabSettings.TitleId = titleId; PlayFabSettings.DeveloperSecretKey = devSecretKey; var loginRequest = new LoginWithEmailAddressRequest(); loginRequest.Email = email; loginRequest.Password = password; PlayFabClientAPI.LoginWithEmailAddress(loginRequest, LoginCallBack, PfSharedControllerEx.FailCallback("LoginWithEmailAddress")); }
public static void GrantUserItem(string playFabId, string itemId) { var grantRequest = new ServerModels.GrantItemsToUserRequest(); grantRequest.PlayFabId = playFabId; grantRequest.ItemIds = new List <string>() { itemId }; PlayFabServerAPI.GrantItemsToUser(grantRequest, GrantUserItemCallback, PfSharedControllerEx.FailCallback("GrantItemsToUser")); }
public static void UpdateUserData(string userDataKey, string userDataValue) { if (string.IsNullOrEmpty(userDataValue)) { userDataValue = null; // Ensure that this field is removed } var updateRequest = new ClientModels.UpdateUserDataRequest(); updateRequest.Data = new Dictionary <string, string>(); updateRequest.Data[userDataKey] = userDataValue; // Multiple keys accepted, unlike this example, best-use-case modifies all keys at once when possible. PlayFabClientAPI.UpdateUserData(updateRequest, UpdateUserDataCallback, PfSharedControllerEx.FailCallback("UpdateUserData")); }
public static void SetTitleData(string titleDataKey, string titleDataValue) { if (string.IsNullOrEmpty(titleDataValue)) { titleDataValue = null; // Ensure that this field is removed } // This api-call updates one titleData key at a time. // You can remove a key by setting the value to null. var updateRequest = new ServerModels.SetTitleDataRequest(); updateRequest.Key = titleDataKey; updateRequest.Value = titleDataValue; PlayFabServerAPI.SetTitleData(updateRequest, SetTitleDataCallback, PfSharedControllerEx.FailCallback("SetTitleData")); }
public void PurchaseCharacterItem(string itemId) { string vcKey; int cost; if (PfSharedModelEx.globalClientUser.GetClientItemPrice(null, itemId, out vcKey, out cost)) { var purchaseRequest = new PurchaseItemRequest(); purchaseRequest.CharacterId = characterId; purchaseRequest.ItemId = itemId; purchaseRequest.VirtualCurrency = vcKey; purchaseRequest.Price = cost; PlayFabClientAPI.PurchaseItem(purchaseRequest, PurchaseItemCallback, PfSharedControllerEx.FailCallback("PurchaseItem")); } else { Debug.LogWarning("You cannot afford this item"); } }
public static void OpenTrade(params string[] offeredInventoryInstanceIds) { var openRequest = new ClientModels.OpenTradeRequest(); // Optional field: null is anybody, alternately if specified, this is a targeted trade request // In this example, we restrict the trade to ourselves (because I don't have multiple clients for this example) // A normal trade process would use all the same steps, but would interact between multliple clients openRequest.AllowedPlayerIds = new List <string>() { PfSharedModelEx.globalClientUser.playFabId }; // Offering the items you have openRequest.OfferedInventoryInstanceIds = new List <string>(); openRequest.OfferedInventoryInstanceIds.AddRange(offeredInventoryInstanceIds); // Listing the items you want openRequest.RequestedCatalogItemIds = new List <string>() { PfSharedModelEx.swillItemId }; PlayFabClientAPI.OpenTrade(openRequest, OpenTradeCallback, PfSharedControllerEx.FailCallback("OpenTrade")); }
public static void AddUserVirtualCurrency(string playFabId, string vcKey, int amt) { ServerModels.AddUserVirtualCurrencyRequest addRequest = new ServerModels.AddUserVirtualCurrencyRequest(); addRequest.PlayFabId = playFabId; addRequest.VirtualCurrency = vcKey; addRequest.Amount = amt; PlayFabServerAPI.AddUserVirtualCurrency(addRequest, ModifyUserVcCallback, PfSharedControllerEx.FailCallback("AddUserVirtualCurrency")); }
public static void GetUserStatistics() { var request = new GetUserStatisticsRequest(); PlayFabClientAPI.GetUserStatistics(request, GetUserStatisticsCallback, PfSharedControllerEx.FailCallback("GetUserStatistics")); }
public void MoveToUser(string itemInstanceId) { var moveRequest = new ServerModels.MoveItemToUserFromCharacterRequest(); moveRequest.PlayFabId = playFabId; moveRequest.CharacterId = characterId; moveRequest.ItemInstanceId = itemInstanceId; PlayFabServerAPI.MoveItemToUserFromCharacter(moveRequest, MoveToUserCallback, PfSharedControllerEx.FailCallback("MoveItemToUserFromCharacter")); }
public static void SubtractCharacterVirtualCurrency(string playFabId, string characterId, string vcKey, int amt) { ServerModels.SubtractCharacterVirtualCurrencyRequest addRequest = new ServerModels.SubtractCharacterVirtualCurrencyRequest(); addRequest.PlayFabId = playFabId; addRequest.CharacterId = characterId; addRequest.VirtualCurrency = vcKey; addRequest.Amount = amt; PlayFabServerAPI.SubtractCharacterVirtualCurrency(addRequest, SubtractCharVcCallback, PfSharedControllerEx.FailCallback("SubtractCharacterVirtualCurrency")); }
public static void GetUserVc() { var getRequest = new ClientModels.GetUserInventoryRequest(); PlayFabClientAPI.GetUserInventory(getRequest, GetUserVcCallback, PfSharedControllerEx.FailCallback("GetUserInventory")); }
public static void GetCharacterVc(string characterId) { var getRequest = new ClientModels.GetCharacterInventoryRequest(); getRequest.CharacterId = characterId; PlayFabClientAPI.GetCharacterInventory(getRequest, GetCharacterVcCallback, PfSharedControllerEx.FailCallback("GetCharacterInventory")); }
public static void AddUserVirtualCurrency(string vcKey, int amt) { ClientModels.AddUserVirtualCurrencyRequest addRequest = new ClientModels.AddUserVirtualCurrencyRequest(); addRequest.VirtualCurrency = vcKey; addRequest.Amount = amt; PlayFabClientAPI.AddUserVirtualCurrency(addRequest, ModifyUserVcCallback, PfSharedControllerEx.FailCallback("AddUserVirtualCurrency")); }
public static void UpdateUserStatistics(string key, int value) { var request = new UpdateUserStatisticsRequest(); request.UserStatistics = new Dictionary <string, int>(); request.UserStatistics[key] = value; PlayFabClientAPI.UpdateUserStatistics(request, UpdateUserStatisticsCallback, PfSharedControllerEx.FailCallback("UpdateUserStatistics")); }
public static void LoginCallBack(LoginResult loginResult) { // CLIENT PfSharedModelEx.globalClientUser.playFabId = loginResult.PlayFabId; PfSharedControllerEx.PostEventMessage(PfSharedControllerEx.EventType.OnUserLogin, loginResult.PlayFabId, null, PfSharedControllerEx.Api.Client, false); var clientRequest = new ListUsersCharactersRequest(); PlayFabClientAPI.GetAllUsersCharacters(clientRequest, ClientCharCallBack, PfSharedControllerEx.FailCallback("C_GetAllUsersCharacters")); // SERVER PfSharedModelEx.serverUsers.Add(loginResult.PlayFabId, PfSharedModelEx.globalClientUser); // Ensure that they share the same object reference var serverRequest = new ServerModels.ListUsersCharactersRequest(); serverRequest.PlayFabId = loginResult.PlayFabId; PlayFabServerAPI.GetAllUsersCharacters(serverRequest, ServerCharCallBack, PfSharedControllerEx.FailCallback("S_GetAllUsersCharacters")); }