예제 #1
0
    public static bool CanELCPTameKaiju(Kaiju kaiju, KaijuTameCost tameCost, global::Empire empire)
    {
        KaijuCouncil            agency  = kaiju.KaijuEmpire.GetAgency <KaijuCouncil>();
        float                   num     = -tameCost.GetValue(empire.SimulationObject);
        DepartmentOfTheTreasury agency2 = empire.GetAgency <DepartmentOfTheTreasury>();

        return(agency2 != null && agency2.IsTransferOfResourcePossible(empire, agency.ELCPResourceName, ref num));
    }
예제 #2
0
    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);
        }
    }
예제 #3
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;
        }
    }
    public override bool CanApply(IDiplomaticContract diplomaticContract, params string[] flags)
    {
        if (!base.CanApply(diplomaticContract, new string[0]))
        {
            return(false);
        }
        Diagnostics.Assert(base.EmpireWhichProvides != null && base.EmpireWhichReceives != null);
        Diagnostics.Assert(base.EmpireWhichProvides.Index != base.EmpireWhichReceives.Index);
        DepartmentOfTheTreasury agency  = base.EmpireWhichProvides.GetAgency <DepartmentOfTheTreasury>();
        DepartmentOfTheTreasury agency2 = base.EmpireWhichReceives.GetAgency <DepartmentOfTheTreasury>();

        Diagnostics.Assert(agency != null && agency2 != null);
        float num = -this.Amount;

        if ((this.BufferedAmount != this.Amount || this.BufferedAmount == 0f) && !agency.IsTransferOfResourcePossible(base.EmpireWhichProvides, this.ResourceName, ref num))
        {
            return(false);
        }
        num = this.Amount;
        return(agency2.IsTransferOfResourcePossible(base.EmpireWhichReceives, this.ResourceName, ref num));
    }
예제 #5
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;
        }
    }