コード例 #1
0
ファイル: DataTemplate.cs プロジェクト: ww386362087/MoyuHero
    /// <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]);
    }
コード例 #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();
    }
コード例 #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"));
        }
    }