Ejemplo n.º 1
0
    private string FormatEmpirePoints(global::Empire empire, bool withNet = false)
    {
        DepartmentOfTheTreasury agency = empire.GetAgency <DepartmentOfTheTreasury>();
        float stockValue;

        if (!agency.TryGetResourceStockValue(empire.SimulationObject, DepartmentOfTheTreasury.Resources.EmpirePoint, out stockValue, false))
        {
            Diagnostics.LogError("Can't get resource stock value {0} on simulation object {1}.", new object[]
            {
                DepartmentOfTheTreasury.Resources.EmpirePoint,
                empire.SimulationObject
            });
        }
        if (!withNet)
        {
            return(GuiFormater.FormatStock(stockValue, SimulationProperties.EmpirePoint, 1, false));
        }
        float netValue;

        if (!agency.TryGetNetResourceValue(empire.SimulationObject, DepartmentOfTheTreasury.Resources.EmpirePoint, out netValue, false))
        {
            Diagnostics.LogError("Can't get resource net value {0} on simulation object {1}.", new object[]
            {
                DepartmentOfTheTreasury.Resources.EmpirePoint,
                empire.SimulationObject
            });
        }
        return(GuiFormater.FormatStockAndNet(stockValue, netValue, SimulationProperties.EmpirePoint, false));
    }
Ejemplo n.º 2
0
    private bool CanSellUnitsAndExplain()
    {
        this.SellButtonPriceLabel.AgeTransform.Visible = false;
        if (this.IsOtherEmpire || !this.DepartmentOfScience.CanTradeUnits(false))
        {
            return(false);
        }
        if (this.selectedUnits.Count == 0)
        {
            this.SellButton.AgeTooltip.Content = "%ArmyEmptySelectionDescription";
            return(false);
        }
        this.SellComputeCandidates();
        if (this.salableUnits.Count == 0)
        {
            this.SellButton.AgeTooltip.Content = "%SellTabNoCandidateDescription";
            return(false);
        }
        if (ELCPUtilities.UseELCPUnitSelling && this.Garrison is Army)
        {
            IWorldPositionningService service = base.GameService.Game.Services.GetService <IWorldPositionningService>();
            Army   army   = this.Garrison as Army;
            Region region = service.GetRegion(army.WorldPosition);
            if (region == null || region.Owner != army.Empire)
            {
                this.SellButton.AgeTooltip.Content = "%SellTabNotInOwnRegionDescription";
                return(false);
            }
        }
        float  num           = this.TotalSellPriceOfSalableUnits();
        string text          = GuiFormater.FormatStock(num, DepartmentOfTheTreasury.Resources.EmpireMoney, 0, true);
        string formattedLine = GuiFormater.FormatInstantCost(this.Garrison.Empire, num, DepartmentOfTheTreasury.Resources.EmpireMoney, true, 1);

        this.SellButtonPriceLabel.Text = text;
        this.SellButtonPriceLabel.AgeTransform.Visible = true;
        AgeUtils.CleanLine(formattedLine, ref this.monochromaticFormat);
        if (!this.Garrison.IsInEncounter)
        {
            this.SellButton.AgeTooltip.Content = string.Format(AgeLocalizer.Instance.LocalizeString("%SellTabOKDescription"), this.monochromaticFormat);
            return(true);
        }
        this.SellButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ArmyLockedInBattleDescription");
        return(false);
    }
Ejemplo n.º 3
0
    protected override IEnumerator OnShow(params object[] parameters)
    {
        this.Value.Text = string.Empty;
        bool          isVisible     = false;
        WorldPosition worldPosition = WorldPosition.Invalid;

        if (this.context is WorldPosition)
        {
            worldPosition = (WorldPosition)this.context;
        }
        else if (this.context is IWorldPositionable)
        {
            worldPosition = (this.context as IWorldPositionable).WorldPosition;
        }
        global::Empire empire = this.playerControllerRepository.ActivePlayerController.Empire as global::Empire;
        bool           flag;

        if (empire.GetAgency <DepartmentOfForeignAffairs>().CanSeeOrbWithOrbHunterTrait)
        {
            flag = this.visibilityService.IsWorldPositionExploredFor(worldPosition, empire);
        }
        else
        {
            flag = this.visibilityService.IsWorldPositionVisibleFor(worldPosition, empire);
        }
        int orbValueAtPosition = this.orbService.GetOrbValueAtPosition(worldPosition);

        if (worldPosition.IsValid && orbValueAtPosition > 0 && flag)
        {
            isVisible = true;
            this.Value.AgeTransform.PixelMarginLeft = this.Title.Font.ComputeTextWidth(AgeLocalizer.Instance.LocalizeString(this.Title.Text), false, false) + 3f * this.Title.AgeTransform.PixelMarginLeft;
            this.Value.Text = GuiFormater.FormatStock((float)orbValueAtPosition, DepartmentOfTheTreasury.Resources.Orb, 0, true);
            if (this.Value.AgeTransform.PixelMarginTop == this.Title.AgeTransform.PixelMarginTop)
            {
                this.Value.AgeTransform.PixelMarginLeft = 2f * this.Title.AgeTransform.PixelMarginLeft + this.Title.Font.ComputeTextWidth(AgeLocalizer.Instance.LocalizeString(this.Title.Text), this.Title.ForceCaps, false);
            }
        }
        yield return(base.OnShow(parameters));

        base.AgeTransform.Visible = isVisible;
        yield break;
    }
Ejemplo n.º 4
0
    public void RefreshContent()
    {
        if (this.City == null)
        {
            return;
        }
        if (this.City.Empire == null)
        {
            return;
        }
        if (this.GuiEmpire.Index != this.City.Empire.Index)
        {
            if (this.guiEmpire == null)
            {
                this.Unbind();
                return;
            }
            this.GuiEmpire = new GuiEmpire(this.City.Empire);
            DepartmentOfIndustry agency = this.City.Empire.GetAgency <DepartmentOfIndustry>();
            this.ConstructionQueue = agency.GetConstructionQueue(this.City);
        }
        if (this.GuiEmpire != null)
        {
            this.FactionBackground.TintColor = this.GuiEmpire.Color;
            this.PopulationSymbol.TintColor  = this.GuiEmpire.Color;
            this.FactionSymbol.TintColor     = this.GuiEmpire.Color;
            this.PinLine.TintColor           = this.GuiEmpire.Color;
            this.PopulationNumber.Text       = GuiFormater.FormatGui(this.City.GetPropertyValue(SimulationProperties.Population), false, false, false, 1);
            this.FactionSymbol.Image         = this.GuiEmpire.GuiFaction.GetImageTexture(global::GuiPanel.IconSize.LogoSmall, true);
        }
        string content = "%CityCurrentConstructionDescription";

        if (this.City.IsInfected)
        {
            this.PanelSpying.Visible        = false;
            this.PanelOvergrownCity.Visible = true;
            this.AgeTransform.Height        = this.ModifierPosition.EndHeight;
            if (this.GuiPreviousEmpire == null)
            {
                this.GuiPreviousEmpire = new GuiEmpire(this.City.LastNonInfectedOwner);
            }
            if (this.GuiPreviousEmpire != null)
            {
                this.PreviousEmpireFactionIcon.TintColor     = this.GuiPreviousEmpire.Color;
                this.PreviousEmpireFactionIcon.Image         = this.GuiPreviousEmpire.GuiFaction.GetImageTexture(global::GuiPanel.IconSize.LogoSmall, true);
                this.PreviousEmpireFactionTooltip.Class      = "Descriptor";
                this.PreviousEmpireFactionTooltip.ClientData = this.GuiEmpire.Empire;
                Faction faction = this.GuiPreviousEmpire.Empire.Faction;
                if (faction != null)
                {
                    new List <string>();
                    foreach (SimulationDescriptor simulationDescriptor in faction.GetIntegrationDescriptors())
                    {
                        this.PreviousEmpireFactionTooltip.Content = simulationDescriptor.Name;
                    }
                }
            }
            if (this.ConstructionQueue.PendingConstructions.Count > 0)
            {
                Construction construction = this.ConstructionQueue.Peek();
                if (construction.ConstructibleElement.SubCategory == "SubCategoryAssimilation" && construction.ConstructibleElement.Name != "CityConstructibleActionInfectedRaze")
                {
                    content = "%IntegratingFactionUnderConstructionDescription";
                }
            }
        }
        this.ConstructionGroup.AgeTooltip.Content = content;
        this.RefreshCityName();
        DepartmentOfIntelligence agency2 = this.playerControllerRepository.ActivePlayerController.Empire.GetAgency <DepartmentOfIntelligence>();
        bool flag = this.playerControllerRepository.ActivePlayerController.Empire.SimulationObject.Tags.Contains(global::Empire.TagEmpireEliminated);

        if (flag && ELCPUtilities.SpectatorSpyFocus >= 0)
        {
            agency2 = this.game.Empires[ELCPUtilities.SpectatorSpyFocus].GetAgency <DepartmentOfIntelligence>();
        }
        Unit hero = null;

        InfiltrationProcessus.InfiltrationState infiltrationState = InfiltrationProcessus.InfiltrationState.None;
        bool flag2 = false;

        if (this.playerControllerRepository != null)
        {
            if (this.City.Empire == this.playerControllerRepository.ActivePlayerController.Empire)
            {
                flag2 = true;
            }
            else if (this.PanelSpying.Visible && agency2 != null && agency2.TryGetSpyOnGarrison(this.City, out hero, out infiltrationState) && infiltrationState == InfiltrationProcessus.InfiltrationState.Infiltrated)
            {
                flag2 = true;
            }
            else if (flag)
            {
                flag2 = true;
            }
        }
        if (!flag2)
        {
            if (this.City.Empire == null)
            {
                this.CompetitorTitle.Text = string.Empty;
            }
            else
            {
                DiplomaticRelation diplomaticRelation = this.playerControllerRepository.ActivePlayerController.Empire.GetAgency <DepartmentOfForeignAffairs>().GetDiplomaticRelation(this.City.Empire);
                Diagnostics.Assert(diplomaticRelation != null);
                if (diplomaticRelation.State != null && diplomaticRelation.State.Name == DiplomaticRelationState.Names.Alliance)
                {
                    AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString("%CityLabelAlliedTitle"), this.CompetitorTitle, out this.temp, '.');
                    this.CompetitorTitle.Text = this.temp;
                }
                else if (diplomaticRelation.State != null && diplomaticRelation.State.Name == DiplomaticRelationState.Names.Peace)
                {
                    AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString("%CityLabelFriendlyTitle"), this.CompetitorTitle, out this.temp, '.');
                    this.CompetitorTitle.Text = this.temp;
                }
                else
                {
                    AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString("%CityLabelEnemyTitle"), this.CompetitorTitle, out this.temp, '.');
                    this.CompetitorTitle.Text = this.temp;
                }
            }
        }
        this.SelectionButton.AgeTransform.Enable = flag2;
        this.PlayerSpecificGroup.Visible         = flag2;
        this.CompetitorSpecificGroup.Visible     = !flag2;
        float propertyValue  = this.City.GetPropertyValue(SimulationProperties.CityDefensePoint);
        float propertyValue2 = this.City.GetPropertyValue(SimulationProperties.MaximumCityDefensePoint);
        float propertyValue3 = this.City.GetPropertyValue(SimulationProperties.CityDefensePointRecoveryPerTurn);
        float propertyValue4 = this.City.GetPropertyValue(SimulationProperties.Ownership);

        Diagnostics.Assert(this.UnitNumber != null);
        Diagnostics.Assert(this.City.StandardUnits != null);
        int num = (this.City.Militia == null) ? 0 : this.City.Militia.StandardUnits.Count;

        this.UnitNumber.Text    = GuiFormater.FormatGui(this.City.StandardUnits.Count + num);
        this.DefenseNumber.Text = GuiFormater.FormatStock(propertyValue, SimulationProperties.CityDefensePoint, 0, true);
        float propertyValue5 = this.City.GetPropertyValue(SimulationProperties.DefensivePower);

        this.DefenseGroup.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%CityDefenseDescription");
        this.DefenseIcon.Image = AgeManager.Instance.FindDynamicTexture("fortificationCityLabel", false);
        if (propertyValue5 > 0f)
        {
            this.DefenseGroup.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%CityDefenseWithDefensivePowerDescription").Replace("$DefensivePowerValue", GuiFormater.FormatGui(propertyValue5, false, true, false, 1));
            this.DefenseIcon.Image = AgeManager.Instance.FindDynamicTexture("retaliationCityLabel", false);
        }
        this.DefenseGroup.AgeTooltip.Content = this.DefenseGroup.AgeTooltip.Content.Replace("$CityDefenseValue", GuiFormater.FormatGui(propertyValue, false, true, false, 1));
        if (propertyValue4 < 1f && !this.City.IsInfected)
        {
            this.OwnershipPercentage.AgeTransform.Visible = true;
            this.OwnershipPercentage.Text = GuiFormater.FormatGui(propertyValue4, true, false, false, 1);
        }
        else
        {
            this.OwnershipPercentage.AgeTransform.Visible = false;
        }
        if (this.City.BesiegingEmpire != null || this.City.BesiegingSeafaringArmies.Count != 0 || this.City.IsUnderEarthquake)
        {
            float num2 = DepartmentOfTheInterior.GetBesiegingPower(this.City, true);
            num2 += DepartmentOfTheInterior.GetCityPointEarthquakeDamage(this.City);
            this.DefenseTendency.Text = "(" + GuiFormater.FormatGui(-num2, false, true, true, 1) + ")";
        }
        else if (propertyValue < propertyValue2)
        {
            this.DefenseTendency.Text = "(" + GuiFormater.FormatGui(propertyValue3, false, true, true, 1) + ")";
        }
        else
        {
            this.DefenseTendency.Text = string.Empty;
        }
        if (flag2)
        {
            Construction construction2 = null;
            if (this.ConstructionQueue != null)
            {
                construction2 = this.ConstructionQueue.Peek();
            }
            if (this.City.IsInfected && construction2 == null)
            {
                this.PlayerSpecificGroup.Visible = false;
            }
            if (construction2 != null)
            {
                IImageFeatureProvider imageFeatureProvider = construction2.ConstructibleElement as IImageFeatureProvider;
                GuiElement            guiElement;
                if (imageFeatureProvider != null)
                {
                    Texture2D image;
                    if (imageFeatureProvider.TryGetTextureFromIcon(global::GuiPanel.IconSize.Small, out image))
                    {
                        this.ConstructionImage.Image = image;
                    }
                }
                else if (this.guiPanelHelper.TryGetGuiElement(construction2.ConstructibleElement.Name, out guiElement))
                {
                    Texture2D image2;
                    if (this.guiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image2))
                    {
                        this.ConstructionImage.Image = image2;
                    }
                }
                else
                {
                    this.ConstructionImage.Image = null;
                }
                CityLabel.emptyList.Clear();
                int   b;
                float num3;
                float num4;
                bool  flag3;
                QueueGuiItem.GetConstructionTurnInfos(this.City, construction2, CityLabel.emptyList, out b, out num3, out num4, out flag3);
                int numberOfTurn = Mathf.Max(1, b);
                this.ConstructionTurns.Text = QueueGuiItem.FormatNumberOfTurns(numberOfTurn);
            }
            else
            {
                this.ConstructionImage.Image = this.NoConstructionTexture;
                this.ConstructionTurns.Text  = "%EmptyConstructionTitle";
            }
        }
        if (this.PanelSpying.Visible && this.playerControllerRepository != null && agency2 != null)
        {
            float value = this.City.GetPropertyValue(SimulationProperties.CityAntiSpy) * 0.01f;
            this.AntiSpyValue.Text                    = GuiFormater.FormatGui(value, true, true, false, 0);
            this.HeroGroup.Visible                    = false;
            this.SpyingEffectsGroup.Visible           = false;
            this.AssignSpyButton.AgeTransform.Visible = false;
            if (this.City.Empire != this.playerControllerRepository.ActivePlayerController.Empire)
            {
                if (infiltrationState != InfiltrationProcessus.InfiltrationState.None)
                {
                    this.HeroGroup.Visible = true;
                    this.HeroCard.Bind(hero, this.playerControllerRepository.ActivePlayerController.Empire as global::Empire, null);
                    this.HeroCard.RefreshContent(false, false);
                    if (this.HeroCard.GuiHero != null)
                    {
                        AgeTooltip ageTooltip = this.HeroCard.HeroPortrait.AgeTransform.AgeTooltip;
                        if (ageTooltip != null)
                        {
                            ageTooltip.Class      = "Unit";
                            ageTooltip.ClientData = this.HeroCard.GuiHero;
                            ageTooltip.Content    = this.HeroCard.GuiHero.Title;
                        }
                    }
                    if (infiltrationState == InfiltrationProcessus.InfiltrationState.Infiltrated)
                    {
                        this.InfiltrationTurnSymbol.AgeTransform.Visible = false;
                        this.InfiltrationTurnValue.AgeTransform.Visible  = false;
                        this.HeroCard.AgeTransform.Alpha = 1f;
                        this.SpyingEffectsGroup.Visible  = true;
                    }
                    else
                    {
                        this.HeroCard.AgeTransform.Alpha = 0.75f;
                        this.InfiltrationTurnSymbol.AgeTransform.Visible = true;
                        this.InfiltrationTurnValue.AgeTransform.Visible  = true;
                        int value2 = DepartmentOfIntelligence.InfiltrationRemainingTurns(hero);
                        this.InfiltrationTurnValue.Text = GuiFormater.FormatGui(value2);
                    }
                }
                else if (!flag)
                {
                    this.AssignSpyButton.AgeTransform.Visible = true;
                    float value3 = 0f;
                    this.failures.Clear();
                    bool flag4 = agency2.CanBeInfiltrate(this.City, out value3, this.failures);
                    bool flag5 = agency2.Empire.GetAgency <DepartmentOfEducation>().Heroes.Count < 1;
                    if (flag5)
                    {
                        flag4 = false;
                    }
                    this.AssignSpyButton.AgeTransform.Enable = flag4;
                    global::IGuiService service = Services.GetService <global::IGuiService>();
                    string str = string.Empty;
                    if (this.failures.Contains(DepartmentOfIntelligence.InfiltrationTargetFailureNotAffordable))
                    {
                        str = "#c52222#";
                    }
                    string arg    = str + GuiFormater.FormatGui(value3, false, true, false, 0) + service.FormatSymbol(this.infiltrationCostResourceName);
                    string format = AgeLocalizer.Instance.LocalizeString("%EspionageLabelAssignSpyTitle");
                    this.AssignTitle.Text = string.Format(format, arg);
                    AgeTooltip ageTooltip2 = this.AssignSpyButton.AgeTransform.AgeTooltip;
                    if (ageTooltip2)
                    {
                        if (flag4)
                        {
                            ageTooltip2.Content = "%EspionageLabelAssignSpyDescription";
                        }
                        else if (flag5)
                        {
                            ageTooltip2.Content = "%EspionageLabelAssignSpyNoHeroesDescription";
                        }
                        else if (this.failures.Contains(DepartmentOfIntelligence.InfiltrationTargetFailureNotVisible))
                        {
                            ageTooltip2.Content = "%EspionageLabelAssignSpyNoVisibilityDescription";
                        }
                        else if (this.failures.Contains(DepartmentOfIntelligence.InfiltrationTargetFailureSiege))
                        {
                            ageTooltip2.Content = "%EspionageLabelAssignSpyUnderSiegeDescription";
                        }
                        else if (this.failures.Contains(DepartmentOfIntelligence.InfiltrationTargetFailureNotAffordable))
                        {
                            ageTooltip2.Content = "%EspionageLabelAssignSpyNotAffordableDescription";
                        }
                        else if (this.failures.Contains(DepartmentOfIntelligence.InfiltrationTargetFailureAlreadyInfiltrated))
                        {
                            ageTooltip2.Content = "%EspionageLabelAssignSpyAlreadyInfiltratedDescription";
                        }
                        else if (this.failures.Contains(DepartmentOfIntelligence.InfiltrationTargetFailureCityInfected))
                        {
                            ageTooltip2.Content = "%EspionageLabelAssignSpyCityInfectedDescription";
                        }
                    }
                }
            }
        }
        bool         flag6 = false;
        List <Kaiju> list  = new List <Kaiju>();

        foreach (RegionalEffect regionalEffect in this.city.GetRegionalEffects())
        {
            IRegionalEffectsProviderGameEntity regionalEffectsProviderGameEntity = null;
            if (this.regionalEffectsService.TryGetEffectOwner(regionalEffect.GUID, out regionalEffectsProviderGameEntity) && regionalEffectsProviderGameEntity.GetRegionalEffectsProviderContext().SimulationObject.Tags.Contains("ClassKaiju"))
            {
                flag6 = true;
                if (regionalEffectsProviderGameEntity is Kaiju)
                {
                    Kaiju item = regionalEffectsProviderGameEntity as Kaiju;
                    if (!list.Contains(item))
                    {
                        list.Add(item);
                    }
                }
            }
        }
        if (flag6)
        {
            AgeTransform ageTransform = this.KaijuIcon.AgeTransform;
            ageTransform.Visible = true;
            ageTransform.Enable  = true;
            this.PopulationGroup.PercentBottom = 100f - (ageTransform.Height + ageTransform.PixelMarginBottom) / ageTransform.GetParent().Height * 100f;
            KaijuInfluenceInCityTooltipData clientData = new KaijuInfluenceInCityTooltipData(this.City, list);
            this.KaijuIcon.AgeTransform.AgeTooltip.Content    = "%CityKaijuAffectedDescription";
            this.KaijuIcon.AgeTransform.AgeTooltip.Class      = "Kaijus";
            this.KaijuIcon.AgeTransform.AgeTooltip.ClientData = clientData;
            return;
        }
        this.KaijuIcon.AgeTransform.Visible = false;
        this.KaijuIcon.AgeTransform.Enable  = false;
        this.PopulationGroup.PercentBottom  = 100f;
    }