public void DisplayCost(AgePrimitiveLabel costLabel)
    {
        string text = string.Empty;

        text           = GuiFormater.FormatInstantCost(this.Term.EmpireWhichProposes, this.EmpirePointCost, DepartmentOfTheTreasury.Resources.EmpirePoint, false, 0);
        costLabel.Text = text;
    }
Exemple #2
0
 public static void ComputeCostAndTurn(Amplitude.Unity.Gui.IGuiService guiService, ReadOnlyCollection <Construction> constructibles, DepartmentOfTheTreasury departmentOfTheTreasury, SimulationObjectWrapper context, out string costString, out int turn)
 {
     PanelFeatureCost.costByResource.Clear();
     for (int i = 0; i < constructibles.Count; i++)
     {
         ConstructibleElement constructibleElement = constructibles[i].ConstructibleElement;
         if (constructibleElement.Costs != null)
         {
             if (constructibleElement is TechnologyDefinition && context.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1) && (constructibleElement as TechnologyDefinition).TechnologyFlags != DepartmentOfScience.ConstructibleElement.TechnologyFlag.OrbUnlock && (constructibleElement as TechnologyDefinition).TechnologyFlags != DepartmentOfScience.ConstructibleElement.TechnologyFlag.KaijuUnlock)
             {
                 costString = string.Empty;
                 turn       = -1;
                 global::Empire empire = context as global::Empire;
                 if (empire == null)
                 {
                     Diagnostics.LogError("Empire is null.");
                     return;
                 }
                 DepartmentOfScience agency = empire.GetAgency <DepartmentOfScience>();
                 if (agency == null)
                 {
                     Diagnostics.LogError("Department of science is null");
                     return;
                 }
                 float buyOutTechnologyCost = agency.GetBuyOutTechnologyCost(constructibleElement);
                 if (buyOutTechnologyCost != 3.40282347E+38f)
                 {
                     costString = GuiFormater.FormatInstantCost(empire, buyOutTechnologyCost, DepartmentOfTheTreasury.Resources.EmpireMoney, true, 0);
                     return;
                 }
                 costString = "-";
                 return;
             }
             else
             {
                 for (int j = 0; j < constructibleElement.Costs.Length; j++)
                 {
                     if (constructibleElement.Costs[j] is PopulationConstructionCost)
                     {
                         PopulationConstructionCost populationConstructionCost = constructibleElement.Costs[j] as PopulationConstructionCost;
                         PanelFeatureCost.AppendCost(SimulationProperties.Population, populationConstructionCost.PopulationValue, true);
                     }
                     else
                     {
                         float productionCostWithBonus = DepartmentOfTheTreasury.GetProductionCostWithBonus(context, constructibleElement, constructibleElement.Costs[j], true);
                         PanelFeatureCost.AppendCost(constructibleElement.Costs[j].ResourceName, productionCostWithBonus, constructibleElement.Costs[j].Instant || constructibleElement.Costs[j].InstantOnCompletion);
                     }
                 }
             }
         }
     }
     PanelFeatureCost.GetCostAndTurn(guiService, departmentOfTheTreasury, context, out costString, out turn);
 }
    public static void RefreshPopulationBuyoutButton(Amplitude.Unity.Game.Empire observer, City city, AgeControlButton populationBuyoutButton)
    {
        if (observer != city.Empire)
        {
            populationBuyoutButton.AgeTransform.Enable = false;
            return;
        }
        float propertyValue            = city.GetPropertyValue(SimulationProperties.CityGrowthStock);
        float propertyValue2           = city.GetPropertyValue(SimulationProperties.NetCityGrowth);
        float propertyValue3           = city.GetPropertyValue(SimulationProperties.Population);
        DepartmentOfTheInterior agency = city.Empire.GetAgency <DepartmentOfTheInterior>();
        float num;
        float num2;

        agency.GetGrowthLimits(propertyValue3, out num, out num2);
        if (propertyValue + propertyValue2 >= num2)
        {
            populationBuyoutButton.AgeTransform.Enable             = false;
            populationBuyoutButton.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%CityBuyoutPopulationNotNeededDescription");
            return;
        }
        float propertyValue4 = city.Empire.GetPropertyValue(SimulationProperties.PopulationBuyoutCooldown);

        if (propertyValue4 > 0f)
        {
            populationBuyoutButton.AgeTransform.Enable             = false;
            populationBuyoutButton.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%CityBuyoutPopulationCooldownDescription").Replace("$Cooldown", propertyValue4.ToString());
            return;
        }
        float num3 = -DepartmentOfTheTreasury.GetPopulationBuyOutCost(city);
        ResourceDefinition      resourceDefinition = ResourceDefinition.GetResourceDefinition(DepartmentOfTheTreasury.Resources.PopulationBuyout);
        string                  newValue           = GuiFormater.FormatInstantCost(city.Empire, -num3, resourceDefinition.GetName(city.Empire), true, 0);
        DepartmentOfTheTreasury agency2            = city.Empire.GetAgency <DepartmentOfTheTreasury>();

        if (agency2.IsTransferOfResourcePossible(city.Empire, DepartmentOfTheTreasury.Resources.PopulationBuyout, ref num3))
        {
            populationBuyoutButton.AgeTransform.Enable             = CityInfoPanel.interactionsAllowed;
            populationBuyoutButton.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%CityBuyoutPopulationDescription").Replace("$Cost", newValue);
        }
        else
        {
            populationBuyoutButton.AgeTransform.Enable             = false;
            populationBuyoutButton.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%CityCannotBuyoutPopulationDescription").Replace("$Cost", newValue);
        }
    }
    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);
    }
Exemple #5
0
    public void RefreshBuyout(AgeControlButton buyoutButton)
    {
        DepartmentOfTheTreasury agency     = base.Empire.GetAgency <DepartmentOfTheTreasury>();
        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 text = GuiFormater.FormatInstantCost(base.Empire, buyOutTechnologyCost, DepartmentOfTheTreasury.Resources.EmpireMoney, true, 0);
        string content;

        if (buyOutTechnologyCost != 3.40282347E+38f)
        {
            if (agency.IsTransferOfResourcePossible(base.Empire, DepartmentOfTheTreasury.Resources.TechnologiesBuyOut, ref num) && this.interactionsAllowed)
            {
                buyoutButton.AgeTransform.Enable  = true;
                buyoutButton.AgeTransform.Alpha   = 1f;
                this.ResearchBuyoutCostLabel.Text = text;
                content = AgeLocalizer.Instance.LocalizeString("%ResearchBuyoutAvailableFormat").Replace("$Cost", text);
            }
            else
            {
                buyoutButton.AgeTransform.Enable  = false;
                buyoutButton.AgeTransform.Alpha   = 0.5f;
                this.ResearchBuyoutCostLabel.Text = text;
                content = AgeLocalizer.Instance.LocalizeString("%ResearchBuyoutUnavailableFormat").Replace("$Cost", text);
            }
        }
        else
        {
            buyoutButton.AgeTransform.Enable  = false;
            buyoutButton.AgeTransform.Alpha   = 0.5f;
            this.ResearchBuyoutCostLabel.Text = "%ResearchVoidSymbol";
            content = AgeLocalizer.Instance.LocalizeString("%ResearchBuyoutNoSelection");
        }
        if (buyoutButton.AgeTransform.AgeTooltip != null)
        {
            buyoutButton.AgeTransform.AgeTooltip.Content = content;
        }
    }
    private void RefreshButtons()
    {
        this.TheirEmpireNameDropList.AgeTransform.Enable = this.interactionsAllowed;
        if (this.SelectedEmpire == null || this.DepartmentOfForeignAffairs == null || this.PlayerDiplomaticRelationWithOther == null || this.PlayerDiplomaticRelationWithOther.State.Name == DiplomaticRelationState.Names.Dead)
        {
            this.OfferButton.AgeTransform.Visible = false;
            this.OfferCostLabel.Text = string.Empty;
            this.CounterOfferButton.AgeTransform.Visible = false;
            this.CounterOfferMyCostLabel.Text            = string.Empty;
            this.ResetButton.AgeTransform.Visible        = false;
            return;
        }
        float  cost  = this.ComputeContractCost(this.DiplomaticContract.EmpireWhichProposes);
        string text  = GuiFormater.FormatInstantCost(this.DiplomaticContract.EmpireWhichProposes, cost, SimulationProperties.EmpirePoint, false, 0);
        float  cost2 = this.ComputeContractCost(this.DiplomaticContract.EmpireWhichReceives);
        string text2 = GuiFormater.FormatInstantCost(this.DiplomaticContract.EmpireWhichReceives, cost2, SimulationProperties.EmpirePoint, true, 0);
        bool   flag  = base.Empire != this.DiplomaticContract.EmpireWhichInitiated;

        if (flag)
        {
            this.OfferButton.AgeTransform.Visible = false;
            this.OfferCostLabel.Text = string.Empty;
            this.CounterOfferButton.AgeTransform.Visible     = true;
            this.CounterOfferMyCostLabel.Text                = text;
            this.CounterOfferTheirCostLabel.Text             = text2;
            this.ResetButton.AgeTransform.Visible            = true;
            this.ResetButton.AgeTransform.Enable             = false;
            this.ResetButton.AgeTransform.AgeTooltip.Content = "%NegotiationCannotResetCounterOfferDescription";
            this.CounterOfferButton.AgeTransform.Enable      = (this.CanContractBeValidated() && this.interactionsAllowed);
        }
        else
        {
            this.OfferButton.AgeTransform.Visible = true;
            this.OfferCostLabel.Text = text;
            this.CounterOfferButton.AgeTransform.Visible     = false;
            this.CounterOfferMyCostLabel.Text                = string.Empty;
            this.ResetButton.AgeTransform.Visible            = true;
            this.ResetButton.AgeTransform.Enable             = this.interactionsAllowed;
            this.ResetButton.AgeTransform.AgeTooltip.Content = "%NegotiationResetDescription";
            this.OfferButton.AgeTransform.Enable             = (this.CanContractBeValidated() && this.interactionsAllowed);
        }
    }
    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;
        }
    }