Пример #1
0
    //获取需要购买的资源数量
    public static int GetNeedBuyOilCount(int resCount)
    {
        int result = -1;

        result = ConnectionValidateHelper.IsEnoughOilUse(resCount);
        if (result != 0)
        {
            result = resCount - InstancePlayer.instance.model_User.model_Resource.GetIntOil();
        }
        else
        {
            result = 0;
        }
        return(result);
    }
Пример #2
0
    void ResData()
    {
        if (_tankRepairItemDic != null)
        {
            int foodCount  = 0;
            int oilCount   = 0;
            int matelCount = 0;
            int rareCount  = 0;
            int timeCount  = 0;
            int cashCount  = 0;

            foreach (KeyValuePair <int, TankRepairItem> kv in _tankRepairItemDic)
            {
                TankRepairItem        tankItem    = kv.Value;
                Dictionary <int, int> resCountDic = tankItem.GetResCountDic();
                int res_1 = 0;
                resCountDic.TryGetValue(1, out res_1);
                foodCount = foodCount + res_1;

                int res_2 = 0;
                resCountDic.TryGetValue(2, out res_2);
                oilCount = oilCount + res_2;

                int res_3 = 0;
                resCountDic.TryGetValue(3, out res_3);
                matelCount = matelCount + res_3;

                int res_4 = 0;
                resCountDic.TryGetValue(4, out res_4);
                rareCount = rareCount + res_4;

                int res_5 = 0;
                resCountDic.TryGetValue(5, out res_5);
                timeCount = timeCount + res_5;

                int res_6 = 0;
                resCountDic.TryGetValue(6, out res_6);
                cashCount = cashCount + res_6;
            }

            if (_allResCountDic != null)
            {
                _allResCountDic.Clear();
                _allResCountDic.Add(1, foodCount);
                _allResCountDic.Add(2, oilCount);
                _allResCountDic.Add(3, matelCount);
                _allResCountDic.Add(4, rareCount);
                _allResCountDic.Add(5, timeCount);
                _allResCountDic.Add(6, cashCount);
            }
        }

        if (_allResCountDic != null)
        {
            int allTime;
            _allResCountDic.TryGetValue(5, out allTime);
            _RepairTime_Value.text = UIHelper.setTimeDHMS(Mathf.RoundToInt(allTime)).ToString();

            int allCash;
            _allResCountDic.TryGetValue(6, out allCash);
            _immediatelyRepair_CoinValue.text = (int)allCash + "";

            for (int i = 1; i <= 4; i++)
            {
                int resNum = 0;
                _allResCountDic.TryGetValue(i, out resNum);
                int requst = -1;
                if (i == 1)
                {
                    requst = ConnectionValidateHelper.IsEnoughFoodUse((int)resNum);
                    if (requst == 0)
                    {
                        _resLabelList[i - 1].text = Mathf.RoundToInt(resNum).ToString() + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaFoodRes());
                    }
                    else
                    {
                        _resLabelList[i - 1].text = UIHelper.SetStringColor(Mathf.RoundToInt(resNum).ToString()) + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaFoodRes());
                    }
                }
                else if (i == 2)
                {
                    requst = ConnectionValidateHelper.IsEnoughOilUse((int)resNum);
                    if (requst == 0)
                    {
                        _resLabelList[i - 1].text = Mathf.RoundToInt(resNum).ToString() + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaOilRes());
                    }
                    else
                    {
                        _resLabelList[i - 1].text = UIHelper.SetStringColor(Mathf.RoundToInt(resNum).ToString()) + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaOilRes());
                    }
                }
                else if (i == 3)
                {
                    requst = ConnectionValidateHelper.IsEnoughMetalUse((int)resNum);
                    if (requst == 0)
                    {
                        _resLabelList[i - 1].text = Mathf.RoundToInt(resNum).ToString() + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaMatelRes());
                    }
                    else
                    {
                        _resLabelList[i - 1].text = UIHelper.SetStringColor(Mathf.RoundToInt(resNum).ToString()) + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaMatelRes());
                    }
                }
                else if (i == 4)
                {
                    requst = ConnectionValidateHelper.IsEnoughRareUse((int)resNum);
                    if (requst == 0)
                    {
                        _resLabelList[i - 1].text = Mathf.RoundToInt(resNum).ToString() + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaRareRes());
                    }
                    else
                    {
                        _resLabelList[i - 1].text = UIHelper.SetStringColor(Mathf.RoundToInt(resNum).ToString()) + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaRareRes());
                    }
                }
            }
        }
    }