Пример #1
0
    public void OnFactoryProductClick(CUIEvent uiEvent)
    {
        ListView <CMallFactoryShopController.ShopProduct> products = Singleton <CMallFactoryShopController> .GetInstance().GetProducts();

        if (products == null)
        {
            stUIEventParams par = new stUIEventParams {
                tag = 1
            };
            Singleton <CUIEventManager> .GetInstance().DispatchUIEvent(enUIEventID.Mall_Open_Factory_Shop_Tab, par);
        }
        else if ((uiEvent.m_eventParams.tag < 0) || (uiEvent.m_eventParams.tag >= products.Count))
        {
            Singleton <CUIManager> .GetInstance().OpenMessageBox("internal error: out of index range.", false);
        }
        else
        {
            CMallFactoryShopController.ShopProduct shopProduct = products[uiEvent.m_eventParams.tag];
            if (shopProduct.CanBuy())
            {
                if ((shopProduct.Type == COM_ITEM_TYPE.COM_OBJTYPE_HERO) || (shopProduct.Type == COM_ITEM_TYPE.COM_OBJTYPE_HEROSKIN))
                {
                    CUIEvent event2 = new CUIEvent {
                        m_eventID = enUIEventID.Mall_Boutique_Factory_Product_Confirm_Buy
                    };
                    event2.m_eventParams.commonUInt64Param1 = shopProduct.Key;
                    event2.m_eventParams.commonUInt32Param1 = 1;
                    Singleton <CMallFactoryShopController> .GetInstance().BuyShopProduct(shopProduct, 1, false, event2);
                }
                else
                {
                    CUseable useableByBaseID = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo().GetUseableContainer(enCONTAINER_TYPE.ITEM).GetUseableByBaseID(shopProduct.Type, shopProduct.ID);

                    uint maxCount = 0;
                    if (shopProduct.LimitCount > 0)
                    {
                        maxCount = shopProduct.LimitCount - shopProduct.BoughtCount;
                    }
                    if (useableByBaseID != null)
                    {
                        uint num2 = (uint)(useableByBaseID.m_stackMax - useableByBaseID.m_stackCount);
                        if ((num2 < maxCount) || (maxCount == 0))
                        {
                            maxCount = num2;
                        }
                    }
                    CUIEvent uieventPars = new CUIEvent {
                        m_eventID = enUIEventID.Mall_Boutique_Factory_Product_Confirm_Buy
                    };
                    uieventPars.m_eventParams.commonUInt64Param1 = shopProduct.Key;
                    BuyPickDialog.Show(shopProduct.Type, shopProduct.ID, shopProduct.CoinType, shopProduct.RealDiscount, maxCount, new BuyPickDialog.OnConfirmBuyDelegate(Singleton <CMallFactoryShopController> .GetInstance().BuyShopProduct), shopProduct, null, uieventPars);
                }
            }
        }
    }
    public void OnFactoryProductClick(CUIEvent uiEvent)
    {
        ListView <CMallFactoryShopController.ShopProduct> products = Singleton <CMallFactoryShopController> .GetInstance().GetProducts();

        if (products == null)
        {
            stUIEventParams par = default(stUIEventParams);
            par.tag = 1;
            Singleton <CUIEventManager> .GetInstance().DispatchUIEvent(enUIEventID.Mall_Open_Factory_Shop_Tab, par);

            return;
        }
        if (uiEvent.m_eventParams.tag < 0 || uiEvent.m_eventParams.tag >= products.Count)
        {
            Singleton <CUIManager> .GetInstance().OpenMessageBox("internal error: out of index range.", false);

            return;
        }
        CMallFactoryShopController.ShopProduct shopProduct = products[uiEvent.m_eventParams.tag];
        if (!shopProduct.CanBuy())
        {
            return;
        }
        if (shopProduct.Type == COM_ITEM_TYPE.COM_OBJTYPE_HERO || shopProduct.Type == COM_ITEM_TYPE.COM_OBJTYPE_HEROSKIN)
        {
            CUIEvent cUIEvent = new CUIEvent();
            cUIEvent.m_eventID = enUIEventID.Mall_Boutique_Factory_Product_Confirm_Buy;
            cUIEvent.m_eventParams.commonUInt64Param1 = (ulong)shopProduct.Key;
            cUIEvent.m_eventParams.commonUInt32Param1 = 1u;
            Singleton <CMallFactoryShopController> .GetInstance().BuyShopProduct(shopProduct, 1u, false, cUIEvent);
        }
        else
        {
            CUseableContainer useableContainer = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo().GetUseableContainer(enCONTAINER_TYPE.ITEM);

            CUseable useableByBaseID = useableContainer.GetUseableByBaseID(shopProduct.Type, shopProduct.ID);
            uint     num             = 0u;
            if (shopProduct.LimitCount > 0u)
            {
                num = shopProduct.LimitCount - shopProduct.BoughtCount;
            }
            if (useableByBaseID != null)
            {
                uint num2 = (uint)(useableByBaseID.m_stackMax - useableByBaseID.m_stackCount);
                if (num2 < num || num == 0u)
                {
                    num = num2;
                }
            }
            CUIEvent cUIEvent2 = new CUIEvent();
            cUIEvent2.m_eventID = enUIEventID.Mall_Boutique_Factory_Product_Confirm_Buy;
            cUIEvent2.m_eventParams.commonUInt64Param1 = (ulong)shopProduct.Key;
            BuyPickDialog.Show(shopProduct.Type, shopProduct.ID, shopProduct.CoinType, shopProduct.RealDiscount, num, new BuyPickDialog.OnConfirmBuyDelegate(Singleton <CMallFactoryShopController> .GetInstance().BuyShopProduct), shopProduct, null, cUIEvent2);
        }
    }