예제 #1
0
    void OnSpeed()
    {
        int requst = ConnectionValidateHelper.IsEnoughCashClearBuildUnitCD(_model_User, _model_unit.unitId);

        if (requst == 0)
        {
            if (_model_unit != null)
            {
                FinishAddUnit();
            }
        }
        else
        {
            UIHelper.BuyCashUI();
        }
    }
예제 #2
0
    //获取加速生产所需的金币数
    public static int GetClearUnitCDNeedCash(Model_User model_user, int unitId)
    {
        int result = -1;

        result = ConnectionValidateHelper.IsEnoughCashClearBuildUnitCD(model_user, unitId);

        if (result != 0)
        {
            Model_Unit model_Unit;
            model_user.unlockUnits.TryGetValue(unitId, out model_Unit);
            float needCash = model_user.model_InitialConfig.GetClearUnitCDCash(model_Unit.produceLeftTime);
            float userCash = model_user.model_Resource.cash;
            if (userCash < needCash)
            {
                result = Mathf.CeilToInt(needCash - userCash);
            }
        }
        else
        {
            result = 0;
        }
        return(result);
    }