Пример #1
0
    //==================================================================

    void QuickBuy()
    {
        QuickBuyRequest request = new QuickBuyRequest();

        request.api = new Model_ApiRequest().api;

        int [] types = new [] {
            (int)Model_Production.Production_Type.Food,
            (int)Model_Production.Production_Type.Oil,
            (int)Model_Production.Production_Type.Metal,
            (int)Model_Production.Production_Type.Rare,
        };

        for (int i = 0; i < 4; i++)
        {
            Production product = new Production();
            product.resourceType = types[i];
            product.num          = _resArr[i];
            if (_resArr[i] != 0)
            {
                request.buy.Add(product);
            }
        }
        int needCash = Model_Helper.GetResourcesNeedCash((float)_resArr[0], (float)_resArr[1], (float)_resArr[2], (float)_resArr[3]);

        if (ConnectionValidateHelper.IsEnoughCashBuyResources(needCash) == 0)
        {
            UIHelper.LoadingPanelIsOpen(true);
            (new PBConnect_quickBuy()).Send(request, OnQuickBuy);
        }
        else
        {
            UIHelper.BuyCashUI();
        }
    }
Пример #2
0
 // 立即训练
 public void OnOnceTrain()
 {
     if (_dataUnit != null)
     {
         int cdCashCount  = Mathf.CeilToInt(_currentTankCount * _dataUnit.costCdCash);
         int isProduction = ConnectionValidateHelper.IsEnoughCashBuyResources(cdCashCount);
         if (isProduction == 0)
         {
             SpeedAddUnit();
         }
         else
         {
             UIHelper.BuyCashUI();
         }
     }
 }
Пример #3
0
    //  立即维修
    void OnImmediatelyRepair()
    {
        int allCash;

        _allResCountDic.TryGetValue(6, out allCash);
        int requst = ConnectionValidateHelper.IsEnoughCashBuyResources((int)allCash);

        if (requst == 0)
        {
            ImmediatelyRepairUnit();
        }
        else
        {
            UIHelper.BuyCashUI();
        }
    }