/// <summary>
        /// Adds the loot bag items to the specified loot bag storage.
        /// </summary>
        /// <param name="storageId">loot bag storage ID</param>
        /// <param name="addingItems">items to add to loot bag</param>
        /// <returns>true if successful, false otherwise</returns>
        public async UniTask <bool> AddLootBagItems(StorageId storageId, List <CharacterItem> lootItems)
        {
#if UNITY_STANDALONE && !CLIENT_BUILD
            // Attempt to read from storage first. This registers it and adds it to cache.
            ReadStorageItemsReq rsir = new ReadStorageItemsReq();
            rsir.StorageType    = storageId.storageType;
            rsir.StorageOwnerId = storageId.storageOwnerId;
            ReadStorageItemsResp rsiresp = await DbServiceClient.ReadStorageItemsAsync(rsir);

            foreach (CharacterItem lootItem in lootItems)
            {
                Storage storge = GetStorage(storageId, out _);
                IncreaseStorageItemsReq req = new IncreaseStorageItemsReq();
                req.StorageType    = storageId.storageType;
                req.StorageOwnerId = storageId.storageOwnerId;
                req.WeightLimit    = storge.weightLimit;
                req.SlotLimit      = storge.slotLimit;
                req.Item           = lootItem;
                IncreaseStorageItemsResp resp = await DbServiceClient.IncreaseStorageItemsAsync(req);

                if (UITextKeys.NONE != resp.Error)
                {
                    return(false);
                }
                SetStorageItems(storageId, resp.StorageCharacterItems);
            }
            return(true);
#else
            return(false);
#endif
        }
コード例 #2
0
        public async UniTask <IncreaseStorageItemsResp> IncreaseStorageItemsAsync(IncreaseStorageItemsReq request)
        {
            var result = await Client.SendRequestAsync <IncreaseStorageItemsReq, IncreaseStorageItemsResp>(DatabaseRequestTypes.RequestIncreaseStorageItems, request);

            if (result.ResponseCode != AckResponseCode.Success)
            {
                return(new IncreaseStorageItemsResp());
            }
            return(result.Response);
        }
コード例 #3
0
        public async UniTask <bool> IncreaseStorageItems(StorageId storageId, CharacterItem addingItem)
        {
#if UNITY_STANDALONE && !CLIENT_BUILD
            Storage storge = GetStorage(storageId, out _);
            IncreaseStorageItemsReq req = new IncreaseStorageItemsReq();
            req.StorageType    = (EStorageType)storageId.storageType;
            req.StorageOwnerId = storageId.storageOwnerId;
            req.WeightLimit    = storge.weightLimit;
            req.SlotLimit      = storge.slotLimit;
            req.Item           = DatabaseServiceUtils.ToByteString(addingItem);
            IncreaseStorageItemsResp resp = await DbServiceClient.IncreaseStorageItemsAsync(req);

            if (UITextKeys.NONE != (UITextKeys)resp.Error)
            {
                // Error ocurring, storage may overwhelming let's it drop items to ground
                return(false);
            }
            SetStorageItems(storageId, DatabaseServiceUtils.MakeListFromRepeatedByteString <CharacterItem>(resp.StorageCharacterItems));
            NotifyStorageItemsUpdated(storageId.storageType, storageId.storageOwnerId);
            return(true);
#else
            return(false);
#endif
        }
        public async UniTask <AsyncResponseData <IncreaseStorageItemsResp> > IncreaseStorageItemsAsync(IncreaseStorageItemsReq request)
        {
            var resp = await Client.SendRequestAsync <IncreaseStorageItemsReq, IncreaseStorageItemsResp>(DatabaseRequestTypes.RequestIncreaseStorageItems, request);

            if (!resp.IsSuccess)
            {
                Logging.LogError(nameof(DatabaseNetworkManager), $"Cannot {nameof(IncreaseStorageItemsAsync)} status: {resp.ResponseCode}");
            }
            return(resp);
        }