示例#1
0
        public Dictionary <BuildingTypeVO, int> GetBuildingsUnlockedBy(BuildingTypeVO reqBuilding)
        {
            Dictionary <BuildingTypeVO, int> dictionary             = new Dictionary <BuildingTypeVO, int>();
            StaticDataController             staticDataController   = Service.StaticDataController;
            BuildingUpgradeCatalog           buildingUpgradeCatalog = Service.BuildingUpgradeCatalog;

            foreach (BuildingTypeVO current in staticDataController.GetAll <BuildingTypeVO>())
            {
                if (current.BuildingRequirement == reqBuilding.Uid || current.BuildingRequirement2 == reqBuilding.Uid)
                {
                    BuildingTypeVO minLevel       = buildingUpgradeCatalog.GetMinLevel(current);
                    BuildingTypeVO buildingTypeVO = (current.Lvl <= minLevel.Lvl) ? null : buildingUpgradeCatalog.GetByLevel(current, current.Lvl - 1);
                    int            num            = (buildingTypeVO != null) ? buildingTypeVO.MaxQuantity : 0;
                    int            num2           = current.MaxQuantity - num;
                    if (num2 > 0)
                    {
                        if (dictionary.ContainsKey(minLevel))
                        {
                            Dictionary <BuildingTypeVO, int> dictionary2;
                            BuildingTypeVO key;
                            (dictionary2 = dictionary)[key = minLevel] = dictionary2[key] + num2;
                        }
                        else
                        {
                            dictionary.Add(minLevel, num2);
                        }
                    }
                }
            }
            return(dictionary);
        }
示例#2
0
        public int GetBuildingMaxPurchaseQuantity(BuildingTypeVO building, int haveReqBuildingLvl)
        {
            BuildingTypeVO buildingTypeVO = this.GetBuildingConstructionRequirement(building);

            if (buildingTypeVO == null)
            {
                return(building.MaxQuantity);
            }
            if (haveReqBuildingLvl >= buildingTypeVO.Lvl || this.HasConstructedBuilding(buildingTypeVO))
            {
                BuildingUpgradeCatalog buildingUpgradeCatalog = Service.BuildingUpgradeCatalog;
                int lvl  = buildingUpgradeCatalog.GetMinLevel(building.UpgradeGroup).Lvl;
                int lvl2 = buildingUpgradeCatalog.GetMaxLevel(building.UpgradeGroup).Lvl;
                for (int i = lvl2; i > lvl; i--)
                {
                    BuildingTypeVO byLevel = buildingUpgradeCatalog.GetByLevel(building.UpgradeGroup, i);
                    if (byLevel != null)
                    {
                        buildingTypeVO = this.GetRequiredBuilding(byLevel.BuildingRequirement);
                        if (buildingTypeVO == null || haveReqBuildingLvl >= buildingTypeVO.Lvl || this.HasConstructedBuilding(buildingTypeVO))
                        {
                            return(byLevel.MaxQuantity);
                        }
                    }
                }
                BuildingTypeVO minLevel = buildingUpgradeCatalog.GetMinLevel(building);
                return(minLevel.MaxQuantity);
            }
            if (Service.UnlockController.HasUnlockedBuildingByReward(building))
            {
                return(1);
            }
            return(0);
        }
        public void ShowBuildings(List <Transform> warBuildingLocators)
        {
            if (this.assetHandles == null)
            {
                this.assetHandles = new List <AssetHandle>();
            }
            if (this.outline == null)
            {
                this.outline = new OutlinedAsset();
            }
            this.pressedBuilding     = null;
            this.pressTimerId        = 0u;
            this.pressScreenPosition = Vector2.zero;
            this.selectedBuilding    = null;
            this.dragged             = false;
            this.CacheHQBuildingIds();
            BuildingUpgradeCatalog catalog      = Service.Get <BuildingUpgradeCatalog>();
            AssetManager           assetManager = Service.Get <AssetManager>();
            SquadWarManager        warManager   = Service.Get <SquadController>().WarManager;
            SquadWarSquadData      squadData    = warManager.GetSquadData(SquadWarSquadType.PLAYER_SQUAD);

            this.AddBuildingsForParticipants(squadData, true, catalog, assetManager, warBuildingLocators);
            SquadWarSquadData squadData2 = warManager.GetSquadData(SquadWarSquadType.OPPONENT_SQUAD);

            this.AddBuildingsForParticipants(squadData2, false, catalog, assetManager, warBuildingLocators);
            Service.Get <UserInputManager>().RegisterObserver(this, UserInputLayer.World);
        }
示例#4
0
        private BuildingTypeVO GetBuildingConstructionRequirement(BuildingTypeVO building)
        {
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.BuildingUpgradeCatalog;
            BuildingTypeVO         minLevel = buildingUpgradeCatalog.GetMinLevel(building);

            return(this.GetRequiredBuilding(minLevel.BuildingRequirement));
        }
        private void UpdateShieldRange(int sliderIndex)
        {
            ShieldController       shieldController       = Service.Get <ShieldController>();
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>();
            BuildingTypeVO         maxLevel = buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo.UpgradeGroup);
            int num  = shieldController.PointsToRange[this.buildingInfo.ShieldRangePoints];
            int num2 = shieldController.PointsToRange[maxLevel.ShieldRangePoints];

            this.sliders[sliderIndex].CurrentSlider.Value = ((num2 == 0) ? 0f : ((float)num / (float)num2));
            if (this.useUpgradeGroup)
            {
                BuildingTypeVO nextLevel = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo);
                int            num3      = shieldController.PointsToRange[nextLevel.ShieldRangePoints];
                this.sliders[sliderIndex].CurrentLabel.Text = this.lang.ThousandsSeparated(num);
                this.sliders[sliderIndex].NextLabel.Text    = this.lang.Get("PLUS", new object[]
                {
                    this.lang.ThousandsSeparated(num3 - num)
                });
                this.sliders[sliderIndex].NextSlider.Value = ((num2 == 0) ? 0f : ((float)num3 / (float)num2));
                return;
            }
            this.sliders[sliderIndex].CurrentLabel.Text = this.lang.Get("FRACTION", new object[]
            {
                this.lang.ThousandsSeparated(num),
                this.lang.ThousandsSeparated(num2)
            });
        }
示例#6
0
        private void UpgradeChampionToMatchPlatform(SmartEntity building)
        {
            BuildingTypeVO buildingType = building.BuildingComp.BuildingType;
            TroopTypeVO    troopTypeVO  = this.FindChampionTypeIfPlatform(buildingType);

            if (troopTypeVO == null)
            {
                return;
            }
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>();
            BuildingTypeVO         nextLevel    = buildingUpgradeCatalog.GetNextLevel(buildingType);
            TroopTypeVO            troopTypeVO2 = this.FindChampionTypeIfPlatform(nextLevel);

            if (troopTypeVO2 == null)
            {
                return;
            }
            this.AddChampionToInventoryIfAlive(building, false);
            CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>();

            UnlockedLevelData.UpgradeTroopsOrStarshipsInventory(currentPlayer.Inventory.Champion, false, troopTypeVO2.UpgradeGroup, troopTypeVO2.Uid);
            this.DestroyChampionEntity(troopTypeVO);
            if (Service.Get <GameStateMachine>().CurrentState is HomeState)
            {
                this.CreateChampionEntity(troopTypeVO2, building);
            }
        }
示例#7
0
        private void UpdateShieldHealth(int sliderIndex)
        {
            ShieldController       shieldController       = Service.ShieldController;
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.BuildingUpgradeCatalog;
            BuildingTypeVO         maxLevel = buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo.UpgradeGroup);
            int num  = shieldController.PointsToHealth[this.buildingInfo.ShieldHealthPoints];
            int num2 = shieldController.PointsToHealth[maxLevel.ShieldHealthPoints];

            this.sliders[sliderIndex].CurrentSlider.Value = ((num2 != 0) ? ((float)num / (float)num2) : 0f);
            if (this.useUpgradeGroup)
            {
                BuildingTypeVO nextLevel = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo);
                int            num3      = shieldController.PointsToHealth[nextLevel.ShieldHealthPoints];
                this.sliders[sliderIndex].CurrentLabel.Text = this.lang.ThousandsSeparated(num);
                this.sliders[sliderIndex].NextLabel.Text    = this.lang.Get("PLUS", new object[]
                {
                    this.lang.ThousandsSeparated(num3 - num)
                });
                this.sliders[sliderIndex].NextSlider.Value = ((num2 != 0) ? ((float)num3 / (float)num2) : 0f);
            }
            else
            {
                this.sliders[sliderIndex].CurrentLabel.Text = this.lang.Get("FRACTION", new object[]
                {
                    this.lang.ThousandsSeparated(num),
                    this.lang.ThousandsSeparated(num2)
                });
            }
        }
示例#8
0
 public static void GrantInstantBuildingUpgrade(RewardVO reward, CurrentPlayer cp)
 {
     for (int i = 0; i < reward.BuildingInstantUpgrades.Length; i++)
     {
         string[] array = reward.BuildingInstantUpgrades[i].Split(new char[]
         {
             ':'
         });
         int            num            = Convert.ToInt32(array[1], CultureInfo.InvariantCulture);
         string         text           = array[0];
         BuildingTypeVO buildingTypeVO = Service.Get <IDataController>().Get <BuildingTypeVO>(text);
         if (buildingTypeVO == null)
         {
             Service.Get <StaRTSLogger>().WarnFormat("buildingUiD {0} does not exist", new object[]
             {
                 text
             });
         }
         else
         {
             BuildingUpgradeCatalog  buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>();
             ISupportController      supportController      = Service.Get <ISupportController>();
             NodeList <BuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <BuildingNode>();
             for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
             {
                 BuildingTypeVO buildingType = buildingNode.BuildingComp.BuildingType;
                 if (buildingType.Lvl < num && buildingType.Type == buildingTypeVO.Type && buildingType.Type != BuildingType.Clearable)
                 {
                     BuildingTypeVO byLevel = buildingUpgradeCatalog.GetByLevel(buildingType.UpgradeGroup, num);
                     if (byLevel != null && byLevel.PlayerFacing)
                     {
                         if (!string.IsNullOrEmpty(buildingTypeVO.LinkedUnit))
                         {
                             if (ContractUtils.IsChampionRepairing(buildingNode.Entity))
                             {
                                 supportController.FinishCurrentContract(buildingNode.Entity, true);
                             }
                             if (cp.Inventory.Champion.GetItemAmount(buildingTypeVO.LinkedUnit) == 0)
                             {
                                 cp.OnChampionRepaired(buildingTypeVO.LinkedUnit);
                             }
                         }
                         supportController.StartBuildingUpgrade(byLevel, buildingNode.Entity, true);
                         int   boardX = buildingNode.Entity.Get <BoardItemComponent>().BoardItem.BoardX;
                         int   boardZ = buildingNode.Entity.Get <BoardItemComponent>().BoardItem.BoardZ;
                         float x;
                         float z;
                         EditBaseController.BuildingBoardToWorld(buildingNode.Entity, boardX, boardZ, out x, out z);
                         Vector3 worldLocation = new Vector3(x, 0f, z);
                         worldLocation.x = Units.BoardToWorldX(boardX);
                         worldLocation.z = Units.BoardToWorldX(boardZ);
                         Service.Get <WorldInitializer>().View.PanToLocation(worldLocation);
                     }
                 }
             }
         }
     }
 }
示例#9
0
        protected override void SetSelectedBuilding(SmartEntity newSelectedBuilding)
        {
            base.SetSelectedBuilding(newSelectedBuilding);
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.BuildingUpgradeCatalog;

            this.nextBuildingInfo = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo);
            this.maxBuildingInfo  = buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo.UpgradeGroup);
            this.reqMet           = Service.UnlockController.IsUnlocked(this.nextBuildingInfo, 1, out this.reqBuildingInfo);
        }
示例#10
0
        private void UpdateCapacity(int sliderIndex)
        {
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>();
            int storage  = this.buildingInfo.Storage;
            int storage2 = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo).Storage;
            int storage3 = buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo.UpgradeGroup).Storage;

            this.UpdateSlider(sliderIndex, this.lang.Get("UPGRADE_FIELD_CAPACITY", new object[0]), storage, storage2, storage3);
        }
示例#11
0
        public ChampionInfoScreen(SmartEntity platformBuilding, TroopTypeVO championType, bool forUpgrade) : base(new TroopUpgradeTag(championType, true), null, forUpgrade, platformBuilding)
        {
            this.wantsTransition   = true;
            this.shouldCloseParent = false;
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.BuildingUpgradeCatalog;

            this.nextBuildingInfo = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo);
            this.maxBuildingInfo  = buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo);
            TroopTypeVO nextLevel = Service.TroopUpgradeCatalog.GetNextLevel(this.selectedTroop.Troop as TroopTypeVO);

            this.selectedTroop.ReqMet = Service.UnlockController.CanDeployableBeUpgraded(this.selectedTroop.Troop, nextLevel, out this.selectedTroop.RequirementText, out this.selectedTroop.ShortRequirementText);
        }
示例#12
0
        protected void UpdateDps(int sliderIndex)
        {
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>();
            IDataController        dataController         = Service.Get <IDataController>();
            BuildingTypeVO         maxLevel     = buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo.UpgradeGroup);
            TurretTypeVO           turretTypeVO = dataController.Get <TurretTypeVO>(maxLevel.TurretUid);

            if (turretTypeVO.ProjectileType.IsBeam)
            {
                int beamDamage  = turretTypeVO.ProjectileType.BeamDamage;
                int beamDamage2 = this.turretInfo.ProjectileType.BeamDamage;
                this.sliders[1].DescLabel.Text = this.lang.Get("BEAM_DAMAGE", new object[]
                {
                    beamDamage2
                });
                this.sliders[sliderIndex].CurrentLabel.Text   = string.Empty;
                this.sliders[sliderIndex].CurrentSlider.Value = ((beamDamage == 0) ? 0f : ((float)beamDamage2 / (float)beamDamage));
                if (this.useUpgradeGroup && this.nextBuildingInfo != null)
                {
                    BuildingTypeVO nextLevel   = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo);
                    int            beamDamage3 = dataController.Get <TurretTypeVO>(nextLevel.TurretUid).ProjectileType.BeamDamage;
                    this.sliders[sliderIndex].NextLabel.Text = this.lang.Get("PLUS", new object[]
                    {
                        this.lang.ThousandsSeparated(beamDamage3 - beamDamage2)
                    });
                    this.sliders[sliderIndex].NextSlider.Value = ((beamDamage == 0) ? 0f : ((float)beamDamage3 / (float)beamDamage));
                    return;
                }
            }
            else
            {
                int dPS  = this.turretInfo.DPS;
                int dPS2 = turretTypeVO.DPS;
                this.sliders[1].DescLabel.Text = this.lang.Get("DAMAGE_DPS", new object[]
                {
                    ""
                });
                this.sliders[sliderIndex].CurrentLabel.Text   = this.lang.ThousandsSeparated(dPS);
                this.sliders[sliderIndex].CurrentSlider.Value = ((dPS2 == 0) ? 0f : ((float)dPS / (float)dPS2));
                if (this.useUpgradeGroup && this.nextBuildingInfo != null)
                {
                    BuildingTypeVO nextLevel2 = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo);
                    int            dPS3       = dataController.Get <TurretTypeVO>(nextLevel2.TurretUid).DPS;
                    this.sliders[sliderIndex].NextLabel.Text = this.lang.Get("PLUS", new object[]
                    {
                        this.lang.ThousandsSeparated(dPS3 - dPS)
                    });
                    this.sliders[sliderIndex].NextSlider.Value = ((dPS2 == 0) ? 0f : ((float)dPS3 / (float)dPS2));
                }
            }
        }
示例#13
0
        private void UpdateCapacity(int sliderIndex)
        {
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.BuildingUpgradeCatalog;
            int          storage      = this.buildingInfo.Storage;
            int          storage2     = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo).Storage;
            int          storage3     = buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo.UpgradeGroup).Storage;
            DeliveryType deliveryType = this.deliveryType;
            string       id;

            if (deliveryType != DeliveryType.Vehicle)
            {
                if (deliveryType != DeliveryType.Starship)
                {
                    if (deliveryType != DeliveryType.Mercenary)
                    {
                        id = "UPGRADE_FIELD_CAPACITY";
                    }
                    else
                    {
                        id = "UPGRADE_FIELD_MERCENARY_CAPACITY";
                    }
                }
                else
                {
                    id = "UPGRADE_FIELD_STARSHIP_CAPACITY";
                }
            }
            else
            {
                id = "UPGRADE_FIELD_VEHICLE_CAPACITY";
            }
            SliderControl sliderControl = this.sliders[sliderIndex];

            sliderControl.DescLabel.Text      = this.lang.Get(id, new object[0]);
            sliderControl.CurrentLabel.Text   = this.lang.ThousandsSeparated(storage);
            sliderControl.CurrentSlider.Value = ((storage3 != 0) ? ((float)storage / (float)storage3) : 0f);
            if (storage2 > storage)
            {
                sliderControl.NextLabel.Text = this.lang.Get("PLUS", new object[]
                {
                    this.lang.ThousandsSeparated(storage2 - storage)
                });
                sliderControl.NextSlider.Value = ((storage3 != 0) ? ((float)storage2 / (float)storage3) : 0f);
            }
            else
            {
                sliderControl.NextLabel.Visible  = false;
                sliderControl.NextSlider.Visible = false;
            }
        }
示例#14
0
        public BuildingTypeVO GetHeroSlotUnlockRequirement(BuildingTypeVO heroBuilding, int slotNum)
        {
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.BuildingUpgradeCatalog;
            List <BuildingTypeVO>  upgradeGroupLevels     = buildingUpgradeCatalog.GetUpgradeGroupLevels(heroBuilding.UpgradeGroup);
            BuildingTypeVO         result = null;

            for (int i = 0; i < upgradeGroupLevels.Count; i++)
            {
                if (upgradeGroupLevels[i].Storage >= slotNum)
                {
                    result = upgradeGroupLevels[i];
                    break;
                }
            }
            return(result);
        }
示例#15
0
        private void UpdateCapacity(int sliderIndex)
        {
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>();
            int storage  = this.buildingInfo.Storage;
            int storage2 = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo).Storage;
            int storage3 = buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo.UpgradeGroup).Storage;

            this.sliders[sliderIndex].DescLabel.Text    = this.lang.Get("UPGRADE_FIELD_CAPACITY", new object[0]);
            this.sliders[sliderIndex].CurrentLabel.Text = this.lang.ThousandsSeparated(storage);
            this.sliders[sliderIndex].NextLabel.Text    = this.lang.Get("PLUS", new object[]
            {
                this.lang.ThousandsSeparated(storage2 - storage)
            });
            this.sliders[sliderIndex].CurrentSlider.Value = ((storage3 == 0) ? 0f : ((float)storage / (float)storage3));
            this.sliders[sliderIndex].NextSlider.Value    = ((storage3 == 0) ? 0f : ((float)storage2 / (float)storage3));
        }
示例#16
0
        protected override void UpdateReputation(int sliderIndex)
        {
            Inventory inventory = Service.Get <CurrentPlayer>().Inventory;

            if (!inventory.HasItem("reputation"))
            {
                this.sliders[sliderIndex].HideAll();
                Service.Get <StaRTSLogger>().WarnFormat("No reputation found in your inventory", new object[0]);
                return;
            }
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>();
            int itemCapacity = inventory.GetItemCapacity("reputation");
            int reputationCapacityForLevel  = GameUtils.GetReputationCapacityForLevel(buildingUpgradeCatalog.GetNextLevel(this.buildingInfo).Lvl);
            int reputationCapacityForLevel2 = GameUtils.GetReputationCapacityForLevel(buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo.UpgradeGroup).Lvl);

            this.UpdateSlider(sliderIndex, this.lang.Get("BUILDING_REPUTATION", new object[0]), itemCapacity, reputationCapacityForLevel, reputationCapacityForLevel2);
        }
示例#17
0
        public void InitStorage(int sliderIndex, string description)
        {
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.BuildingUpgradeCatalog;
            int            storage       = this.buildingInfo.Storage;
            BuildingTypeVO nextLevel     = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo);
            int            num           = (nextLevel != null) ? nextLevel.Storage : storage;
            int            storage2      = buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo.UpgradeGroup).Storage;
            SliderControl  sliderControl = this.sliders[sliderIndex];

            sliderControl.DescLabel.Text      = this.lang.Get(description, new object[0]);
            sliderControl.CurrentLabel.Text   = this.lang.ThousandsSeparated(storage);
            sliderControl.CurrentSlider.Value = ((storage2 != 0) ? ((float)storage / (float)storage2) : 0f);
            sliderControl.NextLabel.Text      = this.lang.Get("PLUS", new object[]
            {
                this.lang.ThousandsSeparated(num - storage)
            });
            sliderControl.NextSlider.Value = ((storage2 != 0) ? ((float)num / (float)storage2) : 0f);
        }
示例#18
0
        private void UpdateCapacity(int sliderIndex)
        {
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>();
            int storage  = this.buildingInfo.Storage;
            int storage2 = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo).Storage;
            int storage3 = buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo.UpgradeGroup).Storage;

            this.sliders[sliderIndex].DescLabel.Text    = this.lang.Get("STORAGE_CAPACITY", new object[0]);
            this.sliders[sliderIndex].CurrentLabel.Text = this.lang.ThousandsSeparated(storage);
            this.sliders[sliderIndex].NextLabel.Text    = this.lang.Get("PLUS", new object[]
            {
                this.lang.ThousandsSeparated(storage2 - storage)
            });
            this.sliders[sliderIndex].CurrentSlider.Value = ((storage3 == 0) ? 0f : ((float)storage / (float)storage3));
            this.sliders[sliderIndex].NextSlider.Value    = ((storage3 == 0) ? 0f : ((float)storage2 / (float)storage3));
            int   num        = StorageSpreadUtils.CalculateAssumedCurrencyInStorage(this.buildingInfo.Currency, this.selectedBuilding);
            int   storage4   = this.buildingInfo.Storage;
            float meterValue = (storage4 == 0) ? 0f : ((float)num / (float)storage4);

            this.projector.Config.MeterValue = meterValue;
        }
示例#19
0
        private void UpdateCapacity(int sliderIndex)
        {
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>();
            int storage  = this.buildingInfo.Storage;
            int storage2 = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo).Storage;
            int storage3 = buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo.UpgradeGroup).Storage;

            this.sliders[sliderIndex].DescLabel.Text    = this.lang.Get("UPGRADE_FIELD_STORAGE", new object[0]);
            this.sliders[sliderIndex].CurrentLabel.Text = this.lang.ThousandsSeparated(storage);
            this.sliders[sliderIndex].NextLabel.Text    = this.lang.Get("PLUS", new object[]
            {
                this.lang.ThousandsSeparated(storage2 - storage)
            });
            this.sliders[sliderIndex].CurrentSlider.Value = ((storage3 == 0) ? 0f : ((float)storage / (float)storage3));
            this.sliders[sliderIndex].NextSlider.Value    = ((storage3 == 0) ? 0f : ((float)storage2 / (float)storage3));
            BuildingComponent buildingComponent = this.selectedBuilding.Get <BuildingComponent>();
            int   accruedCurrency = buildingComponent.BuildingTO.AccruedCurrency;
            int   storage4        = this.buildingInfo.Storage;
            float meterValue      = (storage4 == 0) ? 0f : ((float)accruedCurrency / (float)storage4);

            this.projector.Config.MeterValue = meterValue;
        }
示例#20
0
 public static IGeometryVO DetermineVOForEquipment(EquipmentVO equipmentVO)
 {
     if (equipmentVO != null && !string.IsNullOrEmpty(equipmentVO.BuildingID))
     {
         BuildingUpgradeCatalog buildingUpgradeCatalog = Service.BuildingUpgradeCatalog;
         UnlockController       unlockController       = Service.UnlockController;
         BuildingTypeVO         buildingTypeVO         = buildingUpgradeCatalog.GetMinLevel(equipmentVO.BuildingID);
         int lvl = buildingUpgradeCatalog.GetMaxLevel(equipmentVO.BuildingID).Lvl;
         for (int i = buildingTypeVO.Lvl + 1; i < lvl; i++)
         {
             BuildingTypeVO byLevel = buildingUpgradeCatalog.GetByLevel(equipmentVO.BuildingID, i);
             BuildingTypeVO buildingTypeVO2;
             if (!unlockController.IsUnlocked(byLevel, 1, out buildingTypeVO2))
             {
                 break;
             }
             buildingTypeVO = byLevel;
         }
         return(buildingTypeVO);
     }
     return(equipmentVO);
 }
示例#21
0
        protected virtual void InitHitpoints(int sliderIndex)
        {
            this.hitpointSliderIndex = sliderIndex;
            this.sliders[sliderIndex].CurrentLabel.Visible  = true;
            this.sliders[sliderIndex].CurrentSlider.Visible = true;
            this.sliders[sliderIndex].DescLabel.Visible     = true;
            this.sliders[sliderIndex].Background.Visible    = true;
            string text;

            if (this.useUpgradeGroup && this.nextBuildingInfo != null)
            {
                text = this.lang.Get("BUILDING_HITPOINTS", new object[0]);
                BuildingUpgradeCatalog buildingUpgradeCatalog = Service.BuildingUpgradeCatalog;
                int health  = this.buildingInfo.Health;
                int health2 = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo).Health;
                int health3 = buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo.UpgradeGroup).Health;
                this.sliders[sliderIndex].CurrentLabel.Text = this.lang.ThousandsSeparated(health);
                this.sliders[sliderIndex].NextLabel.Text    = this.lang.Get("PLUS", new object[]
                {
                    this.lang.ThousandsSeparated(health2 - health)
                });
                this.sliders[sliderIndex].CurrentSlider.Value = ((health3 != 0) ? ((float)health / (float)health3) : 0f);
                this.sliders[sliderIndex].NextSlider.Value    = ((health3 != 0) ? ((float)health2 / (float)health3) : 0f);
            }
            else
            {
                text = this.lang.Get("BUILDING_HITPOINTS", new object[0]);
                this.UpdateHitpoints();
            }
            this.sliders[this.hitpointSliderIndex].DescLabel.Text = text;
            if (!this.observingClockViewTime && Service.PostBattleRepairController.IsEntityInRepair(this.selectedBuilding))
            {
                Service.ViewTimeEngine.RegisterClockTimeObserver(this, 1f);
                this.observingClockViewTime = true;
            }
        }
        private void AddBuildingsForParticipants(SquadWarSquadData squadData, bool isForPlayerSquad, BuildingUpgradeCatalog catalog, AssetManager assetManager, List <Transform> warBuildingLocators)
        {
            List <SquadWarParticipantState> list = new List <SquadWarParticipantState>(squadData.Participants);

            list.Sort(new Comparison <SquadWarParticipantState>(this.SortParticipantsAsc));
            string upgradeGroup = (squadData.Faction == FactionType.Empire) ? this.empireHQId : this.rebelHQId;
            bool   isEmpire     = squadData.Faction == FactionType.Empire;
            int    i            = 0;
            int    count        = list.Count;

            while (i < count)
            {
                BuildingTypeVO byLevel = catalog.GetByLevel(upgradeGroup, list[i].HQLevel);
                if (byLevel != null)
                {
                    this.AddBuildingForParticipant(list[i], byLevel, isForPlayerSquad, isEmpire, i, assetManager, warBuildingLocators[i]);
                }
                i++;
            }
        }
示例#23
0
        private void SetupGrid()
        {
            if (this.itemGrid != null)
            {
                return;
            }
            this.itemGrid = base.GetElement <UXGrid>("SwapTypeGrid");
            this.itemGrid.SetTemplateItem("SwapTypeTemplate");
            CurrentPlayer          currentPlayer          = Service.CurrentPlayer;
            FactionType            faction                = currentPlayer.Faction;
            StaticDataController   staticDataController   = Service.StaticDataController;
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.BuildingUpgradeCatalog;
            UnlockController       unlockController       = Service.UnlockController;

            foreach (BuildingTypeVO current in staticDataController.GetAll <BuildingTypeVO>())
            {
                if (current.Type == BuildingType.Turret && current.Faction == faction && current.StoreTab != StoreTab.NotInStore)
                {
                    BuildingTypeVO byLevel        = buildingUpgradeCatalog.GetByLevel(current.UpgradeGroup, this.buildingInfo.Lvl);
                    BuildingTypeVO buildingTypeVO = null;
                    bool           flag           = unlockController.IsUnlocked(current, 1, out buildingTypeVO);
                    if (flag || !byLevel.HideIfLocked)
                    {
                        StoreItemTag storeItemTag = new StoreItemTag();
                        storeItemTag.BuildingInfo = byLevel;
                        string    uid       = byLevel.Uid;
                        UXElement uXElement = this.itemGrid.CloneTemplateItem(uid);
                        uXElement.Tag            = storeItemTag;
                        storeItemTag.MainElement = this.itemGrid.GetSubElement <UXElement>(uid, "ItemInfoTurret");
                        UXLabel subElement = this.itemGrid.GetSubElement <UXLabel>(uid, "LabelItemInfoTurret");
                        subElement.Text                  = LangUtils.GetBuildingDescription(byLevel);
                        storeItemTag.InfoGroup           = this.itemGrid.GetSubElement <UXButton>(uid, "InfoTextTurret");
                        storeItemTag.InfoGroup.Visible   = false;
                        storeItemTag.InfoGroup.OnClicked = new UXButtonClickedDelegate(this.OnSwapInfoLabelButtonClicked);
                        storeItemTag.InfoGroup.Tag       = storeItemTag;
                        UXButton subElement2 = this.itemGrid.GetSubElement <UXButton>(uid, "BtnItemInfoTurret");
                        subElement2.OnClicked = new UXButtonClickedDelegate(this.OnSwapInfoButtonClicked);
                        subElement2.Tag       = storeItemTag;
                        UXSprite        subElement3     = this.itemGrid.GetSubElement <UXSprite>(uid, "SpriteItemImageTurret");
                        ProjectorConfig projectorConfig = ProjectorUtils.GenerateBuildingConfig(byLevel, subElement3);
                        projectorConfig.AnimPreference = AnimationPreference.NoAnimation;
                        ProjectorUtils.GenerateProjector(projectorConfig);
                        UXLabel subElement4 = this.itemGrid.GetSubElement <UXLabel>(uid, "LabelItemRequirement");
                        subElement4.Visible = !flag;
                        UXElement subElement5 = this.itemGrid.GetSubElement <UXElement>(uid, "CountAndBuildTime");
                        subElement5.Visible = flag;
                        if (flag)
                        {
                            int swapCredits    = byLevel.SwapCredits;
                            int swapMaterials  = byLevel.SwapMaterials;
                            int swapContraband = byLevel.SwapContraband;
                            UXUtils.SetupCostElements(this, "CostTurretSwap", uid, swapCredits, swapMaterials, swapContraband, 0, !flag, null, 150);
                            UXLabel subElement6 = this.itemGrid.GetSubElement <UXLabel>(uid, "LabelBuildTime");
                            subElement6.Text = GameUtils.GetTimeLabelFromSeconds(byLevel.SwapTime);
                            UXLabel subElement7 = this.itemGrid.GetSubElement <UXLabel>(uid, "LabelSwapItemCount");
                            subElement7.Text = string.Empty;
                        }
                        else if (buildingTypeVO != null)
                        {
                            subElement4.Text = this.lang.Get("BUILDING_REQUIREMENT", new object[]
                            {
                                buildingTypeVO.Lvl,
                                LangUtils.GetBuildingDisplayName(buildingTypeVO)
                            });
                            UXUtils.SetupCostElements(this, "CostTurretSwap", uid, 0, 0, 0, 0, !flag, this.lang.Get("s_Locked", new object[0]), 150);
                        }
                        UXCheckbox subElement8 = this.itemGrid.GetSubElement <UXCheckbox>(uid, "TurretItemCard");
                        subElement8.Enabled    = flag;
                        subElement8.OnSelected = new UXCheckboxSelectedDelegate(this.OnSwapItemCheckboxSelected);
                        subElement8.Selected   = (byLevel.Uid == this.buildingInfo.Uid);
                        subElement8.Tag        = storeItemTag;
                        if (subElement8.Selected)
                        {
                            this.OnSwapItemCheckboxSelected(subElement8, true);
                        }
                        this.itemGrid.AddItem(uXElement, byLevel.Order);
                    }
                }
            }
            this.itemGrid.RepositionItems();
        }