Пример #1
0
    public void RefreshContent(City city, CityOptionsPanel.ProductionConstruction constructibleElementDefinition, int index, GameObject client)
    {
        IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper;

        Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper");
        UnitDesign unitDesign = constructibleElementDefinition.ConstructibleElement as UnitDesign;
        GuiElement guiElement2;

        if (unitDesign != null)
        {
            this.ConstructibleName.Text   = GuiUnitDesign.GetTruncatedTitle(unitDesign, this.ConstructibleName);
            this.ConstructibleImage.Image = null;
            GuiElement guiElement;
            Texture2D  image;
            if (guiPanelHelper.TryGetGuiElement(unitDesign.UnitBodyDefinitionReference, out guiElement) && guiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image))
            {
                this.ConstructibleImage.Image = image;
            }
        }
        else if (guiPanelHelper.TryGetGuiElement(constructibleElementDefinition.ConstructibleElement.Name, out guiElement2))
        {
            AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString(guiElement2.Title), this.ConstructibleName, out this.temp, '.');
            this.ConstructibleName.Text = this.temp;
            Texture2D image2;
            if (guiPanelHelper.TryGetTextureFromIcon(guiElement2, global::GuiPanel.IconSize.Small, out image2))
            {
                this.ConstructibleImage.Image = image2;
            }
            else
            {
                this.ConstructibleImage.Image = null;
            }
        }
        else
        {
            this.ConstructibleName.Text   = string.Empty;
            this.ConstructibleImage.Image = null;
        }
        if (this.AgeTransform.AgeTooltip != null)
        {
            this.AgeTransform.AgeTooltip.Class   = constructibleElementDefinition.ConstructibleElement.TooltipClass;
            this.AgeTransform.AgeTooltip.Content = constructibleElementDefinition.ConstructibleElement.Name;
            if (constructibleElementDefinition.ConstructibleElement is BoosterGeneratorDefinition)
            {
                this.AgeTransform.AgeTooltip.ClientData = new BoosterGeneratorTooltipData(city.Empire, city, constructibleElementDefinition.ConstructibleElement);
            }
            else
            {
                this.AgeTransform.AgeTooltip.ClientData = new ConstructibleTooltipData(city.Empire, city, constructibleElementDefinition.ConstructibleElement);
            }
        }
        this.ConstructibleButton.OnActivateMethod     = "OnOptionSelect";
        this.ConstructibleButton.OnActivateObject     = client;
        this.ConstructibleButton.OnActivateDataObject = constructibleElementDefinition.ConstructibleElement;
        this.ConstructibleButton.OnMiddleClickMethod  = "OnRightClick";
        this.ConstructibleButton.OnMiddleClickObject  = client;
        this.ConstructibleButton.OnRightClickMethod   = "OnRightClick";
        this.ConstructibleButton.OnRightClickObject   = client;
        this.AgeTransform.Enable = (constructibleElementDefinition.Flags.Length == 0);
    }
Пример #2
0
    public static void TruncateString(string src, AgePrimitiveLabel label, out string dest, char truncateChar)
    {
        float width = label.AgeTransform.Width;

        if (width == 0f)
        {
            width = label.AgeTransform.Width;
        }
        AgeUtils.TruncateString(src, label.Font, width, out dest, truncateChar, label.ForceCaps);
    }
Пример #3
0
    public void RefreshContent(global::Empire empire, UnitBodyDefinition unitBody, GameObject client, AgeTransform anchor)
    {
        this.Reset();
        IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper;

        Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper");
        this.UnitBody = unitBody;
        this.GenerateUnit(empire);
        if (this.tooltip != null)
        {
            this.tooltip.Anchor     = anchor;
            this.tooltip.Class      = this.UnitBody.TooltipClass;
            this.tooltip.ClientData = this.temporaryUnit;
            this.tooltip.Content    = this.UnitBody.Name;
        }
        GuiElement guiElement;

        if (guiPanelHelper.TryGetGuiElement(this.UnitBody.Name, out guiElement))
        {
            AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString(guiElement.Title), this.UnitName, out this.temp, '.');
            this.UnitName.Text = this.temp;
            Texture2D image;
            if (guiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image))
            {
                this.UnitPortrait.Image = image;
            }
        }
        else
        {
            this.UnitName.Text      = string.Empty;
            this.UnitPortrait.Image = null;
        }
        if (this.PrivateerGroup != null)
        {
            this.PrivateerGroup.Visible = this.IsMercenary(empire, this.GuiUnit);
        }
        this.UnitToggle.State             = false;
        this.UnitToggle.OnSwitchMethod    = "OnUnitBodyToggle";
        this.UnitToggle.OnSwitchObject    = client;
        this.LifeGauge.AgeTransform.Alpha = 0f;
    }
Пример #4
0
    private void RefreshCurrentResearch()
    {
        DepartmentOfScience         agency       = base.Empire.GetAgency <DepartmentOfScience>();
        DepartmentOfTheTreasury     agency2      = base.Empire.GetAgency <DepartmentOfTheTreasury>();
        Construction                construction = agency.ResearchQueue.Peek();
        IDownloadableContentService service      = Services.GetService <IDownloadableContentService>();

        if (service != null && service.IsShared(DownloadableContent11.ReadOnlyName) && base.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1))
        {
            this.ResearchBuyoutButton.AgeTransform.Visible = true;
            this.ResearchBuyoutLabel.AgeTransform.Visible  = true;
            this.CurrentResearchTitle.AgeTransform.Visible = false;
            this.EmpireResearchPanel.Enable                = true;
            this.EmpireResearchPanel.AgeTooltip.Class      = string.Empty;
            this.EmpireResearchPanel.AgeTooltip.Content    = string.Empty;
            this.EmpireResearchPanel.AgeTooltip.ClientData = null;
            ConstructibleElement technology = null;
            if (this.departmentOfScience.ResearchQueue.Peek() != null)
            {
                technology = this.departmentOfScience.ResearchQueue.Peek().ConstructibleElement;
            }
            float  buyOutTechnologyCost = this.departmentOfScience.GetBuyOutTechnologyCost(technology);
            float  num      = -buyOutTechnologyCost;
            string newValue = GuiFormater.FormatInstantCost(base.Empire, buyOutTechnologyCost, DepartmentOfTheTreasury.Resources.EmpireMoney, true, 0);
            string content;
            if (construction != null)
            {
                this.ResearchBuyoutLabel.AgeTransform.Alpha = 1f;
                TechnologyDefinition technologyDefinition = construction.ConstructibleElement as TechnologyDefinition;
                if (technologyDefinition != null)
                {
                    AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString(DepartmentOfScience.GetTechnologyTitle(technologyDefinition)), this.ResearchBuyoutLabel, out this.format, '.');
                    DepartmentOfScience.BuildTechnologyTooltip(technologyDefinition, base.Empire, this.ResearchBuyoutLabel.AgeTransform.AgeTooltip, MultipleConstructibleTooltipData.TechnologyState.Normal);
                }
                if (agency2.IsTransferOfResourcePossible(base.Empire, DepartmentOfTheTreasury.Resources.TechnologiesBuyOut, ref num) && this.interactionsAllowed)
                {
                    this.ResearchBuyoutButton.AgeTransform.Enable = true;
                    this.ResearchBuyoutButton.AgeTransform.Alpha  = 1f;
                    this.ResearchBuyoutLabel.Text = this.format;
                    content = AgeLocalizer.Instance.LocalizeString("%ResearchBuyoutAvailableFormat").Replace("$Cost", newValue);
                }
                else
                {
                    this.ResearchBuyoutButton.AgeTransform.Enable = false;
                    this.ResearchBuyoutButton.AgeTransform.Alpha  = 0.5f;
                    this.ResearchBuyoutLabel.Text = this.format;
                    content = AgeLocalizer.Instance.LocalizeString("%ResearchBuyoutUnavailableFormat").Replace("$Cost", newValue);
                }
            }
            else
            {
                this.ResearchBuyoutButton.AgeTransform.Enable = false;
                this.ResearchBuyoutButton.AgeTransform.Alpha  = 0.5f;
                this.ResearchBuyoutLabel.Text = "%ResearchNoneTitle";
                this.ResearchBuyoutLabel.AgeTransform.Alpha = 0.5f;
                content = AgeLocalizer.Instance.LocalizeString("%ResearchBuyoutNoSelection");
                this.ResearchBuyoutLabel.AgeTransform.AgeTooltip.Class      = string.Empty;
                this.ResearchBuyoutLabel.AgeTransform.AgeTooltip.Content    = "%ResearchNoneDescription";
                this.ResearchBuyoutLabel.AgeTransform.AgeTooltip.ClientData = null;
            }
            if (this.ResearchBuyoutButton.AgeTransform.AgeTooltip != null)
            {
                this.ResearchBuyoutButton.AgeTransform.AgeTooltip.Content = content;
                return;
            }
        }
        else
        {
            this.ResearchBuyoutButton.AgeTransform.Visible = false;
            this.ResearchBuyoutLabel.AgeTransform.Visible  = false;
            this.CurrentResearchTitle.AgeTransform.Visible = true;
            if (construction != null)
            {
                this.EmpireResearchPanel.Enable = true;
                int num2 = agency2.ComputeConstructionRemainingTurn(base.Empire, construction);
                if (num2 == 2147483647)
                {
                    this.format = string.Format("$Tech ({0})", GuiFormater.Infinite.ToString());
                }
                else
                {
                    this.format = string.Format("$Tech ({0})", QueueGuiItem.FormatNumberOfTurns(num2));
                }
                TechnologyDefinition technologyDefinition2 = construction.ConstructibleElement as TechnologyDefinition;
                if (technologyDefinition2 != null)
                {
                    AgeUtils.TruncateStringWithSubst(this.format, "$Tech", AgeLocalizer.Instance.LocalizeString(DepartmentOfScience.GetTechnologyTitle(technologyDefinition2)), this.CurrentResearchTitle, out this.format, '.');
                    this.CurrentResearchTitle.Text = this.format;
                    DepartmentOfScience.BuildTechnologyTooltip(technologyDefinition2, base.Empire, this.EmpireResearchPanel.AgeTooltip, MultipleConstructibleTooltipData.TechnologyState.Normal);
                }
            }
            else
            {
                this.EmpireResearchPanel.Enable = false;
                AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString("%ResearchNoneTitle"), this.CurrentResearchTitle, out this.format, '.');
                this.CurrentResearchTitle.Text                 = this.format;
                this.EmpireResearchPanel.AgeTooltip.Class      = string.Empty;
                this.EmpireResearchPanel.AgeTooltip.Content    = "%ResearchNoneDescription";
                this.EmpireResearchPanel.AgeTooltip.ClientData = null;
            }
            this.CurrentResearchTitle.Text = this.format;
        }
    }
Пример #5
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;
    }
Пример #6
0
    public void RefreshContent(Player player, Empire playerEmpire, IGuiPanelHelper helper)
    {
        GuiEmpire guiEmpire = new GuiEmpire(player.Empire);

        this.EmpireIcon.Image     = guiEmpire.GetImageTexture(global::GuiPanel.IconSize.LogoSmall, playerEmpire);
        this.EmpireIcon.TintColor = guiEmpire.Color;
        AgeUtils.TruncateString(player.LocalizedName, this.EmpireLeader, out this.temp, '.');
        this.EmpireLeader.Text      = this.temp;
        this.EmpireLeader.TintColor = player.Empire.Color;
        float       value       = 0f;
        MajorEmpire majorEmpire = player.Empire as MajorEmpire;

        if (majorEmpire != null)
        {
            Diagnostics.Assert(majorEmpire.GameScores != null);
            GameScore gameScore = null;
            if (majorEmpire.GameScores.TryGetValue(GameScores.Names.GlobalScore, out gameScore))
            {
                value = gameScore.Value;
            }
        }
        bool            flag    = false;
        ISessionService service = Services.GetService <ISessionService>();

        Diagnostics.Assert(service != null && service.Session != null);
        string lobbyData = service.Session.GetLobbyData <string>(EmpireInfo.EmpireInfoAccessibility, "Default");

        switch ((int)Enum.Parse(typeof(EmpireInfo.Accessibility), lobbyData))
        {
        case 0:
            flag = true;
            break;

        case 1:
            if (player.Empire == playerEmpire)
            {
                flag = true;
            }
            else if (playerEmpire.GetAgency <DepartmentOfForeignAffairs>().GetDiplomaticRelation(player.Empire).State.Name == DiplomaticRelationState.Names.Dead)
            {
                flag = true;
            }
            break;

        case 2:
            if (player.Empire == playerEmpire)
            {
                flag = true;
            }
            else
            {
                DepartmentOfIntelligence agency = playerEmpire.GetAgency <DepartmentOfIntelligence>();
                if (agency != null && agency.IsEmpireInfiltrated(player.Empire))
                {
                    flag = true;
                }
                else if (playerEmpire.GetAgency <DepartmentOfForeignAffairs>().GetDiplomaticRelation(player.Empire).State.Name == DiplomaticRelationState.Names.Dead)
                {
                    flag = true;
                }
            }
            break;

        default:
            flag = true;
            break;
        }
        if (flag || !(playerEmpire is MajorEmpire) || (playerEmpire as MajorEmpire).IsEliminated)
        {
            this.EmpireScore.Text = GuiFormater.FormatGui(value, false, false, false, 1);
        }
        else
        {
            this.EmpireScore.Text = "???";
        }
        this.EmpireScore.TintColor = player.Empire.Color;
        if (player.Empire == playerEmpire)
        {
            this.EmpireDiplomacy.Text      = "-";
            this.EmpireDiplomacy.TintColor = player.Empire.Color;
        }
        else
        {
            DepartmentOfForeignAffairs agency2 = playerEmpire.GetAgency <DepartmentOfForeignAffairs>();
            if (agency2 != null)
            {
                DiplomaticRelation diplomaticRelation = agency2.GetDiplomaticRelation(player.Empire);
                GuiElement         guiElement;
                if (helper.TryGetGuiElement(diplomaticRelation.State.Name, out guiElement))
                {
                    AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString(guiElement.Title), this.EmpireDiplomacy, out this.temp, '.');
                    this.EmpireDiplomacy.Text      = this.temp;
                    this.EmpireDiplomacy.TintColor = player.Empire.Color;
                }
                if (player.Empire.IsControlledByAI)
                {
                    if (diplomaticRelation.State.Name == DiplomaticRelationState.Names.Unknown)
                    {
                        AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString(guiElement.Title), this.EmpireDiplomacy, out this.temp, '.');
                        this.EmpireLeader.Text = this.temp;
                    }
                    else
                    {
                        AgeUtils.TruncateString(player.Empire.LocalizedName, this.EmpireLeader, out this.temp, '.');
                        this.EmpireLeader.Text = this.temp;
                    }
                }
            }
        }
        string key = string.Empty;

        this.EmpireStatus.Text = string.Empty;
        PlayerHelper.ComputePlayerState(ref player);
        key = string.Format("%PlayerState_{0}", player.State);
        string src = string.Empty;

        if (player.Type == PlayerType.Human && service.Session.SessionMode != SessionMode.Single)
        {
            src = string.Format("{0} ({1:0.}ms)", AgeLocalizer.Instance.LocalizeString(key), player.Latency * 1000.0);
        }
        else
        {
            src = AgeLocalizer.Instance.LocalizeString(key);
        }
        AgeUtils.TruncateString(src, this.EmpireStatus, out this.temp, '.');
        AgePrimitiveLabel empireStatus = this.EmpireStatus;

        empireStatus.Text      = empireStatus.Text + this.temp + "\n";
        this.EmpireStatus.Text = this.EmpireStatus.Text.TrimEnd(new char[]
        {
            '\n'
        });
        this.EmpireStatus.TintColor = player.Empire.Color;
    }
Пример #7
0
    public void RefreshContent()
    {
        this.AgeTransform.Enable = true;
        this.AgeTransform.StopSearchingForTooltips = false;
        this.AgeTransform.AgeTooltip.Content       = string.Empty;
        this.ArmySize.TintColor = Color.white;
        this.HeroCard.HeroPortrait.TintColor = Color.white;
        if (this.ArmyNameLabel != null)
        {
            AgeUtils.TruncateString(this.Army.LocalizedName, this.ArmyNameLabel, out this.temp, '.');
            this.ArmyNameLabel.Text = this.temp;
            if (this.Army.IsInEncounter)
            {
                this.ArmyNameLabel.TintColor = this.ColorIfInBattle;
                this.ArmyNameLabel.AgeTransform.AgeTooltip.Content = "%ArmyLockedInBattleDescription";
            }
            else
            {
                this.ArmyNameLabel.TintColor = Color.white;
                this.ArmyNameLabel.AgeTransform.AgeTooltip.Content = string.Empty;
            }
        }
        if (this.HeroCard != null)
        {
            this.HeroCard.RefreshContent(this.isColossusArmy, this.isKaijuArmy);
        }
        if (this.ArmySize != null)
        {
            this.ArmySize.Text = this.Army.CurrentUnitSlot.ToString() + "/" + this.Army.MaximumUnitSlot.ToString();
            AgeTooltip ageTooltip = this.ArmySize.AgeTransform.AgeTooltip;
            if (ageTooltip != null)
            {
                if (this.Army.CurrentUnitSlot > this.Army.MaximumUnitSlot)
                {
                    ageTooltip.Content      = "%ArmyCapacityExceededDescription";
                    this.ArmySize.TintColor = Color.red;
                }
                else
                {
                    ageTooltip.Content = string.Empty;
                }
            }
        }
        if (this.ArmyHPLabel != null)
        {
            float propertyValue  = this.Army.GetPropertyValue(SimulationProperties.Health);
            float propertyValue2 = this.Army.GetPropertyValue(SimulationProperties.MaximumHealth);
            float num            = 0f;
            if (propertyValue2 > 0f)
            {
                num = 100f * (propertyValue / propertyValue2);
            }
            this.ArmyHPGauge.AgeTransform.PercentRight = num;
            if (num >= 75f)
            {
                this.ArmyHPGauge.TintColor = this.FullLifeColor;
            }
            else if (num >= 25f)
            {
                this.ArmyHPGauge.TintColor = this.HalfLifeColor;
            }
            else
            {
                this.ArmyHPGauge.TintColor = this.CriticalLifeColor;
            }
            this.ArmyHPLabel.Text = GuiFormater.FormatGui(Mathf.Floor(propertyValue), false, false, false, 1) + "/" + GuiFormater.FormatGui(Mathf.Floor(propertyValue2), false, false, false, 1);
        }
        if (this.ArmyMovement != null)
        {
            string str  = GuiFormater.FormatGui(this.Army.GetPropertyValue(SimulationProperties.Movement), false, false, false, 1);
            string str2 = GuiFormater.FormatGui(this.Army.GetPropertyValue(SimulationProperties.MaximumMovement), false, false, false, 1);
            this.ArmyMovement.Text = str + "/" + str2;
        }
        if (this.ArmyLocation != null)
        {
            IGameService service = Services.GetService <IGameService>();
            this.ArmyLocation.Text = service.Game.Services.GetService <IWorldPositionningService>().GetRegion(this.Army.WorldPosition).LocalizedName;
        }
        if (this.ArmyUpkeep != null)
        {
            float propertyValue3 = this.Army.GetPropertyValue(SimulationProperties.MilitaryUpkeep);
            this.ArmyUpkeep.Text = GuiFormater.FormatQuantity(-propertyValue3, SimulationProperties.MilitaryUpkeep, 0);
        }
        if (this.HeroCard != null)
        {
            this.HeroCard.AgeTransform.Enable = !this.ReadOnly;
        }
        bool flag;

        if (this.Army.StandardUnits.Count > 0)
        {
            flag = this.Army.StandardUnits.All((Unit unit) => unit.UnitDesign.Tags.Contains(DownloadableContent9.TagColossus));
        }
        else
        {
            flag = false;
        }
        bool flag2 = flag;
        bool flag3;

        if (this.Army.StandardUnits.Count > 0)
        {
            flag3 = this.Army.StandardUnits.Any((Unit unit) => unit.UnitDesign.Tags.Contains(DownloadableContent20.TagKaijuMonster));
        }
        else
        {
            flag3 = false;
        }
        bool flag4 = flag3;

        this.ArmySize.AgeTransform.Visible          = (!flag2 && !flag4);
        this.ColossusArmyLabel.AgeTransform.Visible = flag2;
        if (flag2)
        {
            this.ColossusArmyLabel.Text = "\\7805\\";
            this.ColossusArmyLabel.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ArmyWithColossusDescription");
        }
        this.KaijuArmyLabel.AgeTransform.Visible = flag4;
        if (flag4)
        {
            string text = this.ArmySize.Text;
            this.KaijuArmyLabel.Text = "\\7100\\ " + text;
            this.KaijuArmyLabel.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ArmyWithKaijuMonsterDescription");
        }
        AgeTransform ageTransform = this.ArmyStatusLabel.AgeTransform.GetParent();

        if (this.Army.IsCamouflaged)
        {
            this.ArmyStatusLabel.AgeTransform.Visible = true;
            this.ArmyStatusLabel.Text       = "\\7815\\";
            ageTransform.AgeTooltip.Content = "%ArmyCamouflagedDescription";
        }
        else if (this.Army.IsNaval)
        {
            this.ArmyStatusLabel.AgeTransform.Visible = true;
            this.ArmyStatusLabel.Text       = "\\7825\\";
            ageTransform.AgeTooltip.Content = "%ArmyIsSeafaringDescription";
        }
        else
        {
            this.ArmyStatusLabel.AgeTransform.Visible = false;
            ageTransform.AgeTooltip.Content           = string.Empty;
        }
        this.SelectionToggle.State = false;
    }