// 自动买药 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 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; }
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); } }
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); }