Ejemplo n.º 1
0
        public static void GetUserVc(string playFabId)
        {
            var getRequest = new ServerModels.GetUserInventoryRequest();

            getRequest.PlayFabId = playFabId;
            PlayFabServerAPI.GetUserInventory(getRequest, GetUserVcCallback, PfSharedControllerEx.FailCallback("GetUserInventory"));
        }
Ejemplo n.º 2
0
 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"));
     }
 }
Ejemplo n.º 3
0
        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"));
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public void GetInventory()
        {
            var getRequest = new GetCharacterInventoryRequest();

            getRequest.CharacterId = characterId;
            PlayFabClientAPI.GetCharacterInventory(getRequest, GetInventoryCallback, PfSharedControllerEx.FailCallback("GetCharacterInventory"));
        }
Ejemplo n.º 6
0
        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"));
        }
Ejemplo n.º 7
0
        public static void CancelTrade(string tradeId)
        {
            var cancelRequest = new ClientModels.CancelTradeRequest();

            cancelRequest.TradeId = tradeId;
            PlayFabClientAPI.CancelTrade(cancelRequest, CancelTradeCallback, PfSharedControllerEx.FailCallback("CancelTrade"));
        }
Ejemplo n.º 8
0
        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"));
        }
Ejemplo n.º 9
0
        public void GetInventory()
        {
            var getRequest = new ServerModels.GetCharacterInventoryRequest();

            getRequest.PlayFabId   = playFabId;
            getRequest.CharacterId = characterId;
            PlayFabServerAPI.GetCharacterInventory(getRequest, GetInventoryCallback, PfSharedControllerEx.FailCallback("GetCharacterInventory"));
        }
Ejemplo n.º 10
0
        public static void GetUserStatistics(string playFabId)
        {
            var request = new GetUserStatisticsRequest();

            request.PlayFabId = playFabId;
            PlayFabServerAPI.GetUserStatistics(request, GetUserStatisticsCallback,
                                               PfSharedControllerEx.FailCallback("GetUserStatistics"));
        }
Ejemplo n.º 11
0
        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"));
        }
Ejemplo n.º 12
0
        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"));
        }
Ejemplo n.º 13
0
        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"));
        }
Ejemplo n.º 14
0
        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"));
        }
Ejemplo n.º 15
0
        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"));
        }
Ejemplo n.º 16
0
        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"));
        }
Ejemplo n.º 17
0
        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"));
        }
Ejemplo n.º 18
0
        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"));
        }
Ejemplo n.º 19
0
        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"));
        }
Ejemplo n.º 20
0
        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");
            }
        }
Ejemplo n.º 21
0
        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"));
        }
Ejemplo n.º 22
0
 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"));
 }
Ejemplo n.º 23
0
        public static void GetUserStatistics()
        {
            var request = new GetUserStatisticsRequest();

            PlayFabClientAPI.GetUserStatistics(request, GetUserStatisticsCallback, PfSharedControllerEx.FailCallback("GetUserStatistics"));
        }
Ejemplo n.º 24
0
        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"));
        }
Ejemplo n.º 25
0
 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"));
 }
Ejemplo n.º 26
0
        public static void GetUserVc()
        {
            var getRequest = new ClientModels.GetUserInventoryRequest();

            PlayFabClientAPI.GetUserInventory(getRequest, GetUserVcCallback, PfSharedControllerEx.FailCallback("GetUserInventory"));
        }
Ejemplo n.º 27
0
        public static void GetCharacterVc(string characterId)
        {
            var getRequest = new ClientModels.GetCharacterInventoryRequest();

            getRequest.CharacterId = characterId;
            PlayFabClientAPI.GetCharacterInventory(getRequest, GetCharacterVcCallback, PfSharedControllerEx.FailCallback("GetCharacterInventory"));
        }
Ejemplo n.º 28
0
 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"));
 }
Ejemplo n.º 29
0
        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"));
        }
Ejemplo n.º 30
0
        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"));
        }