コード例 #1
0
        private void TransferItems()
        {
            if (_cleanuped)
            {
                return;
            }
            if (ItemsTransfered)
            {
                return;
            }
            ItemsTransfered = true;
            var firstCharItemsCount =
                FirstCharacterItems.Count(i => i != null && i.Item != null && i.Item.ItemId != 20551);
            var secondCharItemsCount =
                SecondCharacterItems.Count(i => i != null && i.Item != null && i.Item.ItemId != 20551);

            if (TradeType == Asda2TradeType.RedularTrade)
            {
                if (SecondChar.Asda2Inventory.FreeRegularSlotsCount < firstCharItemsCount || FisrtChar.Asda2Inventory.FreeRegularSlotsCount < secondCharItemsCount)
                {
                    FisrtChar.SendSystemMessage("Check free space in inventory!.");
                    SecondChar.SendSystemMessage("Check free space in inventory!.");
                    CancelTrade();
                    return;
                }
            }
            else
            {
                if (SecondChar.Asda2Inventory.FreeShopSlotsCount < firstCharItemsCount || FisrtChar.Asda2Inventory.FreeShopSlotsCount < secondCharItemsCount)
                {
                    FisrtChar.SendSystemMessage("Check free space in inventory!.");
                    SecondChar.SendSystemMessage("Check free space in inventory!.");
                    CancelTrade();
                    return;
                }
            }
            var newItemsOfSecond = Transfer(FirstCharacterItems, SecondChar);
            var newItemsOfFirst  = Transfer(SecondCharacterItems, FisrtChar);

            if (TradeType == Asda2TradeType.RedularTrade)
            {
                Asda2TradeHandler.SendRegularTradeCompleteResponse(FisrtChar.Client, newItemsOfFirst);
                Asda2TradeHandler.SendRegularTradeCompleteResponse(SecondChar.Client, newItemsOfSecond);
            }
            else
            {
                Asda2TradeHandler.SendShopTradeCompleteResponse(FisrtChar.Client, newItemsOfFirst);
                Asda2TradeHandler.SendShopTradeCompleteResponse(SecondChar.Client, newItemsOfSecond);
            }
            FisrtChar.SendMoneyUpdate();
            SecondChar.SendMoneyUpdate();
        }
コード例 #2
0
        private void TransferItems()
        {
            if (_cleanuped || ItemsTransfered)
            {
                return;
            }
            ItemsTransfered = true;
            int num1 = FirstCharacterItems.Count(
                i =>
            {
                if (i != null && i.Item != null)
                {
                    return(i.Item.ItemId != 20551);
                }
                return(false);
            });
            int num2 = SecondCharacterItems.Count(
                i =>
            {
                if (i != null && i.Item != null)
                {
                    return(i.Item.ItemId != 20551);
                }
                return(false);
            });

            if (TradeType == Asda2TradeType.RedularTrade)
            {
                if (SecondChar.Asda2Inventory.FreeRegularSlotsCount < num1 ||
                    FisrtChar.Asda2Inventory.RegularItems.Count(
                        i => i == null) < num2)
                {
                    FisrtChar.SendSystemMessage("Check free space in inventory!.");
                    SecondChar.SendSystemMessage("Check free space in inventory!.");
                    CancelTrade();
                    return;
                }
            }
            else if (SecondChar.Asda2Inventory.ShopItems.Count(
                         i => i == null) < num1 ||
                     FisrtChar.Asda2Inventory.ShopItems.Count(
                         i => i == null) < num2)
            {
                FisrtChar.SendSystemMessage("Check free space in inventory!.");
                SecondChar.SendSystemMessage("Check free space in inventory!.");
                CancelTrade();
                return;
            }

            Asda2Item[] items1 =
                Transfer(FirstCharacterItems, SecondChar);
            Asda2Item[] items2 =
                Transfer(SecondCharacterItems, FisrtChar);
            if (TradeType == Asda2TradeType.RedularTrade)
            {
                Asda2TradeHandler.SendRegularTradeCompleteResponse(FisrtChar.Client, items2);
                Asda2TradeHandler.SendRegularTradeCompleteResponse(SecondChar.Client, items1);
            }
            else
            {
                Asda2TradeHandler.SendShopTradeCompleteResponse(FisrtChar.Client, items2);
                Asda2TradeHandler.SendShopTradeCompleteResponse(SecondChar.Client, items1);
            }

            FisrtChar.SendMoneyUpdate();
            SecondChar.SendMoneyUpdate();
        }