Beispiel #1
0
    /// <summary>
    /// 根据商店物品购买次数获得下次购买需要消耗的资源数;
    /// </summary>
    /// <param name="shopT"></param>
    /// <param name="buyTimes"></param>
    /// <param name="isDiscount"></param>
    /// <returns></returns>
    public int GetShopBuyCost(ShopTemplate shopT, int buyTimes, bool isDiscount = false)
    {
        if (shopT == null || buyTimes < 0)
        {
            return(-1);
        }

        int [] costs = null;

        if (isDiscount)
        {
            costs = shopT.getDiscountCost();
        }
        else
        {
            costs = shopT.getCost();
        }

        if (costs == null)
        {
            Debug.LogError("shop表格数据错误,id=" + shopT.getId() + "的消费数据处错误");
            return(-1);
        }

        if (buyTimes >= costs.Length)
        {
            return(costs [costs.Length - 1]);
        }

        return(costs [buyTimes]);
    }
Beispiel #2
0
    public void ShowInfo(int tableid)
    {
        m_Tableid = tableid;

        m_ShopTemp = DataTemplate.GetInstance().GetShopTemplateByParaID(m_Tableid);


        // icon
        m_Item        = ( ItemTemplate )DataTemplate.GetInstance().m_ItemTable.getTableData(tableid);
        m_Icon.sprite = UIResourceMgr.LoadSprite(common.defaultPath + m_Item.getIcon_s());

        int number = 0;

        ObjectSelf.GetInstance().TryGetItemCountById(EM_BAG_HASHTABLE_TYPE.EM_BAG_HASHTABLE_TYPE_COMMON, tableid, ref number);
        m_UI_Text_Count.text = number.ToString();

        m_UI_Text_Name.text = GameUtils.getString(m_Item.getName());

        m_UI_Text_Num.text = m_Number.ToString();

        m_UI_Text_Total.text = (m_Number * m_ShopTemp.getCost() [0]).ToString();
    }
Beispiel #3
0
    protected virtual void OnClickUI_Btn_Add()
    {
        if (m_Number < 100)
        {
            m_Number++;
            m_UI_Text_Num.text   = m_Number.ToString();
            m_UI_Text_Total.text = (m_Number * m_ShopTemp.getCost() [0]).ToString();

            if (ObjectSelf.GetInstance().Gold < m_Number * m_ShopTemp.getCost() [0])
            {
                m_UI_Text_Total.color = Color.red;
            }
            else
            {
                m_UI_Text_Total.color = Color.white;
            }
        }
        else
        {
            InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("ui_yingxiongqianghua_shengji8"));
        }
    }