Esempio n. 1
0
        public async UniTask <DecreaseStorageItemsResult> DecreaseStorageItems(StorageId storageId, int dataId, short amount)
        {
#if UNITY_STANDALONE && !CLIENT_BUILD
            Storage storge = GetStorage(storageId, out _);
            DecreaseStorageItemsReq req = new DecreaseStorageItemsReq();
            req.StorageType    = (EStorageType)storageId.storageType;
            req.StorageOwnerId = storageId.storageOwnerId;
            req.WeightLimit    = storge.weightLimit;
            req.SlotLimit      = storge.slotLimit;
            req.DataId         = dataId;
            req.Amount         = amount;
            DecreaseStorageItemsResp resp = await DbServiceClient.DecreaseStorageItemsAsync(req);

            if (UITextKeys.NONE != (UITextKeys)resp.Error)
            {
                // Error ocurring, storage may overwhelming let's it drop items to ground
                return(new DecreaseStorageItemsResult());
            }
            SetStorageItems(storageId, DatabaseServiceUtils.MakeListFromRepeatedByteString <CharacterItem>(resp.StorageCharacterItems));
            NotifyStorageItemsUpdated(storageId.storageType, storageId.storageOwnerId);
            Dictionary <int, short> decreasedItems = new Dictionary <int, short>();
            foreach (ItemIndexAmountMap entry in resp.DecreasedItems)
            {
                decreasedItems.Add(entry.Index, (short)entry.Amount);
            }
            return(new DecreaseStorageItemsResult()
            {
                IsSuccess = true,
                DecreasedItems = decreasedItems,
            });
#else
            return(new DecreaseStorageItemsResult());
#endif
        }
Esempio n. 2
0
        public async UniTask <DecreaseStorageItemsResp> DecreaseStorageItemsAsync(DecreaseStorageItemsReq request)
        {
            var result = await Client.SendRequestAsync <DecreaseStorageItemsReq, DecreaseStorageItemsResp>(DatabaseRequestTypes.RequestDecreaseStorageItems, request);

            if (result.ResponseCode != AckResponseCode.Success)
            {
                return(new DecreaseStorageItemsResp());
            }
            return(result.Response);
        }
        public async UniTask <AsyncResponseData <DecreaseStorageItemsResp> > DecreaseStorageItemsAsync(DecreaseStorageItemsReq request)
        {
            var resp = await Client.SendRequestAsync <DecreaseStorageItemsReq, DecreaseStorageItemsResp>(DatabaseRequestTypes.RequestDecreaseStorageItems, request);

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