/// <summary> /// 只有经验药水有用 /// </summary> /// <param name="id">商品参数 id</param> /// <returns>商品一行数值表</returns> public ShopTemplate GetShopTemplateByParaID(int id) { foreach (var item in m_ShopTable.getDataList()) { ShopTemplate shop = ( ShopTemplate )item; if (int.Parse(shop.getPara()) == id) { return(shop); } } return(null); }
public override void InitUIView() { base.InitUIView(); if (data != null) { _shopT = DataTemplate.GetInstance().GetShopTemplateByID(data.shopId); iconImg.sprite = UIResourceMgr.LoadSprite(common.defaultPath + ShopT.getResourceName()); //iconImg.SetNativeSize(); nameTxt.text = GameUtils.getString(ShopT.getCommodityName()); oneCostImg.sprite = GameUtils.GetSpriteByResourceType(ShopT.getCostType()); totalCostImg.sprite = GameUtils.GetSpriteByResourceType(ShopT.getCostType()); //判断当前时间是否打折期间---与购买商品时候是否打折进行比对,如果不同,购买失败,让玩家从新购买; isDiscount = ShopModule.IsShopItemInDiscount(ShopT); if (isDiscount) { perPrice = ShopT.getDiscountCost()[0]; } else { perPrice = ShopT.getCost()[0]; } oneCostTxt.text = perPrice.ToString(); totalCostTxt.text = (ItemCount * perPrice).ToString(); maxCount = GetMaxCount(); ItemCount = Mathf.Min(1, maxCount); moneyIcon.sprite = GameUtils.GetSpriteByResourceType(ShopT.getCostType()); switch (ShopT.getCostType()) { case (int)EM_RESOURCE_TYPE.Gold: GameEventDispatcher.Inst.addEventListener(GameEventID.G_Gold_Update, UpdateTotalGoldInfo); UpdateTotalGoldInfo(); break; case (int)EM_RESOURCE_TYPE.Money: GameEventDispatcher.Inst.addEventListener(GameEventID.G_Money_Update, UpdateTotalMoneyInfo); UpdateTotalMoneyInfo(); break; } int curCount = -1; if (ObjectSelf.GetInstance().TryGetItemCountById(EM_BAG_HASHTABLE_TYPE.EM_BAG_HASHTABLE_TYPE_COMMON, Convert.ToInt32(_shopT.getPara()), ref curCount)) { curCountTxt.text = curCount + ""; } } }