public ActionResult Show(int id)
        {
            BagItem foundBagItem = BagItem.Find(id);

            return(View(foundBagItem));
            //return View(0); Fail CorrectModelType Test
        }
Beispiel #2
0
 //implémentation de l'interface IPointerClickHandler
 public void OnPointerClick(PointerEventData eventData)
 {
     if (eventData.button == PointerEventData.InputButton.Left)
     {
         if (Inventory.InventoryScr.TheSlot != null && MoveManager.TheMoveManager.Itembougeable != null && MoveManager.TheMoveManager.Itembougeable is BagItem)
         {
             if (Bag != null)
             {
                 Inventory.InventoryScr.SwapBags(Bag, MoveManager.TheMoveManager.Itembougeable as BagItem);
             }
             else
             {
                 BagItem b = (BagItem)MoveManager.TheMoveManager.Itembougeable;
                 b.BagButton = this;
                 b.Use();
                 Bag = b;
                 MoveManager.TheMoveManager.Drop();
                 Inventory.InventoryScr.TheSlot = null;
             }
         }
         //si on clique en appuyant sur caps lock, on prend le sac
         else if (Input.GetKey(KeyCode.CapsLock))
         {
             MoveManager.TheMoveManager.PickBougeable(Bag);
         }
         //sinon ou l'ouvre/ferme
         else if (bagitem != null)
         {
             bagitem.BagScr.OpenOrClose();
         }
     }
 }
Beispiel #3
0
    public void OnDrop(PointerEventData eventData)
    {
        BagItem bagItem = eventData.pointerDrag.GetComponent <BagItem>();

        Debug.Log(bagItem.itemInfo.id);
        if (bagPanel.itemInfoList[slotIndex].id == -1)
        {
            if (bagItem != null)
            {
                bagPanel.itemInfoList[bagItem.slotsIndex] = new ItemInfo();
                bagItem.slotsIndex = slotIndex;
                bagPanel.itemInfoList[slotIndex] = bagItem.itemInfo;
            }
        }
        else if (bagItem.slotsIndex != slotIndex)
        {
            //被换的物品信息
            Transform beItem = transform.GetChild(0);
            beItem.GetComponent <BagItem>().slotsIndex = bagItem.slotsIndex;
            //把被换的物品移动到原来拖动物品的父节点下
            beItem.SetParent(bagPanel.slotsList[bagItem.slotsIndex].transform);
            beItem.position = beItem.parent.position;
            //交换两个物品的信息,拖动物品的位置在OnEndDrag函数中设置
            bagPanel.itemInfoList[bagItem.slotsIndex] = beItem.GetComponent <BagItem>().itemInfo;
            bagItem.slotsIndex = slotIndex;
            bagPanel.itemInfoList[slotIndex] = bagItem.itemInfo;
        }
    }
Beispiel #4
0
    public void OnDrop(PointerEventData eventData)
    {
        BagItem bagItem = eventData.pointerDrag.GetComponent <BagItem>();

        Debug.Log(bagItem.itemInfo.id);

        if (bagItem != null && bagItem.slotsIndex != slotsIndex)
        {
            if (bagItem.itemInfo.name == this.itemInfo.name)
            {
                this.itemInfo.count += bagItem.itemInfo.count;
                SetData(this.itemInfo);
                bagPanel.itemInfoList[bagItem.slotsIndex] = new ItemInfo();
                Destroy(bagItem.gameObject);
            }
            else if (bagItem.itemInfo.name != this.itemInfo.name)
            {//两个物品不相同时交换位置
                int tempslotindex = slotsIndex;
                //被换的物品信息
                Transform beItem = transform;
                slotsIndex = bagItem.slotsIndex;
                //把被换的物品移动到原来拖动物品的父节点下
                beItem.SetParent(bagPanel.slotsList[bagItem.slotsIndex].transform);
                beItem.position = beItem.parent.position;
                //交换两个物品的信息,拖动物品的位置在OnEndDrag函数中设置
                bagPanel.itemInfoList[bagItem.slotsIndex] = itemInfo;
                bagItem.slotsIndex = tempslotindex;
                bagPanel.itemInfoList[tempslotindex] = bagItem.itemInfo;
            }
        }
    }
Beispiel #5
0
    private void createItem(int id, int count)
    {
        if (pool.ContainsKey(id))
        {
            return;
        }
        var obj = Tool.InstancePrefab("UI/BagItem", bag_content.transform.position, bag_content.transform.rotation);

        obj.transform.SetParent(bag_content.transform);
        obj.transform.localScale = Vector3.one;
        var item = obj.GetComponent <BagItem>();

        pool[id]   = item;
        item.Id    = id;
        item.Count = count;
        EventTriggerListener.Get(obj).onClick = delegate(GameObject p) {
            var xml = DB.DB.Item.Get(id);
            if (xml == null)
            {
                return;
            }
            bag_detail.text = xml.Desc;
            item_select     = item;
        };
        item.Show();
    }
Beispiel #6
0
 public Pet()
 {
     for (var i = 1; i <= 6; i++)
     {
         Equips[i] = new BagItem();
     }
 }
Beispiel #7
0
        public static void FillWithPickedItem(BagItem bagSlot, int maxCount)
        {
            var items = bagSlot.GetBagItems(BaseBagItem.MouseOnBagIndex);

            if (items.ContainsKey(bagSlot.index))
            {
                var maxHold = ConfigItem.getMaxCount(items[bagSlot.index].id);
                if (items[bagSlot.index].id == BaseBag.PickItem.id && maxHold > 1)
                {
                    var sent = Mathf.Min(maxHold - items[bagSlot.index].count, BaseBag.PickItem.count, maxCount);
                    BaseBag.PickItem.count     -= sent;
                    items[bagSlot.index].count += sent;
                }
                else
                {
                    var temp = BaseBag.PickItem;
                    BaseBag.PickItem     = items[bagSlot.index];
                    items[bagSlot.index] = temp;
                }
            }
            else
            {
                items[bagSlot.index] = new ItemData(BaseBag.PickItem);
                var sent = Mathf.Min(maxCount, BaseBag.PickItem.count);
                items[bagSlot.index].count = sent;
                BaseBag.PickItem.count    -= sent;
            }

            bagSlot.ShowItemInfo();
            BaseBag.ShowPickItem();
        }
Beispiel #8
0
            private static bool Prefix(BagItem __instance)
            {
                try
                {
                    var isMouseInButton = (bool)BagItem_isMouseInButton.GetValue(__instance);
                    var rmbClicked      = isMouseInButton && UnityEngine.Input.GetMouseButtonDown(1);
                    if (!rmbClicked)
                    {
                        return(true);
                    }

                    var item         = __instance.GetItem();
                    var moneyHovered = (item != null) && (item.id == 9027);
                    if (moneyHovered)
                    {
                        return(true);
                    }

                    if (BaseBag.PickItem != null)
                    {
                        var count = KeyBindings.GetKey(KeyBindingType.Unpack) ? 10 : 1;
                        BagItemUtil.FillWithPickedItem(__instance, count);
                        return(false);
                    }
                }
                catch (Exception e) { Log.ExceptionOnce(e); }

                return(true);
            }
        public ActionResult Create(string nameOfItem, int price, int weight, bool packed)
        {
            BagItem newBagItem = new BagItem(nameOfItem, price, weight, packed);

            return(RedirectToAction("Index"));
            //return new EmptyResult(); Fail CorrectView test
        }
Beispiel #10
0
 public void InitBag3(BagItem bag, int bagIndex)
 {
     bag.SetUpScript();
     bags.Add(bag);
     bag.BagButton            = bagbuttons[bagIndex];
     bagbuttons[bagIndex].Bag = bag;
 }
Beispiel #11
0
        public static TipShowData GetCompareTip(BagItem item)
        {
            if (item.cat == 2)
            {
                WeaponResConfigItem weapon = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(item.id);

                if (weapon.Type == (int)EWeaponType_Config.PrimeWeapon)
                {
                    if (HasTip("w1"))
                    {
                        return(new TipShowData(item.cat, item.id, chickenDic["w1"].id, 1));
                    }
                    else if (HasTip("w2"))
                    {
                        return(new TipShowData(item.cat, item.id, chickenDic["w2"].id, 1));
                    }
                }
                else if (weapon.Type == (int)EWeaponType_Config.SubWeapon)
                {
                    if (HasTip("w3"))
                    {
                        return(new TipShowData(item.cat, item.id, chickenDic["w3"].id, 1));
                    }
                }
            }

            return(new TipShowData(item.cat, item.id, 0, 1));
        }
Beispiel #12
0
    private void Awake()
    {
        BagItem bag = (BagItem)Instantiate(items[0]);

        bag.Init(20);
        bag.Use();
    }
Beispiel #13
0
    public void OnDrop(PointerEventData eventData)
    {
        BagItem droppenItem = eventData.pointerDrag.GetComponent <BagItem> ();

        if (droppenItem == null)
        {
            Debug.Log("当前拖拽无效");
            return;
        }
        if (transform.childCount == 0 || inv.itemBagList[slotID].ID == -1)
        {
            //把拖拽的item对应的槽位赋值一个新的item
            inv.itemBagList[droppenItem.slotIndex] = new ItemData();
            droppenItem.slotIndex = slotID;
            //把拖拽的item赋值给当前落下的槽位
            inv.itemBagList[slotID] = droppenItem.itemData;
        }
        //交换对象,位置
        else if (droppenItem.slotIndex != slotID)
        {
            Transform item = this.transform.GetChild(0);
            item.GetComponent <GoodItem>().slotIndex = droppenItem.slotIndex;
            item.transform.SetParent(inv.slotBagList[droppenItem.slotIndex].transform);
            item.transform.position = item.transform.parent.position;
            inv.itemBagList[droppenItem.slotIndex] = item.GetComponent <BagItem>().itemData;
            droppenItem.slotIndex   = slotID;
            inv.itemBagList[slotID] = droppenItem.itemData;
        }
    }
Beispiel #14
0
    private void RefreshInventoryItems()
    {
        foreach (Transform child in bagContainer)
        {
            if (child == itemTemplate)
            {
                continue;
            }
            Destroy(child.gameObject);
        }
        int   x = 0;
        int   y = 0;
        float itemSlotCellSIze = 60f;

        foreach (Stack stack in inventory.GetStacks())
        {
            BagItem bagItem = MakeBagItem(stack.item, stack.amount);
            bagItem.transform.GetComponent <RectTransform>().anchoredPosition = new Vector2(x * itemSlotCellSIze, -y * itemSlotCellSIze);

            bagItem.OnBeginDrag += BeginDragBagItem;
            bagItem.OnEndDrag   += EndDragBagItem;
            bagItem.OnDrag      += DragBagItem;
            bagItem.OnDrop      += DropBagItem;

            x++;
            if (x * itemSlotCellSIze + itemSlotCellSIze >= bagContainer.GetComponent <RectTransform>().rect.width)
            {
                x = 0;
                y++;
            }
        }
    }
Beispiel #15
0
 private void ShowPanel(BagItem bagItem)
 {
     InstrumentPanel.gameObject.SetActive(false);
     ObjectPanel.gameObject.SetActive(false);
     HistoryPanel.gameObject.SetActive(false);
     ChangeItemButtonColor(bagItem);
 }
        public ActionResult Index()
        {
            List <BagItem> allBagItem = BagItem.GetAll();

            return(View(allBagItem));
            // return new EmptyResult(); Fail CorrectView test
            //return View(0); Fail CorrectModelType Test
        }
        public void BagItemConstructor_CreatesInstanceOfBagItem_BagItem()
        {
            //Arrange
            BagItem testBagItem = new BagItem("camera", 1000, 2, true);

            //Act and Assert
            Assert.AreEqual(typeof(BagItem), testBagItem.GetType());
        }
Beispiel #18
0
    //蕨교관으썹충警속item
    public static void CreateNewItem(BagItem item)
    {
        Slot newItem = Instantiate(instance.slotPrefeb, instance.slotGrid.transform.position, Quaternion.identity);

        newItem.gameObject.transform.SetParent(instance.slotGrid.transform);
        newItem.slotItem         = item;
        newItem.slotImage.sprite = item.Icon;
    }
Beispiel #19
0
 public void RemoveMechaComponentFromBag(BagItem bagItem, bool temporary)
 {
     BagPanel.RemoveItem(bagItem, temporary);
     if (!temporary)
     {
         mechaComponentInfosInBag.Remove(bagItem.MechaComponentInfo);
     }
 }
    public void SetInformationPanel(BagItem bagItem, int itemIndex)
    {
        this.ItemName.text     = bagItem.ItemName;
        this.ItemCount         = bagItem.ItemCount;
        this.ItemIndex         = itemIndex;
        this.ItemDescribe.text = itemIndex.ToString();
        this.ItemDescribe.gameObject.SetActive(true);
        this.ItemName.gameObject.SetActive(true);

        if (bagItem.ItemType != BagItem.ItemTypes.UnKnown)
        {
            AbandonButton.gameObject.SetActive(true);
            AbandonButton.onClick.RemoveAllListeners();
            if (ItemCount > 1)
            {
                AbandonButton.onClick.AddListener(() => NumInputControlScript.OpenBagItemNumInputField(ItemCount,
                                                                                                       BagNumInputControlScript.ConsumableOrAbandon.Abandon));
            }
            else if (ItemCount == 1)
            {
                AbandonButton.onClick.AddListener(() => this.AbandonButtonClick(1));
            }
        }
        else
        {
            AbandonButton.gameObject.SetActive(false);
        }

        if (bagItem.ItemType == BagItem.ItemTypes.Equip || bagItem.ItemType == BagItem.ItemTypes.Book)
        {
            EquipButton.gameObject.SetActive(true);
            EquipButton.onClick.RemoveAllListeners();
            EquipButton.onClick.AddListener(() => this.EquipButtonClick());
        }
        else
        {
            EquipButton.gameObject.SetActive(false);
        }

        if (bagItem.ItemType == BagItem.ItemTypes.Consumables)
        {
            ConsumableButton.gameObject.SetActive(true);
            ConsumableButton.onClick.RemoveAllListeners();
            if (ItemCount > 1)
            {
                ConsumableButton.onClick.AddListener(() => NumInputControlScript.OpenBagItemNumInputField(ItemCount,
                                                                                                          BagNumInputControlScript.ConsumableOrAbandon.Consumable));
            }
            else if (ItemCount == 1)
            {
                EquipButton.onClick.AddListener(() => this.ConsumableButtonClick(1));
            }
        }
        else
        {
            ConsumableButton.gameObject.SetActive(false);
        }
    }
Beispiel #21
0
    public void OnDrop(PointerEventData eventData)
    {
        InventoryUI    invUI             = inventory.GetInventoryUI();
        DockUI         dockUI            = inventory.GetDockUI();
        UIDragableItem inventoryDragable = invUI.movingDragableItem;
        BagItem        preBagItem        = eventData.pointerDrag.GetComponent <BagItem>();
        ItemSlot       preSlot           = eventData.pointerDrag.GetComponent <ItemSlot>();

        if (preBagItem != null && preBagItem.gameObject.activeInHierarchy && invUI.hasDragable)
        {
            inventoryDragable.OnPlacementConfirm(this);
            inventoryDragable.GetComponent <RectTransform>().position = rectTransform.position;
            if (itemSlot != null)
            {
                dockUI.SetSlotItemAndSave(itemSlot, inventoryDragable.item);
                switch (itemSlot.positionType)
                {
                case ItemSlotPositionType.Dock:
                    break;

                case ItemSlotPositionType.Wear:
                    break;

                case ItemSlotPositionType.Bag:
                    break;
                }
                dockUI.UpdateWithInventoryChange(inventory);
            }
        }
        UIDragableItem dockDragable = dockUI.movingDragableItem;

        if (preSlot != null && preSlot.gameObject.activeInHierarchy && dockUI.hasDragable)
        {
            dockDragable.OnPlacementConfirm(this);
            dockDragable.GetComponent <RectTransform>().position = rectTransform.position;
            if (itemSlot != null)
            {
                Item itemWhichWasInTheSlotBeforeReplacement = itemSlot.item;
                inventory.dockUI.SetSlotItemAndSave(itemSlot, dockDragable.item);
                switch (itemSlot.positionType)
                {
                case ItemSlotPositionType.Dock:
                    // move from one dock slot to another
                    inventory.dockUI.SetSlotItemAndSave(preSlot, itemWhichWasInTheSlotBeforeReplacement);
                    break;

                case ItemSlotPositionType.Wear:
                    break;

                case ItemSlotPositionType.Bag:
                    break;
                }
                // update the dock
                dockUI.UpdateWithInventoryChange(inventory);
            }
        }
    }
Beispiel #22
0
        /*public BagManager() {
         *      // make sure all bags are closed
         *
         *      CloseAllBags();
         *      UpdateItems();
         *
         *      // check all contents
         * }*/

        public void UpdateItemsSorted()
        {
            //PPather.WriteLine("UpdateItemsSorted()");
            int[] count = new int[5] {
                0, 0, 0, 0, 0
            };
            UpdateItems();
            for (int i = 0; i < BagItems.Length; i++)
            {
                BagItem it = BagItems[i];
                //PPather.WriteLine("UpdateItemsSorted: Adding {0} to Bag {1} (count = {2})", it.item.Name, it.bag, count[it.bag] + 1);
                count[it.bag]++;
            }

            int bags = GPlayerSelf.Me.Bags.Length + 1;

            long[] AllBags = GPlayerSelf.Me.Bags;
            for (int bagNr = 0; bagNr < 5; bagNr++)
            {
                int SlotCount;
                if (bagNr == 0)
                {
                    SlotCount = GContext.Main.Me.SlotCount;
                }
                else
                {
                    GContainer bag = (GContainer)GObjectList.FindObject(AllBags[bagNr - 1]);
                    if (bag != null)
                    {
                        SlotCount = bag.SlotCount;
                    }
                    else
                    {
                        SlotCount = 0;
                    }
                }
                count[bagNr] = SlotCount;
            }

            //PPather.WriteLine("UpdateItemsSorted: Creating new Bag array of size {0}", bags);
            Bags = new Bag[bags];
            for (int i = 0; i < bags; i++)
            {
                //PPather.WriteLine("UpdateItemsSorted: Creating new GItem array of size {0} to Bag {1}", count[i], i);
                GItem[] gits = new GItem[count[i]];
                //PPather.WriteLine("UpdateItemsSorted: Adding gits to Bag {0}", i);
                Bags[i] = new Bag(i, gits);
            }

            for (int i = 0; i < BagItems.Length; i++)
            {
                BagItem it = BagItems[i];
                //PPather.WriteLine("UpdateItemsSorted: Bag[{0}].Add({1}, {2})", it.bag, it.item.Name, it.slot-1);
                Bags[it.bag].Add(it.item, it.slot - 1);
            }
        }
Beispiel #23
0
    public static BagItem Get(this GameObject go)
    {
        BagItem component = go.GetComponent <BagItem>();

        if (component == null)
        {
            go.AddComponent <BagItem>();
        }
        return(component);
    }
Beispiel #24
0
    private BagItem MakeBagItem(Item item, int amount)
    {
        RectTransform itemSlotRectTransform = Instantiate(itemTemplate, bagContainer);

        itemSlotRectTransform.gameObject.SetActive(true);
        BagItem bagItem = itemSlotRectTransform.GetComponent <BagItem>();

        bagItem.SetItem(item, amount);
        return(bagItem);
    }
        //Updated for new DB
        public void MoveToBank(BagItem bagitem)
        {
            //OpenConn();
            SqlCommand cmd = new SqlCommand("exec MoveToBank @id", conn);

            cmd.Parameters.AddWithValue("@id", bagitem.id);
            cmd.CommandType = CommandType.Text;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
        }
Beispiel #26
0
    private void BeginDragBagItem(BagItem item, PointerEventData eventData)
    {
        RectTransform dragableItemTransform = Instantiate(dragableItem, itemsUIContainer).GetComponent <RectTransform>();

        dragableItemTransform.gameObject.SetActive(true);
        movingDragableItem = dragableItemTransform.GetComponent <UIDragableItem>();
        hasDragable        = true;
        movingDragableItem.SetItem(item.item, item.amount);
        movingDragableItem.OnBeginDrag(eventData);
    }
Beispiel #27
0
        public void AddToBag(int ProductID, int AccountID)
        {
            BagItem bagItem = new BagItem()
            {
                AccountID = AccountID,
                ProductID = ProductID
            };

            bagItemContext.CreateBagItem(bagItem);
        }
Beispiel #28
0
    public Text itemCount;         //用于显示物品数量

    /// <summary>
    /// 将对应的物品显示在Grid方格中
    /// </summary>
    /// <param name="id">物品id</param>
    /// <param name="num">物品数量</param>
    public void SetByID(int id, int num = 1)
    {
        this.id = id;
        info    = ObjectsInfo._instance.GetObjectInfoById(id);
        BagItem item = this.GetComponentInChildren <BagItem>();

        item.setIconName(info.name_Icon);
        count             = num;
        itemCount.enabled = true;
        itemCount.text    = count.ToString();
    }
Beispiel #29
0
    public bool AddMechaComponentToBag(MechaComponentInfo mci, out BagItem bagItem)
    {
        bool suc = BagPanel.TryAddItem(mci, out bagItem);

        if (suc)
        {
            mechaComponentInfosInBag.Add(mci);
        }

        return(suc);
    }
Beispiel #30
0
    private void LoadBags(SaveData data)
    {
        foreach (BagData bagdata in data.MyInventoryData.Mybags)
        {
            BagItem newBag = (BagItem)Instantiate(items[0]);

            newBag.Init(bagdata.MySlotCount);

            Inventory.InventoryScr.InitBag3(newBag, bagdata.MyBagIndex);
        }
    }
Beispiel #31
0
 public void PutIntoBag(BagItem item, byte count = 1)
 {
     switch (item.bagType)
     {
         case ConstantDefine.BagItemType.Equipment:
             equipmentBag.Add((Equipment)item, item.bagType, count);
             break;
         case ConstantDefine.BagItemType.Potion:
             potionBag.Add((Potion)item, item.bagType, count);
             break;
         case ConstantDefine.BagItemType.Sundry:
             sundryBag.Add((Sundry)item, item.bagType, count);
             break;
         case ConstantDefine.BagItemType.Money:
             break;
         default:
             break;
     }
 }
Beispiel #32
0
 public static Reward GetRewardInfoFromXmlByAt(byte index)
 {
     Reward reward = new Reward();
     string path = "/rewards/reward[" + index.ToString() + "]/";
     XmlElement root = _GetXmlRootElement("reward/reward");
     int exp = 0;
     if (int.TryParse(root.SelectSingleNode(path + "exp").InnerText, out exp))
     {
         reward.exp = exp;
         int gold = 0;
         if (int.TryParse(root.SelectSingleNode(path + "gold").InnerText, out gold))
         {
             reward.gold = gold;
             XmlNodeList nameNodes = root.SelectNodes(path + "items/name");
             XmlNodeList idNodes = root.SelectNodes(path + "items/id");
             XmlNodeList countNodes = root.SelectNodes(path + "items/count");
             BagItem[] bagItems = new BagItem[nameNodes.Count];
             byte[] counts = new byte[nameNodes.Count];
             for (int i = 0; i < nameNodes.Count; i++)
             {
                 //数量
                 byte count = 0;
                 if (byte.TryParse(countNodes[i].InnerText, out count))
                 {
                     counts[i] = count;
                     Type type = Type.GetType(nameNodes[i].InnerText);
                     if (type == null)
                     {
                         Debug.LogError("没有该物品");
                     }
                     byte id = 0;
                     ConstantDefine.CollectionType itemType;
                     if (byte.TryParse(idNodes[i].InnerText, out id))
                     {
                         itemType = (ConstantDefine.CollectionType)id;
                         BagItem item = Activator.CreateInstance(type, new object[1] { itemType }) as BagItem;
                         if (item != null)
                         {
                             bagItems[i] = item;
                         }
                     }
                 }
                 reward.items = bagItems;
                 reward.counts = counts;
             }
         }
     }
     return reward;
 }
Beispiel #33
0
        public void UpdateItems()
        {
            List<GItem> ItemList = new List<GItem>();
            List<BagItem> BagItemList = new List<BagItem>();
            long[] AllBags = GPlayerSelf.Me.Bags;

            long[] Contents;
            int SlotCount;

            for (int bag = 0; bag <= 4; bag++)
            {
                SlotCount = 0;
                if (bag == 0)
                {
                    Contents = GContext.Main.Me.BagContents;
                    SlotCount = GContext.Main.Me.SlotCount;
                }
                else
                {
                    GContainer container = (GContainer)GObjectList.FindObject(AllBags[bag - 1]);
                    if (container != null)
                    {
                        Contents = container.BagContents;
                        SlotCount = container.SlotCount;
                    }
                    else
                        Contents = null;
                }
                if (Contents != null)
                {
                    for (int i = 0; i < Contents.Length; i++)
                    {
                        GItem CurItem = (GItem)GObjectList.FindObject(Contents[i]);
                        if (CurItem != null)
                        {
                            ItemList.Add(CurItem);
                            BagItem bi = new BagItem(bag, SlotCount - i, CurItem);
                            BagItemList.Add(bi);
                        }
                    }
                }
            }

            Items = ItemList.ToArray();
            BagItems = BagItemList.ToArray();
        }
        public void Decode(ClientConnection pConnection, MaplePacket pPacket)
        {
            InventorySlots = new byte[INVENTORIES];
            for (int i = 0; i < INVENTORIES; i++)
                InventorySlots[i] = pPacket.ReadByte();

            pPacket.ReadLong(); // 94354848000000000 | 1-1-1900



            EquipmentItems = new Dictionary<short, ItemEquip>[EQUIP_INVENTORIES];
#if LOCALE_EMS
            for (byte i = 0; i < 3; i++)
            {
                EquipmentItems[i] = new Dictionary<short, ItemEquip>();

                while (true)
                {
                    short slot = pPacket.ReadShort();
                    if (slot == 0) break;
                    slot = CharacterInventory.CorrectEquipSlot(i, slot);

                    ItemEquip equip = (ItemEquip)ItemBase.DecodeItemData(pConnection, pPacket);

                    EquipmentItems[i].Add(slot, equip);
                }
            }

            pPacket.ReadBool(); // EMS only -.-

            for (byte i = 3; i < EQUIP_INVENTORIES; i++)
            {
                EquipmentItems[i] = new Dictionary<short, ItemEquip>();

                while (true)
                {
                    short slot = pPacket.ReadShort();
                    if (slot == 0) break;
                    slot = CharacterInventory.CorrectEquipSlot(i, slot);

                    ItemEquip equip = (ItemEquip)ItemBase.DecodeItemData(pConnection, pPacket);

                    EquipmentItems[i].Add(slot, equip);
                }
            }
#else
            for (byte i = 0; i < EQUIP_INVENTORIES; i++)
            {
                EquipmentItems[i] = new Dictionary<short, ItemEquip>();

                while (true)
                {
                    short slot = pPacket.ReadShort();
                    if (slot == 0) break;
                    slot = CharacterInventory.CorrectEquipSlot(i, slot);

                    ItemEquip equip = (ItemEquip)ItemBase.DecodeItemData(pConnection, pPacket);

                    EquipmentItems[i].Add(slot, equip);
                }
            }
#endif

            InventoryItems = new Dictionary<byte, ItemBase>[NORMAL_INVENTORIES];
            BagItems = new Dictionary<int, BagItem>();

            for (byte i = 0; i < NORMAL_INVENTORIES; i++)
            {
                InventoryItems[i] = new Dictionary<byte, ItemBase>();

                while (true)
                {
                    byte slot = pPacket.ReadByte();
                    if (slot == 0) break;

                    ItemBase item = ItemBase.DecodeItemData(pConnection, pPacket);
                    InventoryItems[i].Add(slot, item);

                    if (item.BagID != -1)
                    {
                        // Update BagID... O.o
                        item.BagID = GameHelper.GetBagID(item.BagID, i);

                        BagItem bi = new BagItem(item);
                        BagItems.Add(item.BagID, bi);
                    }
                }
            }

            // Bagzzz
            for (int inv = 3; inv <= 4; inv++)
            {
                var bags = pPacket.ReadInt();
                for (int i = 0; i < bags; i++)
                {
                    int bagid = pPacket.ReadInt();

                    int bagitemid = pPacket.ReadInt();

                    BagItem bi = BagItems[GameHelper.GetBagID(bagid, inv - 2)]; // No addition to inv...!

                    while (true)
                    {
                        int slotid = pPacket.ReadInt();
                        if (slotid == -1) break;

                        ItemBase item = ItemBase.DecodeItemData(pConnection, pPacket);
                        bi.Items.Add((byte)slotid, item);
                    }
                }
            }
        }
Beispiel #35
0
        private void LandPlant(string userId, JsonObject theFarmStatus)
        {
            string have = "";
            string result = "";
            User friendInfo = new User(GetUserModel(userId));
            CropItem cropInfo = new CropItem(GetCropModel(cId));

            if (!userId.Equals(""))
            {
                for (int i = 0; i < theFarmStatus.GetCollection().Count; i++)
                {
                    Land newLand = new Land(theFarmStatus.GetCollection()[i]);
                    have = newLand.b;
                    if (have.Equals("0"))//无植物
                    {
                        BagItem newBagItem = new BagItem(GetBagItemModel(cId));
                        if (_autoSeed && (Convert.ToInt32(newBagItem.amount) == 0))
                        {
                            buySeed(cId, "1");
                        }
                        else
                        { }
                        result = Plant(cId, userId, i.ToString());
                        if (result.Contains("\"farmlandIndex\":" + i.ToString()) && result.Contains("\"cId\":" + cId.ToString()))
                        {
                            toLog("往" + friendInfo.userName + "的农场的第" + i.ToString() + "号地种植" + cropInfo.cName + "成功");
                        }
                        else
                        {
                            toLog("往" + friendInfo.userName + "的农场的第" + i.ToString() + "号地种植" + cropInfo.cName + "失败");
                        }
                    }
                }
            }
        }