Beispiel #1
0
    public void OnInventoryClick(object[] objectArray)
    {
        InventoryItem it     = objectArray[0] as InventoryItem;
        bool          isleft = (bool)objectArray[1];

        if (it.Inventory.InventoryType == InventoryType.Equip || it.Inventory.InventoryType == InventoryType.Pet || it.Inventory.InventoryType == InventoryType.PetEquip)
        {
            InventoryItemUI   itUI      = null;
            KnapsackRoleEquip roleEquip = null;
            if (isleft == true)
            {
                itUI = objectArray[2] as InventoryItemUI;
            }
            else
            {
                roleEquip = objectArray[2] as KnapsackRoleEquip;
            }
            inventory.CloseOn();
            equip.Show(it, itUI, roleEquip, isleft);
        }
        else
        {
            InventoryItemUI itUI = objectArray[2] as InventoryItemUI;
            equip.closeon();
            inventory.Show(it, itUI);
        }
        if ((it.Inventory.InventoryType == InventoryType.Equip && isleft == true) || it.Inventory.InventoryType != InventoryType.Equip)
        {
            this.itUI = objectArray[2] as InventoryItemUI;
            EnableButton();
            pricesale.text = (this.itUI.it.Inventory.Price * this.itUI.it.Count).ToString();
        }
    }
Beispiel #2
0
    public void OnEquipClick(object[] objectArray)
    {
        InventoryItem it     = (InventoryItem)objectArray[0];
        bool          isLeft = (bool)objectArray[1];


        if (it.Inventory.Inventorytype == InventoryType.Euqip)
        {
            InventoryItemUI   itUI      = null;
            KnapsackRoleEquip roleEquip = null;
            if (isLeft == true)
            {
                itUI = objectArray[2] as InventoryItemUI;
            }
            else
            {
                roleEquip = objectArray[2] as KnapsackRoleEquip;
            }



            equipPopup.Show(it, itUI, roleEquip, isLeft);
        }
        else
        {
            _inventoryPopup.Show(it);
        }
    }
Beispiel #3
0
    public void OnInventoryClick(object[] objArr)
    {
        InventoryItem it     = objArr [0] as InventoryItem;
        bool          isLeft = (bool)objArr [1];

        if (it._Item._InventoryType == InventoryType.Equip)
        {
            InventoryItemUI itUI = null;
            BagRoleEquip    bre  = null;
            if (isLeft == true)
            {
                itUI = objArr [2] as InventoryItemUI;
            }
            else
            {
                bre = objArr[2] as BagRoleEquip;
            }
            inventoryPopup.Close();
            equipPopup.Show(it, itUI, bre, isLeft);
        }
        else
        {
            InventoryItemUI itUI = objArr[2] as InventoryItemUI;
            equipPopup.Close();
            inventoryPopup.Show(it, itUI);
        }
        if ((it._Item._InventoryType == InventoryType.Equip && isLeft == true) || it._Item._InventoryType != InventoryType.Equip)
        {
            this.it = it;
            EnableBtn();
        }
    }
Beispiel #4
0
    public void onInventoryClick(object[] objArray)
    {
        InventoryItem it     = objArray[0] as InventoryItem;
        bool          isLeft = (bool)objArray[1];

        if (it.Inventory.InventoryType == InventoryType.Equip)
        {
            inventoryPopup.onClose();
            if (isLeft == false)
            {
                itUI = objArray[2] as InventoryItemUI;
                enableSellBtn();
                sellPriceTxt.text = (itUI.it.Inventory.Price * itUI.it.Count).ToString();
            }
            equipPopup.Show(it, itUI, isLeft);
        }
        else
        {
            itUI = objArray[2] as InventoryItemUI;
            equipPopup.onClose();
            inventoryPopup.Show(it, itUI);
            enableSellBtn();
            sellPriceTxt.text = (itUI.it.Inventory.Price * itUI.it.Count).ToString();
        }
    }
Beispiel #5
0
    //接受点击每个小格子传来消息
    public void OnInventoryClick(object[] objectArray)
    {
        InventoryItem      it   = objectArray[0] as InventoryItem;
        InventoryItemUI    itUI = null;
        KnapspackRoleEquip kre  = null;
        bool isLeft             = false;

        if (it.Inventory.InventoryTYPE == InventoryType.Equip)
        {
            isLeft = (bool)objectArray[1];
            if (isLeft)
            {
                itUI = objectArray[2] as InventoryItemUI;
            }
            else
            {
                kre = objectArray[2] as KnapspackRoleEquip;
            }
            equip.Show(it, itUI, isLeft);
        }
        else
        {
            itUI = objectArray[2] as InventoryItemUI;
            inventoryPopup.Show(it, itUI);
        }
        if ((it.Inventory.InventoryTYPE == InventoryType.Equip && isLeft) || it.Inventory.InventoryTYPE != InventoryType.Equip)
        {
            this.itUI = objectArray[2] as InventoryItemUI;
            EnableButton(itUI.it.Inventory.Price * itUI.it.Count);
        }
    }
Beispiel #6
0
    //
    public void OnInventoryClick(object[] o)
    {
        //Debug.Log("OnEquipClick");
        InventoryItem it     = o[0] as InventoryItem;
        bool          isLeft = (bool)(o[1]);
        //Debug.Log(isLeft);

        InventoryItemUI       itui = null;
        KnapsackRoleEquipItem eit  = null;

        if (it.Inventory.InventoryTYPE == InventoryType.Equip)
        {
            if (isLeft)
            {
                itui = o[2] as InventoryItemUI;
            }
            else
            {
                eit = o[2] as KnapsackRoleEquipItem;
            }

            equipPopup.Show(it, itui, eit, isLeft);
            inventoryPopup.Close();
        }
        else
        {
            itui = o[2] as InventoryItemUI;
            inventoryPopup.Show(it, itui);
            equipPopup.Close();
        }

        //可以出售的情况
        if (isLeft == true)
        {
            EnableSellBtn();
            this.itui = o[2] as InventoryItemUI;

            sellPriceLabel.text = (this.itui.it.Inventory.Price * this.itui.it.Count).ToString();
        }
    }
Beispiel #7
0
    /// <summary>
    /// 物品点击事件。被点击的物品上传到这里,KnapsackRoleEquip和InventoryItemUI里面的OnPress(sendmessage过来的)
    /// </summary>
    /// <param name="objArray"></param>
    public void OnInventoryClick(object[] objArray)
    {
        InventoryItem it = objArray[0] as InventoryItem;    //被电击的物品

        bool isLeft = (bool)objArray[1];

        if (it.inventory.InventoryTYPE == InventoryType.Equip)
        {
            InventoryItemUI   itUi   = null;
            KnapsackRoleEquip itRole = null;
            if (isLeft == true) //背包中装备
            {
                itUi = objArray[2] as InventoryItemUI;
            }
            else        //role中装备
            {
                itRole = objArray[2] as KnapsackRoleEquip;
            }
            equipPopup.Show(it, itUi, itRole, isLeft);    //show将点击的inventoryUI传进来
            inventoryPopup.Close();
        }
        else
        {
            InventoryItemUI itUI = objArray[2] as InventoryItemUI;
            inventoryPopup.Show(it, itUI);
            equipPopup.Close();
        }

        if (isLeft)    //不是role中点击的
        {
            this.itUI = objArray[2] as InventoryItemUI;
            EnableBUtn();
            priceLabel.text = "售价" + this.itUI.it.inventory.Price * this.itUI.it.Count;
        }
        else
        {
            upgradeButton.isEnabled = false;
        }
    }
        /// <summary>
        /// Validates the product inventory for items currently added in basket
        /// </summary>
        /// <param name="fixQuantity">Indicate if the quantity need to be fixed as per available stock. If no then it will only record warning messages</param>
        /// <returns>returns true if no issues found</returns>
        protected bool ValidateInventory(bool fixQuantity = false)
        {
            bool recalculateRequried = false;
            // VALIDATE INVENTORY
            List <string> warningMessages = new List <string>();

            if (_StoreInventoryEnabled)
            {
                Dictionary <string, InventoryInfo> inventories = new Dictionary <string, InventoryInfo>();
                string        tempMessage;
                InventoryInfo info;
                foreach (BasketItem item in _Basket.Items)
                {
                    if (item.OrderItemType != OrderItemType.Product || item.IsChildItem)
                    {
                        continue;
                    }
                    info = GetInventoryInfo(inventories, item);
                    bool enforceInv = info.InventoryStatus.InventoryMode != InventoryMode.None &&
                                      info.InventoryStatus.AllowBackorder == false;
                    if (enforceInv)
                    {
                        // inventory needs to be enforced
                        if (item.Quantity > info.NowAvailable)
                        {
                            if (fixQuantity)
                            {
                                if (info.NowAvailable < 1)
                                {
                                    item.Quantity = 0;
                                }
                                else
                                {
                                    item.Quantity = (short)info.NowAvailable;
                                }
                                item.Save();

                                recalculateRequried = true;
                            }
                            else
                            {
                                tempMessage = GetInventoryStockMessage(item, info);
                                warningMessages.Add(tempMessage);
                            }
                        }

                        // if this was a kit product and some quanity of it getting included
                        // update the inventories for all its component products
                        if (item.Product.KitStatus == KitStatus.Master && item.Quantity > 0)
                        {
                            InventoryInfo info1;
                            foreach (InventoryManagerData invd1 in info.InventoryStatus.ChildItemInventoryData)
                            {
                                info1 = inventories[invd1.ProductId + "_" + invd1.OptionList + "_"];
                                if (invd1.InventoryMode != InventoryMode.None &&
                                    invd1.AllowBackorder == false)
                                {
                                    // ensure that none of the component product exceeds inventory
                                    int effectiveQuantity = item.Quantity * invd1.Multiplier;
                                    if (effectiveQuantity > info1.NowAvailable)
                                    {
                                        if (fixQuantity)
                                        {
                                            if (info1.NowAvailable < 1)
                                            {
                                                item.Quantity = 0;
                                            }
                                            else
                                            {
                                                item.Quantity = (short)(info1.NowAvailable / invd1.Multiplier);
                                            }
                                        }
                                        else
                                        {
                                            tempMessage = GetInventoryStockMessage(item, info1);
                                            warningMessages.Add(tempMessage);
                                        }
                                    }
                                    info1.NowAvailable -= item.Quantity * invd1.Multiplier;
                                    inventories[invd1.ProductId + "_" + invd1.OptionList + "_"] = info1;
                                }
                            }
                        }

                        info.NowAvailable -= item.Quantity;
                    }

                    int curQty = item.Quantity;
                    tempMessage = ValidateMinMaxLimits(item, info);
                    if (!string.IsNullOrEmpty(tempMessage))
                    {
                        warningMessages.Add(tempMessage);
                        if (enforceInv)
                        {
                            info.NowAvailable += curQty - item.Quantity;
                        }
                    }
                }

                // CHECK IF WE NEED TO DISPLAY THE WARNINGS
                if (!fixQuantity && warningMessages.Count > 0)
                {
                    InventoryMessages.DataSource = warningMessages;
                    InventoryMessages.DataBind();
                    InventoryPopup.Show();
                }
                else if (warningMessages.Count > 0)
                {
                    InventoryPopup.Hide();
                    // save the basket
                    _Basket.Save();
                }
            }

            if (recalculateRequried)
            {
                IBasketService service = AbleContext.Resolve <IBasketService>();
                service.Combine(_Basket);
                service.Recalculate(_Basket);
            }

            return(warningMessages.Count == 0);
        }