Exemple #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]);
    }