Exemplo n.º 1
0
        private void OnLeaveInventory(UnloadInventoryBasicIntegrationMessage message)
        {
            int connectionId = message.ConnectionId;

            if (!IsCanMakeDMarketOperation(connectionId))
            {
                return;
            }

            PlayerInfo          playerInfo = GetPlayer(connectionId);
            PlayerInventoryInfo inventory  = playerInfo.Inventory;

            List <ItemInfo> movingItems = new List <ItemInfo>();

            foreach (var playerItemInfo in inventory.Items)
            {
                if (inventory.IsEquipped(playerItemInfo.WorldId))
                {
                    continue;
                }

                movingItems.Add(new ItemInfo(playerItemInfo.WorldId, playerItemInfo.ItemType));
            }

            ApplyCommand(new ServerBulkTransferInventoryBasicIntegrationCommand(movingItems, ItemActionType.ToMarket, connectionId));
        }
Exemplo n.º 2
0
 public InventoryParameters(PlayerInventoryInfo inventory, ClientApi clientApi, IWidgetCore widget, IClientApiSettings apiSettings, bool isBasicIntegration)
 {
     Inventory          = inventory;
     ClientApi          = clientApi;
     Widget             = widget;
     ApiSettings        = apiSettings;
     IsBasicIntegration = isBasicIntegration;
 }
Exemplo n.º 3
0
 public void UpdateInventoryData(PlayerInventoryInfo inventory)
 {
     if (inventory != null)
     {
         Model.Inventory = inventory;
         Model.SetChanges();
     }
 }
Exemplo n.º 4
0
 public void Run(PlayerInventoryInfo inventory, IWidget widget = null,
                 ClientApi widgetApi = null)
 {
     Model     = new ShopModel();
     Widget    = widget;
     WidgetApi = widgetApi;
     UpdateInventoryData(inventory);
     ApplyState <ShopInitState>();
 }
        private async Task GetPlayerInventory()
        {
            try
            {
                string url = string.Format("http://{0}:{1}/api/getplayerinventory?steamid={2}&adminuser={3}&admintoken={4}",
                                           SdtdServerInfoManager.Instance.ServerIP,
                                           SdtdServerInfoManager.Instance.GPSPort,
                                           SteamID,
                                           SdtdServerInfoManager.Instance.WebUserToken.AdminUser,
                                           SdtdServerInfoManager.Instance.WebUserToken.AdminToken);

                string json = await HttpHelper.Instance.GetStringAsync(url);

                PlayerInventoryInfo playerInventoryInfos = JsonConvert.DeserializeObject <PlayerInventoryInfo>(json);

                string itemIconBaseUrl = string.Format("http://{0}:{1}/itemicons/",
                                                       SdtdServerInfoManager.Instance.ServerIP,
                                                       SdtdServerInfoManager.Instance.GPSPort);

                LoadImage(BagItems, playerInventoryInfos.bag, itemIconBaseUrl);

                LoadImage(BeltItems, playerInventoryInfos.belt, itemIconBaseUrl);

                LoadImage(EquipmentItems, new List <ItemData>()
                {
                    playerInventoryInfos.equipment.head,
                    playerInventoryInfos.equipment.eyes,
                    playerInventoryInfos.equipment.face,
                    playerInventoryInfos.equipment.armor,
                    playerInventoryInfos.equipment.jacket,
                    playerInventoryInfos.equipment.shirt,
                    playerInventoryInfos.equipment.legarmor,
                    playerInventoryInfos.equipment.pants,
                    playerInventoryInfos.equipment.boots,
                    playerInventoryInfos.equipment.gloves
                }, itemIconBaseUrl);
            }
            catch (Exception ex)
            {
                string message = "获取玩家背包数据失败";
                Log.Error(ex, message);
                _dialogService.ShowInformation(ex.Message, message);
            }
        }
Exemplo n.º 6
0
        private void OnLoadDMarketDataMsg(AppLoadDMarketDataMessage message)
        {
            int connectionId = message.ConnectionId;

            if (!IsCanMakeDMarketOperation(connectionId))
            {
                return;
            }

            DMarketApi.GetInMarketInventory(Model.GetPlayerMarketAccessToken(connectionId),
                                            (response, request) =>
            {
                PlayerInfo playerInfo = GetPlayer(connectionId);

                PlayerInventoryInfo inventory = GetInventory(connectionId);
                playerInfo.Inventory          = inventory;
                inventory.RemoveAllDMarketItems();

                foreach (var item in response.Items)
                {
                    GameItemType itemType = DMarketConverter.GetItemType(item.classId);
                    long worldId          = DMarketConverter.GetWorldId(item.assetId);

                    PlayerItemInfo dmarketItem = new PlayerItemInfo(itemType, worldId, true);
                    inventory.AddItem(dmarketItem);
                }

                Storage.Change(playerInfo);

                SendDmarketDataUpdateAnswer(connectionId);
            },
                                            error =>
            {
                if (error.ErrorCode == ErrorCode.DMarketTokenExpired)
                {
                    RefreshMarketToken(connectionId, () => OnLoadDMarketDataMsg(message),
                                       errorParam => SendLoadDMarketLoadDataError(connectionId, errorParam));
                    return;
                }

                SendLoadDMarketLoadDataError(connectionId, error.ErrorCode);
            });
        }
Exemplo n.º 7
0
        public void Update(PlayerInventoryInfo inventory)
        {
            //TODO need optimization
            _items.Clear();

            foreach (PlayerItemInfo gameItem in inventory.Items)
            {
                if (!gameItem.IsInMarket && !inventory.IsEquipped(gameItem.WorldId))
                {
                    var newItem = new InGameItemInfo
                    {
                        Title   = _infoCatalog.GetInfo(gameItem.ItemType).Name,
                        Sprite  = _imageCatalog.GetInventoryItemSprite(gameItem.ItemType),
                        AssetId = _dMarketConverter.GetAssetId(gameItem.WorldId),
                        ClassId = _dMarketConverter.GetClassId(gameItem.ItemType)
                    };
                    _items.Add(newItem);
                }
            }
            ItemsChanged.SafeRaise();
        }
Exemplo n.º 8
0
 public DMarketDataLoadResponse(PlayerInventoryInfo inventory, ErrorCode error = ErrorCode.None)
 {
     Inventory = inventory;
     Error     = error;
 }
Exemplo n.º 9
0
 public void UpdateInventoryData(PlayerInventoryInfo inventory)
 {
     MarketIntegrationModel.Update(inventory);
     Model.SetInventory(inventory);
     Model.SetChanges();
 }
Exemplo n.º 10
0
 public void SetInventory(PlayerInventoryInfo inventoryInfo)
 {
     _inventory = inventoryInfo;
 }