示例#1
0
        public void Init()
        {
            account.Running.OnGetting = true;

            List <int> foodIndex = Foods.GetFoods(account.petsList[account.Running.CurrentPetIndex].Informations.GID);

            ObjectItem objectItem = null;

            foreach (ObjectItem item1 in account.SafeItems)
            {
                if (foodIndex.Contains(item1.ObjectGID))
                {
                    objectItem = item1;
                }
            }

            if (objectItem == null)
            {
                account.Running.NoFood();
                return;
            }

            int abbleWeight = account.Pods.WeightMax -
                              account.Pods.Weight - 1;
            //return;
            DataClass item         = GameData.GetDataObject(D2oFileEnum.Items, objectItem.ObjectGID);
            int       objectWeight = (int)item.Fields["realWeight"];
            int       quantity     = abbleWeight / objectWeight;

            if (objectItem.Quantity < quantity)
            {
                quantity = objectItem.Quantity;
            }

            ExchangeObjectMoveMessage exchangeObjectMoveMessage =
                new ExchangeObjectMoveMessage(objectItem.ObjectUID, -quantity);

            using (BigEndianWriter writer = new BigEndianWriter())
            {
                exchangeObjectMoveMessage.Serialize(writer);

                MessagePackaging messagePackaging = new MessagePackaging(writer);

                messagePackaging.Pack((int)exchangeObjectMoveMessage.ProtocolID);

                account.SocketManager.Send(messagePackaging.Writer.Content);
                account.LastPacketID.Clear();
            }
        }
示例#2
0
文件: Pet.cs 项目: shadowok/BlueSheep
        public void SetFood()
        {
            FoodList.Clear();
            string     name      = BlueSheep.Common.Data.I18N.GetText((int)Datas.Fields["nameId"]);
            List <int> foodIndex = Foods.GetFoods(name);

            if (foodIndex == null)
            {
                foodIndex = Foods.GetFoods(Informations.GID);
            }

            foreach (Core.Inventory.Item item in account.Inventory.Items)
            {
                if (foodIndex != null && foodIndex.Contains(item.GID))
                {
                    FoodList.Add(new Food(item, GameData.GetDataObject(D2oFileEnum.Items, item.GID)));
                }
            }
        }