Exemple #1
0
    void RecalcScrollRectSize()
    {
        lvButton.transform.SetParent(transform, true);
        bool canLevelHousing = GameDataManager.Instance.dataStore.housingLevel < GameDataManager_DataStore.housingLevelCap;

        lvButton.gameObject.SetActive(canLevelHousing);
        int modifier = 0;

        if (canLevelHousing)
        {
            modifier = 1;
        }
        for (int i = 0; i < houseAdvWatchers.Length; i++)
        {
            houseAdvWatchers[i].transform.SetParent(transform, true);
        }
        houseLvCached                   = GameDataManager.Instance.dataStore.housingLevel;
        scrollAreaRect.sizeDelta        = new Vector2(scrollAreaRect.sizeDelta.x, ((GameDataManager.Instance.dataStore.housingLevel + modifier) * advPanelHeight) + ((GameDataManager.Instance.dataStore.housingLevel - 1 + modifier) * advPanelsSpacing));
        scrollAreaRect.anchoredPosition = Vector3.zero;
        for (int i = 0; i < houseAdvWatchers.Length; i++)
        {
            _RSRS_parentAndPositionListEntry(i, houseAdvWatchers[i].transform as RectTransform);
        }
        if (canLevelHousing)
        {
            RectTransform rt = lvButton.transform as RectTransform;
            rt.SetParent(advPanelsParent.transform, true);
            rt.anchoredPosition = (houseAdvWatchers[GameDataManager.Instance.dataStore.housingLevel].transform as RectTransform).anchoredPosition;
            int[] costs = TownBuilding.GetUpgradeCost_House(GameDataManager.Instance.dataStore.housingLevel);
            lvButton_Bricks.text = costs[0].ToString();
            lvButton_Planks.text = costs[1].ToString();
            lvButton_Metal.text  = costs[2].ToString();
        }
    }
Exemple #2
0
 public void LevelUpHousing()
 {
     int[] costs = TownBuilding.GetUpgradeCost_House(GameDataManager.Instance.dataStore.housingLevel);
     if (GameDataManager.Instance.SpendResourcesIfPossible(costs) && GameDataManager.Instance.dataStore.housingLevel < GameDataManager_DataStore.housingLevelCap)
     {
         GameDataManager.Instance.dataStore.housingLevel++;
     }
     else
     {
         shell.SurrenderFocus();
         insufficientResourcesPopup.Open();
     }
 }
Exemple #3
0
 private void UpdateProcessing_Barracks()
 {
     if (GameDataManager.Instance.dataStore.housingLevel != buildingLevelCached)
     {
         buildingLevelCached = GameDataManager.Instance.dataStore.housingLevel;
         devTypeLabel.text   = strings[32] + Environment.NewLine + strings[31] + buildingLevelCached;
     }
     if (GameDataManager.Instance.dataStore.housingLevel < GameDataManager_DataStore.housingLevelCap)
     {
         if (!materialsNeededSection.activeInHierarchy)
         {
             materialsNeededSection.SetActive(true);
         }
         if (GameDataManager.Instance.dataStore.resBricks != cachedMaterialQuantities[0] || GameDataManager.Instance.dataStore.resPlanks != cachedMaterialQuantities[1] || GameDataManager.Instance.dataStore.resMetal != cachedMaterialQuantities[2])
         {
             cachedMaterialQuantities = new int[] { GameDataManager.Instance.dataStore.resBricks, GameDataManager.Instance.dataStore.resPlanks, GameDataManager.Instance.dataStore.resMetal };
             int[] costs = TownBuilding.GetUpgradeCost_House(GameDataManager.Instance.dataStore.housingLevel);
             RefreshResourceCounters(costs);
             if (GameDataManager.Instance.CheckMaterialAvailability(costs))
             {
                 if (devStatusLabel.text != strings[12])
                 {
                     devStatusLabel.text = strings[12];
                 }
             }
             else if (devStatusLabel.text != strings[15])
             {
                 devStatusLabel.text = strings[13];
             }
         }
     }
     else
     {
         if (materialsNeededSection.activeInHierarchy)
         {
             materialsNeededSection.SetActive(false);
         }
         if (devStatusLabel.text != strings[17])
         {
             devStatusLabel.text = strings[17];
         }
     }
 }