Exemplo n.º 1
0
    public void updateItem(NoticeActiveGoods goods, NoticeSample sample)
    {
        NoticeActiveServerInfo serverInfo = fatherContent.serverInfo;

        activeGoods = goods;
        //2014.7.17 modified
        //conditionDes.text = Language ("ConsumeRebate_01", activeGoods.getSample().rmbCondition,
        //                             Mathf.Min (serverInfo.consumeValue, activeGoods.getSample().rmbCondition), activeGoods.getSample().rmbCondition);
        conditionDes.text = Language("ConsumeRebate_01", activeGoods.getSample().rmbCondition,
                                     activeGoods.getRoleCountCanBuy(), activeGoods.getSample().maxBuyCount);
        costNumLabel.text    = "X " + activeGoods.getCostPrice();
        totalCountLabel.text = Language("ConsumeRebate_04", activeGoods.getServerCountCanBuy());
        //maxBuyLabel.text = Language ("ConsumeRebate_03", activeGoods.getRoleCountCanBuy (), activeGoods.getSample().maxBuyCount);
        maxBuyLabel.text = Language("ConsumeRebate_03", activeGoods.getSample().rmbCondition - serverInfo.consumeValue > 0 ? activeGoods.getSample().rmbCondition - serverInfo.consumeValue : 0);
        if (goodsShowPos.transform.childCount > 0)
        {
            goodsShowPos.transform.GetChild(0).GetComponent <GoodsView> ().init(activeGoods.getGoodsType(), activeGoods.getGoodsSid(), activeGoods.getGoodsShowNum());
        }
        else
        {
            GoodsView goodsView = (NGUITools.AddChild(goodsShowPos, goodsViewPref) as GameObject).GetComponent <GoodsView> ();
            goodsView.init(activeGoods.getGoodsType(), activeGoods.getGoodsSid(), activeGoods.getGoodsShowNum());
            goodsView.fatherWindow = fatherContent.win;
        }
        if (activeGoods.getRoleCountCanBuy() < 1 || activeGoods.getServerCountCanBuy() < 1)
        {
            buyButton.disableButton(true);
        }
        else
        {
            buyButton.disableButton(false);
            buyButton.fatherWindow = fatherContent.win;
            buyButton.onClickEvent = clickBuyButton;
        }
    }
    //serverInfo=[[400000000商品id,1全服已购买次数]],userInfo=[[[consume_rmb类型,200活动期间消耗]暂时只有一个],[[[role_times,400000000],1]个人消耗次数,...]]
    private void initConsumeRebateGoods(int activeID, ErlArray serverInfo, ErlArray userInfo)
    {
        NoticeActiveServerInfo consumeInfo = activeInfo.get(activeID) as NoticeActiveServerInfo;

        if (consumeInfo == null)
        {
            consumeInfo = new NoticeActiveServerInfo();
            activeInfo.put(activeID, consumeInfo);
        }
        ErlArray          temp, temp1;
        NoticeActiveGoods goods;
        int sid;

        for (int i = 0; i < serverInfo.Value.Length; i++)
        {
            temp  = serverInfo.Value[i] as ErlArray;
            sid   = StringKit.toInt(temp.Value[0].getValueString());
            goods = consumeInfo.goodsList.get(sid) as NoticeActiveGoods;
            if (goods == null)
            {
                goods        = new NoticeActiveGoods(sid);
                goods.timeID = activeID;
                consumeInfo.goodsList.put(sid, goods);
            }
            goods.serverBuyCount = StringKit.toInt(temp.Value[1].getValueString());
        }
        if (userInfo.Value.Length > 0)
        {
            temp = (userInfo.Value[0] as ErlArray);
            if (temp.Value.Length > 0)
            {
                consumeInfo.consumeValue = StringKit.toInt((temp.Value[0] as ErlArray).Value[1].getValueString()); //兑换rmb消耗入门限制
            }
            temp = userInfo.Value[1] as ErlArray;
            for (int i = 0; i < temp.Value.Length; i++)
            {
                temp1 = temp.Value[i] as ErlArray;
                sid   = StringKit.toInt((temp1.Value[0] as ErlArray).Value[1].getValueString());
                goods = consumeInfo.goodsList.get(sid) as NoticeActiveGoods;
                if (goods == null)
                {
                    goods        = new NoticeActiveGoods(sid);
                    goods.timeID = activeID;
                    consumeInfo.goodsList.put(sid, goods);
                }
                goods.roleBuyCount = StringKit.toInt(temp1.Value[1].getValueString());
            }
        }
    }
    public List <NoticeActiveGoods> getGoodsList(NoticeActiveAndSid[] actives)
    {
        List <NoticeActiveGoods> list = new List <NoticeActiveGoods>();
        NoticeActiveServerInfo   serverInfo;
        NoticeActiveGoods        goods;

        foreach (NoticeActiveAndSid active in actives)
        {
            serverInfo = activeInfo.get(active.activeID) as NoticeActiveServerInfo;
            foreach (int sid in active.exchangeSids)
            {
                goods = serverInfo.goodsList.get(sid) as NoticeActiveGoods;
                if (goods == null)
                {
                    goods        = new NoticeActiveGoods(sid);
                    goods.timeID = active.activeID;
                    serverInfo.goodsList.put(sid, goods);
                }
                list.Add(goods);
            }
        }
        return(list);
    }