public void onInitializeItem(GameObject go, int dataindex) { // 优先使用热更新的代码 if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("ShopPanelScript_hotfix", "onInitializeItem")) { ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.ShopPanelScript_hotfix", "onInitializeItem", null, go, dataindex); return; } ShopData shopItemData = _shopItemDatas[dataindex]; string[] strings = shopItemData.props.Split(':'); int id = Convert.ToInt32(strings[0]); Image goods_image = go.transform.Find("goods_image").GetComponent <Image>(); Text goods_des = go.transform.Find("goods_des").GetComponent <Text>(); GameObject goods_bg = go.transform.Find("goods_bg").gameObject; var Image_price_bg = goods_bg.transform.GetChild(0); var Image_price_bg1 = goods_bg.transform.GetChild(1); var goods_icon = Image_price_bg.transform.GetChild(0).GetComponent <Image>(); var Text_Price = Image_price_bg.transform.GetChild(1).GetComponent <Text>(); var goods_icon1 = Image_price_bg1.transform.GetChild(0).GetComponent <Image>(); var Text_Price1 = Image_price_bg1.transform.GetChild(1).GetComponent <Text>(); //首充 Image Image_first_recharge = go.transform.Find("Image_first_recharge").GetComponent <Image>(); GameObject Image_jiazeng = go.transform.Find("Image_jiazeng").gameObject; goods_des.text = shopItemData.goods_name; if (_type == 3) { for (int i = 0; i < PropData.getInstance().getPropInfoList().Count; i++) { PropInfo propInfo = PropData.getInstance().getPropInfoList()[i]; if (id == propInfo.m_id) { goods_image.sprite = Resources.Load <Sprite>("Sprites/Icon/Prop/" + propInfo.m_icon); } } } else if (_type == 2) { goods_image.sprite = Resources.Load <Sprite>("Sprites/Icon/Prop/icon_yuanbao"); if (!string.IsNullOrEmpty(shopItemData.extra_reward)) { Image_first_recharge.gameObject.SetActive(true); Image_jiazeng.gameObject.SetActive(true); Image_jiazeng.transform.GetChild(0).GetComponent <Text>().text = shopItemData.extra_reward.Split(':')[1] + "元宝"; } } else { goods_image.sprite = Resources.Load <Sprite>("Sprites/Icon/Prop/icon_jinbi"); } //设置已经首充 for (int i = 0; i < UserData.userRecharge.Count; i++) { if (UserData.userRecharge[i].goods_id == shopItemData.goods_id) { Image_first_recharge.gameObject.SetActive(false); Image_jiazeng.gameObject.SetActive(false); } } //设置第一个价格 if (_shopItemDatas[dataindex].money_type == 1) { goods_icon.sprite = Resources.Load <Sprite>("Sprites/Icon/Prop/icon_jinbi"); } else if (_shopItemDatas[dataindex].money_type == 2) { goods_icon.sprite = Resources.Load <Sprite>("Sprites/Icon/Prop/icon_yuanbao"); } else { goods_icon.sprite = Resources.Load <Sprite>("Sprites/Icon/icon_rmb_white"); } Text_Price.text = shopItemData.price + ""; //设置第二个价格 if (shopItemData.price2 > 0) { Image_price_bg1.gameObject.SetActive(true); goods_icon1.sprite = Resources.Load <Sprite>("Sprites/Icon/Prop/icon_huizhang"); Text_Price1.text = shopItemData.price2 + ""; } else { Image_price_bg1.gameObject.SetActive(false); } Button button = go.GetComponent <Button>(); button.onClick.RemoveAllListeners(); button.onClick.AddListener(delegate() { BuyGoodsPanelScript.create(_shopItemDatas[dataindex].goods_id); }); }
public static void buy(int money_type) { BuyGoodsPanelScript script = OtherData.s_buyGoodsPanelScript; BuyGoodsRequest buyGoodsRequest = LogicEnginerScript.Instance.GetComponent <BuyGoodsRequest>(); int totalPrice = 0; if (money_type == script.m_shopData.money_type) { totalPrice = script.m_shopData.price * script.m_goods_num; } else if (money_type == script.m_shopData.money_type2) { totalPrice = script.m_shopData.price2 * script.m_goods_num; } switch (money_type) { case 1: if (UserData.gold < totalPrice) { ToastScript.createToast("金币不足,请前去充值"); return; } else { buyGoodsRequest.setGoodsInfo(script.m_shopData.goods_id, script.m_goods_num, money_type); buyGoodsRequest.CallBack = script.onReceive_BuyGoods; buyGoodsRequest.OnRequest(); } break; case 2: if (UserData.yuanbao < totalPrice) { ToastScript.createToast("元宝不足,请前去充值"); return; } else { buyGoodsRequest.setGoodsInfo(script.m_shopData.goods_id, script.m_goods_num, money_type); buyGoodsRequest.CallBack = script.onReceive_BuyGoods; buyGoodsRequest.OnRequest(); } break; //人民币购买 case 3: if (!OtherData.s_canRecharge) { ToastScript.createToast("元宝购买暂未开放,敬请期待"); return; } if (UserData.IsRealName) { // ios if (OtherData.s_channelName.CompareTo("ios") == 0) { PlatformHelper.pay(PlatformHelper.GetChannelName(), "AndroidCallBack", "GetPayResult", script.SetRequest(script.m_shopData)); } // 渠道包 else if (AndroidPlatform.isShield(OtherData.s_channelName)) { if (!ChannelHelper.Is3RdLogin()) { PayTypePanelScript.create(script.m_shopData); } else { PlatformHelper.pay(PlatformHelper.GetChannelName(), "AndroidCallBack", "GetPayResult", script.SetRequest(script.m_shopData)); } } // 官方包 else { PayTypePanelScript.create(script.m_shopData); } GameObject.Destroy(script.gameObject); } else { // 部分渠道不需要做实名限制 if (ShieldShopRealName.isShield(OtherData.s_channelName)) { // ios if (OtherData.s_channelName.CompareTo("ios") == 0) { PlatformHelper.pay(PlatformHelper.GetChannelName(), "AndroidCallBack", "GetPayResult", script.SetRequest(script.m_shopData)); } // 渠道包 else if (AndroidPlatform.isShield(OtherData.s_channelName)) { if (!ChannelHelper.Is3RdLogin()) { PayTypePanelScript.create(script.m_shopData); } else { PlatformHelper.pay(PlatformHelper.GetChannelName(), "AndroidCallBack", "GetPayResult", script.SetRequest(script.m_shopData)); } } // 官方包 else { PayTypePanelScript.create(script.m_shopData); } GameObject.Destroy(script.gameObject); } else { CommonExitPanelScript commonExit = CommonExitPanelScript.create().GetComponent <CommonExitPanelScript>(); commonExit.TextContent.text = "您还未实名,无法购买"; commonExit.ButtonClose.gameObject.SetActive(true); commonExit.ButtonConfirm.onClick.AddListener(delegate() { RealNameScript.create(); GameObject.Destroy(commonExit.gameObject); }); } } break; case 4: if (UserData.medal < totalPrice) { ToastScript.createToast("徽章不足,无法购买"); return; } else { buyGoodsRequest.setGoodsInfo(script.m_shopData.goods_id, script.m_goods_num, money_type); buyGoodsRequest.CallBack = script.onReceive_BuyGoods; buyGoodsRequest.OnRequest(); } break; } }