Example #1
0
    void QuickBuy()     // 购买cash
    {
        QuickBuyRequest request = new QuickBuyRequest();

        request.api = new Model_ApiRequest().api;

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

        for (int i = 0; i < 4; i++)
        {
            Production product = new Production();
            product.resourceType = types[i];
            product.num          = 5000;

            request.buy.Add(product);
        }

        // UI 显示需要金币
        int needCash = Model_Helper.GetResourcesNeedCash(5000, 5000, 5000, 5000);

        (new PBConnect_quickBuy()).Send(request, OnQuickBuy);
    }
Example #2
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();
        }
    }
Example #3
0
    void Start()
    {
        Assert.assert(_instance == null);
        _instance = this;

        // 进入游戏屏幕常亮
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        DataManager.instance.InitData();

        if (!InstancePlayer.instance.model_User.isLogin)         // 登陆时进入
        {
            UIController.instance.CreateScene(UICommon.UI_LOGIN_SCENE);
        }
        else          //  从战斗页面退出时进入
        {
            int missionMagicId = InstancePlayer.instance.uiDataStatus.GetMissionMagicId();

            UIDataStatus.STATE page = InstancePlayer.instance.uiDataStatus.state;
            switch (page)
            {
            case UIDataStatus.STATE.CAMPAIGN:
                UIController.instance.CreatePanel(UICommon.UI_PANEL_CAMPAIGN, missionMagicId);
                break;

            case UIDataStatus.STATE.MISSION:
                UIController.instance.CreatePanel(UICommon.UI_PANEL_CAMPAIGN, missionMagicId);
                UIController.instance.CreatePanel(UICommon.UI_PANEL_MISSION, missionMagicId);
                break;

            case UIDataStatus.STATE.HERO:
                UIController.instance.CreateScene(UICommon.UI_MAIN_SCENE);
                UIController.instance.CreatePanel(UICommon.UI_PANEL_HERO);
                break;

            case UIDataStatus.STATE.BUILDING_UPGRADE:
                UIController.instance.CreateScene(UICommon.UI_MAIN_SCENE);
                break;

            case UIDataStatus.STATE.TANK_REPAIR:
                UIController.instance.CreateScene(UICommon.UI_MAIN_SCENE);
                UIController.instance.CreatePanel(UICommon.UI_PANEL_REPAIRFACTORY);
                break;

            case UIDataStatus.STATE.TECHNOLOGY:
                UIController.instance.CreateScene(UICommon.UI_MAIN_SCENE);
                break;

            case UIDataStatus.STATE.PVP:
                UIController.instance.CreateScene(UICommon.UI_MAIN_SCENE);
                UIController.instance.CreatePanel(UICommon.UI_PANEL_PVP);
                break;
            }
        }

        Model_Helper.ResumeAllTimer();
    }
Example #4
0
 private void LackResArr()
 {
     if (_resArr != null)
     {
         _resArr[0] = Model_Helper.GetNeedBuyFoodCount((int)_data_Building.cost.costFood);
         _resArr[1] = Model_Helper.GetNeedBuyOilCount((int)_data_Building.cost.costOil);
         _resArr[2] = Model_Helper.GetNeedBuyMetalCount((int)_data_Building.cost.costMetal);
         _resArr[3] = Model_Helper.GetNeedBuyRareCount((int)_data_Building.cost.costRare);
     }
 }
Example #5
0
    public void RefreshFood(Notification notification)
    {
        _refreCoins = false;
        StartCoroutine(RefreCois());
        int foodlNum = Model_Helper.GetPlayerHavaFoodRes();
        int refreNum = int.Parse(notification._data.ToString());
        int curreNum = foodlNum + refreNum;

        _AddFood_Label.text = UIHelper.SetResourcesShowFormat(curreNum);
    }
Example #6
0
 void TenOrOne(int times)
 {
     _partType        = _partType;
     _currentUnitPart = _currentUnitPart;
     _units.TryGetValue(_currentUnitData.id, out _modelUnit);
     PBConnect_upgradeUnitPart.RESULT result = PBConnect_upgradeUnitPart.CheckUpgrade(_modelUnit.unitId, (int)_partType);
     if (result == PBConnect_upgradeUnitPart.RESULT.OK)
     {
         if (times == 1)
         {
             UpgradeOneUnitPart();
         }
         else
         {
             UpgradeTenUnitPart();
         }
     }
     else if (result == PBConnect_upgradeUnitPart.RESULT.LACK_ITEM1)
     {
         string str = "材料不足";
         UIHelper.ShowTextPromptPanel(this.gameObject, str);
     }
     else if (result == PBConnect_upgradeUnitPart.RESULT.LACK_ITEM2)
     {
         string str = "材料不足";
         UIHelper.ShowTextPromptPanel(this.gameObject, str);
     }
     else if (result == PBConnect_upgradeUnitPart.RESULT.LACK_MAIN_LEVEL)
     {
         string str = "车体系统等级不足,请升级!";
         UIHelper.ShowTextPromptPanel(this.gameObject, str);
     }
     else if (result == PBConnect_upgradeUnitPart.RESULT.LACK_PLAYER_LEVEL)
     {
         string str = "部件等级超过玩家等级!";
         UIHelper.ShowTextPromptPanel(this.gameObject, str);
     }
     else if (result == PBConnect_upgradeUnitPart.RESULT.MAX_LEVEL)
     {
         string str = "部件达到最大级别!";
         UIHelper.ShowTextPromptPanel(this.gameObject, str);
     }
     else if (result == PBConnect_upgradeUnitPart.RESULT.LACK_RESOURCE)
     {
         int[] resArr = Model_Helper.GetPlayerNeedBuyRes(_currentUnitPart.cost.costFood, _currentUnitPart.cost.costOil, _currentUnitPart.cost.costMetal, _currentUnitPart.cost.costRare);
         UIHelper.BuyResourcesUI(resArr, ResourcesBuyType.StrengThenPartType, times);
     }
     else if (result == PBConnect_upgradeUnitPart.RESULT.UNIT_LOCK)
     {
         string str = "UNIT_LOCK!";
         UIHelper.ShowTextPromptPanel(this.gameObject, str);
     }
 }
Example #7
0
    public static RESULT Check(PBConnect_buyShopItem.SHOP_TYPE shopId, REQUEST_TYPE requestType)
    {
        if (requestType == REQUEST_TYPE.REFRESH)
        {
            Assert.assert(refreshCostType >= 0);

            if (!Model_Helper.HasEnoughResource(refreshCostType, refreshCostCount))
            {
                return(RESULT.LACK_RESOURCE);
            }
        }

        return(RESULT.OK);
    }
Example #8
0
    void UpdateUI()
    {
        int index = 0;

        for (int i = 0; i < _resArr.Length; i++)
        {
            int arrValue = _resArr[i];
            if (arrValue != 0)
            {
                _newdic.Add(index, _resArr[i]);
                string resName = "";
                if (i == 0)
                {
                    resName = "Food";
                }
                else if (i == 1)
                {
                    resName = "Accel";
                }
                else if (i == 2)
                {
                    resName = "Metal";
                }
                else if (i == 3)
                {
                    resName = "Rare";
                }
                _spritedic.Add(index, resName);
                index += 1;
            }
        }
        index = 0;
        for (int i = 0; i < _newdic.Count; i++)
        {
            _spriteList[i].gameObject.SetActive(true);
            _spriteList[i].spriteName = _spritedic[i];
            _labelList[i].text        = UIHelper.SetStringColor(_newdic[i].ToString());
        }

        int needCash = Model_Helper.GetResourcesNeedCash((float)_resArr[0], (float)_resArr[1], (float)_resArr[2], (float)_resArr[3]);

        _cashLabel.text = needCash + "";

        _spritedic.Clear();
        _newdic.Clear();
    }
Example #9
0
    //获取玩家缺少的资源种类及数量
    public static int[] GetPlayerNeedBuyRes(int needFood, int needOil, int needMetal, int needRare)
    {
        int[] resArr = new int[4];
        int   food   = 0;
        int   oil    = 0;
        int   metal  = 0;
        int   rare   = 0;

        food  = Model_Helper.GetNeedBuyFoodCount(needFood);
        oil   = Model_Helper.GetNeedBuyOilCount(needOil);
        metal = Model_Helper.GetNeedBuyMetalCount(needMetal);
        rare  = Model_Helper.GetNeedBuyRareCount(needRare);

        if (resArr != null)
        {
            resArr[0] = food;
            resArr[1] = oil;
            resArr[2] = metal;
            resArr[3] = rare;
        }
        return(resArr);
    }
    //	维修
    void OnRepair()
    {
        int foodCount  = 0;
        int oilCount   = 0;
        int matelCount = 0;
        int rareCount  = 0;

        _allResCountDic.TryGetValue(1, out foodCount);
        _allResCountDic.TryGetValue(2, out oilCount);
        _allResCountDic.TryGetValue(3, out matelCount);
        _allResCountDic.TryGetValue(4, out rareCount);

        int[] _resArr      = Model_Helper.GetPlayerNeedBuyRes((int)foodCount, (int)oilCount, (int)matelCount, (int)rareCount);
        bool  isNeedBuyRes = ConnectionValidateHelper.IsResourcesEnoughToUse(_resArr);

        if (isNeedBuyRes)
        {
            RepairUnit();
        }
        else
        {
            UIController.instance.CreatePanel(UICommon.UI_TIPS_BUYRES, _resArr, ResourcesBuyType.RepairTankType);
        }
    }
    public static RESULT CheckUpgrade(int unitId, int partIndex)
    {
        if (!InstancePlayer.instance.model_User.unlockUnits.ContainsKey(unitId))
        {
            return(RESULT.UNIT_LOCK);
        }

        Model_Unit modelUnit = InstancePlayer.instance.model_User.unlockUnits [unitId];
        DataUnit   dataUnit  = DataManager.instance.dataUnitsGroup.GetUnit(unitId);

        int partId        = dataUnit.partsId [partIndex];
        int partLevel     = modelUnit.partLevels[partIndex];
        int mainPartLevel = modelUnit.partLevels[0];

        DataUnitPart dataUnitPart = DataManager.instance.dataUnitPartGroup.GetPart(partId, partLevel);


        int maxLevel = DataManager.instance.dataUnitPartGroup.GetPartMaxLevel(partId);

        if (partLevel >= maxLevel)
        {
            return(RESULT.MAX_LEVEL);
        }

        if (partIndex == 0)
        {
            int playerLevel = InstancePlayer.instance.model_User.honorLevel;
            if (playerLevel < dataUnitPart.mainLevel)
            {
                return(RESULT.LACK_PLAYER_LEVEL);
            }
        }
        else
        {
            if (mainPartLevel < dataUnitPart.mainLevel)
            {
                return(RESULT.LACK_MAIN_LEVEL);
            }
        }

        int itemCount1 = InstancePlayer.instance.model_User.model_itemGroup.GetItemCount(dataUnitPart.itemCost1.id);

        if (itemCount1 < dataUnitPart.itemCost1.count)
        {
            return(RESULT.LACK_ITEM1);
        }

        int itemCount2 = InstancePlayer.instance.model_User.model_itemGroup.GetItemCount(dataUnitPart.itemCost2.id);

        if (itemCount2 < dataUnitPart.itemCost2.count)
        {
            return(RESULT.LACK_ITEM2);
        }


        bool hasEnoughResource = Model_Helper.HasEnoughResource(dataUnitPart.cost);

        if (!hasEnoughResource)
        {
            return(RESULT.LACK_RESOURCE);
        }


        return(RESULT.OK);
    }
    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());
                    }
                }
            }
        }
    }
Example #13
0
    void OnDestroy()
    {
        _instance = null;

        Model_Helper.PauseAllTimer();
    }