Example #1
0
    public void SetData(ItemClickDelegate clickFun, ItemClickDelegate doubleClickFun, ItemClickDelegate iconClickFun, int shopIndex, Tab_SystemShop tabSysShop)
    {
        if (tabSysShop == null)
        {
            return;
        }
        delItemClick       = clickFun;
        delItemDoubleClick = doubleClickFun;
        delItemIconClick   = iconClickFun;
        int pid = tabSysShop.GetPidbyIndex(shopIndex);

        LabelMoney.text = tabSysShop.GetPricebyIndex(shopIndex).ToString();
        Tab_CommonItem curTabItem = TableManager.GetCommonItemByID(pid, 0);

        if (null == curTabItem)
        {
            LogModule.WarningLog("can not read cur common item talbe :" + pid.ToString());
            return;
        }

        int groupCount = tabSysShop.GetNumPerGroupbyIndex(shopIndex);

        if (groupCount < 0)
        {
            groupCount = 1;
        }

        LabelName.text     = curTabItem.Name;// +"*" + groupCount.ToString();
        sprIcon.spriteName = curTabItem.Icon;
        int colorQuality = curTabItem.Quality - 1;

        if (colorQuality >= 0 && colorQuality < GlobeVar.QualityColorGrid.Length)
        {
            QualitySprite.spriteName = GlobeVar.QualityColorGrid[curTabItem.Quality - 1];
        }


        int moneyType    = tabSysShop.GetMoneyTypebyIndex(shopIndex);
        int moneySubType = tabSysShop.GetMoneySubTypebyIndex(shopIndex);

        if (moneyType == (int)Consume_Type.COIN)
        {
            MoneyIcon.spriteName = "qian5";
        }
        else if (moneyType == (int)Consume_Type.YUANBAO)
        {
            if (moneySubType == (int)Consume_SubType.YUANBAO_NORMAL)
            {
                MoneyIcon.spriteName = "qian2";
            }
            else if (moneySubType == (int)Consume_SubType.YUANBAO_BIND)
            {
                MoneyIcon.spriteName = "qian3";
            }
        }

        m_curGameItem        = new GameItem();
        m_curGameItem.DataID = pid;
    }
Example #2
0
    public void OnClickBuy(GameObject obj)
    {
        Tab_SystemShop sysShopTable = TableManager.GetSystemShopByID(WorldVoiceSysShopId, 0);

        if (sysShopTable != null && sysShopTable.CanBuyMulty > 0)
        {
            int            ciid        = sysShopTable.GetPidbyIndex(WorldVoiceIndex);
            string         medicalName = "World Voice";
            Tab_CommonItem tcitem      = TableManager.GetCommonItemByID(ciid, 0);
            if (tcitem == null)
            {
                return;
            }
            else
            {
                medicalName = tcitem.Name;
            }

//		Tab_CommonItem buyItem = TableManager.GetCommonItemByID(WorldVoiceIndex, 0);
//		medicalName = buyItem.Name;
            string goldMoneyShopTitle      = StrDictionary.GetClientDictionaryString("#{10955}", medicalName);
            string goldMoneyShopTotalTitle = StrDictionary.GetClientDictionaryString("#{2837}");
            string oktitle      = StrDictionary.GetClientDictionaryString("#{2837}");
            string currencyIcon = string.Empty;
            int    moneyType    = sysShopTable.GetMoneyTypebyIndex(WorldVoiceIndex);
            int    moneySubType = sysShopTable.GetMoneySubTypebyIndex(WorldVoiceIndex);
            int    price        = sysShopTable.GetPricebyIndex(WorldVoiceIndex);
//		int moneyType = 1;
//		int moneySubType = buyItem.SellMoneyType;
//		int price = buyItem.SellPrice;
            int stepPerClick = 1;
            if (moneyType == (int)Consume_Type.COIN)
            {
                currencyIcon = "qian5";
                stepPerClick = 10;
            }
            else if (moneyType == (int)Consume_Type.YUANBAO)
            {
                if (moneySubType == (int)Consume_SubType.YUANBAO_NORMAL)
                {
                    currencyIcon = "qian2";
                }
                else if (moneySubType == (int)Consume_SubType.YUANBAO_BIND)
                {
                    currencyIcon = "qian3";
                }
            }
            NumChooseController.OpenWindow(1, 999, goldMoneyShopTitle, OnNumChoose, stepPerClick, goldMoneyShopTotalTitle, oktitle,
                                           true, "", currencyIcon, price);
        }
        else
        {
            MessageBoxLogic.OpenOKBox(1004, 1000);
        }
    }
    // 批量购买当前选中物品
    public void BuyBatchCurItem()
    {
        CloseCurItemTip();
        if (null != m_curShowPage)
        {
            SysShopPage curPage = m_curShowPage.GetComponent <SysShopPage>();
            if (curPage == null || curPage.GetCurHighLightItem() == null)
            {
                return;
            }

            Tab_SystemShop sysShopTable = TableManager.GetSystemShopByID(m_curShopID, 0);

            if (sysShopTable != null && sysShopTable.CanBuyMulty > 0)
            {
                string medicalName             = curPage.GetCurHighLightItem().LabelName.text;
                string goldMoneyShopTitle      = StrDictionary.GetClientDictionaryString("#{10955}", medicalName);
                string goldMoneyShopTotalTitle = StrDictionary.GetClientDictionaryString("#{2837}");
                string oktitle      = StrDictionary.GetClientDictionaryString("#{2837}");
                int    index        = int.Parse(curPage.GetCurHighLightItem().gameObject.name);
                string currencyIcon = string.Empty;
                int    moneyType    = sysShopTable.GetMoneyTypebyIndex(index);
                int    moneySubType = sysShopTable.GetMoneySubTypebyIndex(index);
                int    stepPerClick = 1;
                if (moneyType == (int)Consume_Type.COIN)
                {
                    currencyIcon = "qian5";
                    stepPerClick = 10;
                }
                else if (moneyType == (int)Consume_Type.YUANBAO)
                {
                    if (moneySubType == (int)Consume_SubType.YUANBAO_NORMAL)
                    {
                        currencyIcon = "qian2";
                    }
                    else if (moneySubType == (int)Consume_SubType.YUANBAO_BIND)
                    {
                        currencyIcon = "qian3";
                    }
                }
                NumChooseController.OpenWindow(ITEMCOUNT_MIN, ITEMCOUNT_MAX, goldMoneyShopTitle, OnNumChoose, stepPerClick, goldMoneyShopTotalTitle, oktitle,
                                               true, "", currencyIcon, sysShopTable.GetPricebyIndex(index));
            }
            else
            {
                MessageBoxLogic.OpenOKBox(1004, 1000);
            }
        }
    }
    // 购买物品
    public static void BuyItem(string strItemIndex, int count)
    {
        int  curItemIndex;
        bool bCanGetID = int.TryParse(strItemIndex, out curItemIndex);

        if (!bCanGetID)
        {
            LogModule.ErrorLog("cur item id set error!");
            return;
        }

        Tab_SystemShop sysShopTable = TableManager.GetSystemShopByID(m_curShopID, 0);

        if (null == sysShopTable)
        {
            LogModule.ErrorLog("cur sysshop id isn't exist! : id " + m_curShopID.ToString());
            return;
        }

        int pid = sysShopTable.GetPricebyIndex(curItemIndex);

        if (pid < 0)
        {
            LogModule.ErrorLog("can not find cur item pid : itemID" + pid.ToString());
            return;
        }

        if (count < ITEMCOUNT_MIN || count > ITEMCOUNT_MAX)
        {
            LogModule.ErrorLog("item count is out range : count " + count.ToString());
            return;
        }

        CG_SYSTEMSHOP_BUY buyPacket = (CG_SYSTEMSHOP_BUY)PacketDistributed.CreatePacket(MessageID.PACKET_CG_SYSTEMSHOP_BUY);

        buyPacket.SetBuyNum(count);
        buyPacket.SetShopId(m_curShopID);
        buyPacket.SetMercIndex(curItemIndex);
        buyPacket.SendPacket();
    }