// 自动买药 public bool OnAutoBuyDrug(int nId) { bool IsBuy = false; int ShopId = 3; int itemIdex = -1; Tab_SystemShop curShop = TableManager.GetSystemShopByID(ShopId, 0); if (curShop != null) { for (int i = 0; i < curShop.Pnum; i++) { if (nId == curShop.GetPidbyIndex(i)) { IsBuy = true; itemIdex = i; break; } } if (IsBuy) //可以买 { CG_SYSTEMSHOP_BUY buyPacket = (CG_SYSTEMSHOP_BUY)PacketDistributed.CreatePacket(MessageID.PACKET_CG_SYSTEMSHOP_BUY); buyPacket.SetBuyNum(1); buyPacket.SetShopId(ShopId); buyPacket.SetMercIndex(itemIdex); buyPacket.SendPacket(); } } return(true); }
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 void AddItem(GameObject curItem, int index, int shopIndex, Tab_SystemShop tabSysShop) { if (null == curItem) { return; } //curItem.transform.localPosition = new Vector3(xStartPos + widthDiff * (index % 2), yStartPos - heightDiff * (index /2)); SysShopPageItem shopPageItem = curItem.GetComponent <SysShopPageItem>(); if (null != shopPageItem) { shopPageItem.SetData(ChildItemClick, ChildItemDoubleClick, ChildItemIconClick, shopIndex, tabSysShop); } }
// 购买物品 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(); }
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; }
void InitShopPageInfo(List <GameObject> pageList, int shopID, GameObject BindObject) { Obj_MainPlayer mainPlayer = Singleton <ObjManager> .Instance.MainPlayer; if (null == mainPlayer) { LogModule.ErrorLog("main player is not init"); return; //yield break; } pageList.Clear(); GameObject curPage = null; GameObject curPageItem = null; // 根据表格配置,初始化ITEM Tab_SystemShop curShopTable = TableManager.GetSystemShopByID(shopID, 0); int curItemIndex = 0; // 除去无效物品,实际物品ID int curShowPage = 0; for (int i = 0, count = curShopTable.getPidCount(); i < count; i++) { //yield return null; Tab_CommonItem curTabItem = TableManager.GetCommonItemByID(curShopTable.GetPidbyIndex(i), 0); if (null != curTabItem) { if (curItemIndex % PAGEITEMCOUNT_MAX == 0) { curPage = Utils.BindObjToParent(m_PageItem, BindObject); pageList.Add(curPage); curPage.name = i.ToString(); curPage.GetComponent <SysShopPage>().SetPageNum(curItemIndex / PAGEITEMCOUNT_MAX); } // 显示适用等级的最后一页 if (curTabItem.MinLevelRequire <= mainPlayer.BaseAttr.Level && shopID == GOLD_SHOP_ID) { curShowPage = pageList.Count - 1; } GameObject newCurPageBindObject = null; newCurPageBindObject = curPage.GetComponent <SysShopPage>().ShopItemGirdObject; curPageItem = Utils.BindObjToParent(m_ShopItem, newCurPageBindObject); curPageItem.name = i.ToString(); curPage.GetComponent <SysShopPage>().AddItem(curPageItem, curItemIndex % PAGEITEMCOUNT_MAX, i, curShopTable); curItemIndex++; } else { LogModule.DebugLog("systemshop:can not find cur item in item table, item id:" + curShopTable.GetPidbyIndex(i)); } // UIGrid[] gridArray = m_SysShowPageRoot.gameObject.GetComponentsInChildren<UIGrid>(); // for (int j = 0; j < gridArray.Length; j++) // { // gridArray[j].repositionNow = true; // } // m_SysShowPageRoot.repositionNow = true; } if (shopID == GOLD_SHOP_ID) { CurShopType = ShopTypeEnum.GoldMoneyShop; m_pageList = pageListForGoldShop; } else if (shopID == DIANQUAN_SHOP_ID) { CurShopType = ShopTypeEnum.DianQuanShop; m_pageList = pageListForDianQuanShop; } ShowPage(curShowPage); }