コード例 #1
0
    private void RefreshCostGroup(DepartmentOfScience.ConstructibleElement.State state)
    {
        bool flag = state != DepartmentOfScience.ConstructibleElement.State.Researched && state != DepartmentOfScience.ConstructibleElement.State.ResearchedButUnavailable;

        if (this.ShowCaptionCost && flag)
        {
            Amplitude.Unity.Gui.IGuiService service = Services.GetService <global::IGuiService>();
            Diagnostics.Assert(service != null);
            DepartmentOfTheTreasury agency = this.empire.GetAgency <DepartmentOfTheTreasury>();
            Diagnostics.Assert(agency != null);
            string empty = string.Empty;
            int    num   = 0;
            PanelFeatureCost.ComputeCostAndTurn(service, this.TechnologyDefinition, agency, this.empire, out empty, out num);
            if (string.IsNullOrEmpty(empty))
            {
                this.CaptionCostGroup.Visible = false;
            }
            else
            {
                this.CostLabel.Text           = empty;
                this.CaptionCostGroup.Visible = true;
            }
        }
        else if (this.CaptionCostGroup != null)
        {
            this.CaptionCostGroup.Visible = false;
        }
    }
コード例 #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);
 }
コード例 #3
0
    private void RefreshCosts()
    {
        ConstructionQueue    constructionQueueForEmpire = this.kaijuTechsService.GetConstructionQueueForEmpire(base.Empire);
        ConstructibleElement constructibleElement       = null;

        if (constructionQueueForEmpire.Peek() != null)
        {
            constructibleElement = constructionQueueForEmpire.Peek().ConstructibleElement;
        }
        int    num = 0;
        string text;

        PanelFeatureCost.ComputeCostAndTurn(base.GuiService, constructionQueueForEmpire.PendingConstructions, this.departmentOfTheTreasury, base.Empire, out text, out num);
        if (constructibleElement != null)
        {
            if (this.CanAffordTechs())
            {
                this.buyoutCostLabel.Text             = text;
                this.buyoutButton.AgeTransform.Enable = true;
                this.buyoutButton.AgeTransform.Alpha  = 1f;
                string text2 = AgeLocalizer.Instance.LocalizeString("%KaijuUnlockBuyoutAvailableFormat").Replace("$Cost", text);
            }
            else
            {
                this.buyoutCostLabel.Text             = text;
                this.buyoutButton.AgeTransform.Enable = false;
                this.buyoutButton.AgeTransform.Alpha  = 0.5f;
                string text2 = AgeLocalizer.Instance.LocalizeString("%KaijuUnlockBuyoutUnavailableFormat").Replace("$Cost", text);
            }
        }
        else
        {
            this.buyoutButton.AgeTransform.Enable = false;
            this.buyoutButton.AgeTransform.Alpha  = 0.5f;
            this.buyoutCostLabel.Text             = "%ResearchVoidSymbol";
            string text2 = AgeLocalizer.Instance.LocalizeString("%KaijuUnlockBuyoutNoSelectionDescription");
        }
    }
コード例 #4
0
 public void Show(ConstructibleTooltipData constructibleData)
 {
     this.ConstructibleTitle.Text = AgeLocalizer.Instance.LocalizeString(constructibleData.Title);
     this.effectDescriptions.Clear();
     this.simulationEffectParser.ParseSimulationDescriptor(constructibleData, this.effectDescriptions, null, false, false);
     this.EffectMapper.LoadEffects(this.effectDescriptions, true);
     if (this.EffectMapper.EffectsList.Height == 0f)
     {
         this.EffectTitle.Text = AgeLocalizer.Instance.LocalizeString("%FeatureNoEffectsTitle");
     }
     else
     {
         this.EffectTitle.Text = AgeLocalizer.Instance.LocalizeString("%FeatureEffectsTitle");
     }
     this.EffectGroup.Height  = this.EffectMapper.EffectsList.PixelOffsetTop + this.EffectMapper.EffectsList.PixelMarginTop + this.EffectMapper.EffectsList.Height + this.EffectMapper.EffectsList.PixelMarginBottom + this.EffectMapper.EffectsList.PixelOffsetBottom;
     this.CostGroup.Visible   = true;
     this.CostGroup.Y         = this.ConstructibleTitle.AgeTransform.Height + this.EffectGroup.Height;
     this.AgeTransform.Height = this.CostGroup.Y;
     if (constructibleData != null && ((ICostFeatureProvider)constructibleData).Constructible != null && ((ICostFeatureProvider)constructibleData).Empire != null)
     {
         DepartmentOfTheTreasury agency  = ((ICostFeatureProvider)constructibleData).Empire.GetAgency <DepartmentOfTheTreasury>();
         SimulationObjectWrapper context = (((ICostFeatureProvider)constructibleData).Context == null) ? ((ICostFeatureProvider)constructibleData).Empire : ((ICostFeatureProvider)constructibleData).Context;
         string text = string.Empty;
         int    num;
         PanelFeatureCost.ComputeCostAndTurn(this.guiService, ((ICostFeatureProvider)constructibleData).Constructible, agency, context, out text, out num);
         this.TurnIcon.AgeTransform.Visible  = false;
         this.TurnValue.AgeTransform.Visible = false;
         if (((ICostFeatureProvider)constructibleData).Constructible is CreepingNodeImprovementDefinition)
         {
             IDatabase <SimulationDescriptor> database = Databases.GetDatabase <SimulationDescriptor>(false);
             text = ((!(text == "-")) ? text : string.Empty);
             CreepingNodeImprovementDefinition creepingNodeImprovementDefinition = ((ICostFeatureProvider)constructibleData).Constructible as CreepingNodeImprovementDefinition;
             SimulationObject     simulationObject = new SimulationObject("DummyNode");
             SimulationDescriptor descriptor       = null;
             if (database.TryGetValue("ClassCreepingNode", out descriptor))
             {
                 simulationObject.AddDescriptor(descriptor);
             }
             else
             {
                 Diagnostics.LogError("Could not find the class creeping node descriptor");
             }
             float propertyBaseValue = simulationObject.GetPropertyBaseValue(creepingNodeImprovementDefinition.BaseCostPropertyName);
             float num2          = simulationObject.GetPropertyBaseValue(SimulationProperties.NodeCostIncrement);
             float propertyValue = ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.NodeCostIncrementModifier);
             num2 *= propertyValue;
             if (creepingNodeImprovementDefinition.SubCategory == "SubCategoryVillage")
             {
                 num2 *= ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.NodeOvergrownVillageCostModifier);
             }
             float  propertyValue2 = ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.NumberOfCreepingNodes);
             float  propertyValue3 = ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.NumberOfFinishedCreepingNodes);
             int    num3           = Mathf.CeilToInt(propertyBaseValue + num2 * (2f * propertyValue2 - propertyValue3 + 1f));
             float  propertyValue4 = ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.GameSpeedMultiplier);
             int    num4           = (int)Math.Max(0.0, Math.Ceiling((double)((float)creepingNodeImprovementDefinition.ConstructionTurns * propertyValue4)));
             string str            = string.Format(AgeLocalizer.Instance.LocalizeString("%FeaturePanelNodeCost"), num3.ToString(), num4.ToString());
             text = text + " " + str;
         }
         if (!string.IsNullOrEmpty(text))
         {
             this.CostValue.Text = text;
             if (this.CostValue.AgeTransform.PixelMarginTop == this.CostTitle.AgeTransform.PixelMarginTop)
             {
                 this.CostValue.AgeTransform.PixelMarginLeft = 2f * this.CostTitle.AgeTransform.PixelMarginLeft + this.CostTitle.Font.ComputeTextWidth(AgeLocalizer.Instance.LocalizeString(this.CostTitle.Text), this.CostTitle.ForceCaps, false);
             }
             this.AgeTransform.Height += this.CostTitle.AgeTransform.Height;
             return;
         }
     }
     else
     {
         this.CostGroup.Visible = false;
     }
 }
コード例 #5
0
    protected override IEnumerator OnShow(params object[] parameters)
    {
        this.CostValue.Text = string.Empty;
        this.TurnValue.Text = string.Empty + GuiFormater.Infinite;
        ICostFeatureProvider provider = this.context as ICostFeatureProvider;

        if (provider != null && provider.Constructible != null && provider.Empire != null)
        {
            DepartmentOfTheTreasury departmentOfTheTreasury = provider.Empire.GetAgency <DepartmentOfTheTreasury>();
            SimulationObjectWrapper context = (provider.Context == null) ? provider.Empire : provider.Context;
            string costString;
            int    turn;
            PanelFeatureCost.ComputeCostAndTurn(base.GuiService, provider.Constructible, departmentOfTheTreasury, context, out costString, out turn);
            this.CostValue.AgeTransform.PixelMarginRight = 0f;
            if (this.DisplayTurnCost)
            {
                this.CostValue.AgeTransform.PixelMarginRight = base.AgeTransform.Width - this.TurnValue.AgeTransform.X - 20f * AgeUtils.CurrentUpscaleFactor();
            }
            this.CostValue.AgeTransform.ComputeExtents(Rect.MinMaxRect(0f, 0f, 0f, 0f));
            this.CostValue.Text = costString;
            this.CostTitle.Text = "%FeatureCostTitle";
            if (provider.Constructible is KaijuTechnologyDefinition)
            {
                KaijuTechnologyDefinition kaijuTechnologyDefinition = provider.Constructible as KaijuTechnologyDefinition;
                IGameService       gameService       = Services.GetService <IGameService>();
                IKaijuTechsService kaijuTechsService = gameService.Game.Services.GetService <IKaijuTechsService>();
                if (kaijuTechsService.GetTechnologyState(kaijuTechnologyDefinition, provider.Empire) == DepartmentOfScience.ConstructibleElement.State.Researched)
                {
                    this.CostTitle.Text = "%FeatureAlreadyUnlockedTitle";
                    costString          = " ";
                }
            }
            this.CostValue.Text = costString;
            if (this.CostValue.AgeTransform.PixelMarginTop == this.CostTitle.AgeTransform.PixelMarginTop)
            {
                float pixelMargin = 2f * this.CostTitle.AgeTransform.PixelMarginLeft + this.CostTitle.Font.ComputeTextWidth(AgeLocalizer.Instance.LocalizeString(this.CostTitle.Text), this.CostTitle.ForceCaps, false);
                this.CostValue.AgeTransform.PixelMarginLeft = pixelMargin;
            }
            if (provider.Context == null)
            {
                this.TurnValue.Text = string.Empty;
                this.TurnIcon.AgeTransform.Visible = false;
            }
            else
            {
                this.TurnIcon.AgeTransform.Visible = true;
                if (turn == 2147483647)
                {
                    this.TurnValue.Text = string.Empty + GuiFormater.Infinite;
                }
                else
                {
                    turn = Mathf.Max(1, turn);
                    this.TurnValue.Text = turn.ToString();
                }
            }
        }
        yield return(base.OnShow(parameters));

        this.CostValue.AgeTransform.Height = this.CostValue.Font.LineHeight * (float)this.CostValue.TextLines.Count;
        base.AgeTransform.Height           = this.CostValue.Font.LineHeight * (float)this.CostValue.TextLines.Count + this.CostValue.AgeTransform.PixelMarginTop + this.CostValue.AgeTransform.PixelMarginBottom;
        base.AgeTransform.Visible          = !string.IsNullOrEmpty(this.CostValue.Text);
        if (!this.DisplayTurnCost)
        {
            this.TurnIcon.AgeTransform.Visible  = false;
            this.TurnValue.AgeTransform.Visible = false;
        }
        yield break;
    }
コード例 #6
0
    protected override IEnumerator OnShow(params object[] parameters)
    {
        ConstructibleTooltipData constructibleTooltipData = this.context as ConstructibleTooltipData;

        if (constructibleTooltipData != null && constructibleTooltipData.Empire != null && constructibleTooltipData.Constructible != null)
        {
            DepartmentOfTheTreasury agency  = constructibleTooltipData.Empire.GetAgency <DepartmentOfTheTreasury>();
            DepartmentOfTheInterior agency2 = constructibleTooltipData.Empire.GetAgency <DepartmentOfTheInterior>();
            string text = string.Empty;
            if (agency2.MainCity != null)
            {
                int num;
                PanelFeatureCost.ComputeCostAndTurn(this.guiService, constructibleTooltipData.Constructible, agency, agency2.MainCity, out text, out num);
            }
            else
            {
                int num2;
                PanelFeatureCost.ComputeCostAndTurn(this.guiService, constructibleTooltipData.Constructible, agency, constructibleTooltipData.Empire, out text, out num2);
            }
            text = ((!(text == "-")) ? text : string.Empty);
            CreepingNodeImprovementDefinition creepingNodeImprovementDefinition = constructibleTooltipData.Constructible as CreepingNodeImprovementDefinition;
            SimulationObject     simulationObject = new SimulationObject("DummyNode");
            SimulationDescriptor descriptor       = null;
            if (this.simulationDescriptorDatabase.TryGetValue("ClassCreepingNode", out descriptor))
            {
                simulationObject.AddDescriptor(descriptor);
            }
            else
            {
                Diagnostics.LogError("Could not find the class creeping node descriptor");
            }
            float propertyBaseValue = simulationObject.GetPropertyBaseValue(creepingNodeImprovementDefinition.BaseCostPropertyName);
            float num3          = simulationObject.GetPropertyBaseValue(SimulationProperties.NodeCostIncrement);
            float propertyValue = constructibleTooltipData.Empire.GetPropertyValue(SimulationProperties.NodeCostIncrementModifier);
            num3 *= propertyValue;
            if (creepingNodeImprovementDefinition.SubCategory == "SubCategoryVillage")
            {
                num3 *= constructibleTooltipData.Empire.GetPropertyValue(SimulationProperties.NodeOvergrownVillageCostModifier);
            }
            float  propertyValue2 = constructibleTooltipData.Empire.GetPropertyValue(SimulationProperties.NumberOfCreepingNodes);
            float  propertyValue3 = constructibleTooltipData.Empire.GetPropertyValue(SimulationProperties.NumberOfFinishedCreepingNodes);
            int    num4           = Mathf.CeilToInt(propertyBaseValue + num3 * (2f * propertyValue2 - propertyValue3 + 1f));
            float  propertyValue4 = constructibleTooltipData.Empire.GetPropertyValue(SimulationProperties.GameSpeedMultiplier);
            int    num5           = (int)Math.Max(0.0, Math.Ceiling((double)((float)creepingNodeImprovementDefinition.ConstructionTurns * propertyValue4)));
            string str            = string.Format(AgeLocalizer.Instance.LocalizeString("%FeaturePanelNodeCost"), num4.ToString(), num5.ToString());
            text = text + " " + str;
            bool flag = this.CanAfforFoodCost(constructibleTooltipData.Empire, creepingNodeImprovementDefinition);
            if (!string.IsNullOrEmpty(text))
            {
                this.CostValue.Text      = text;
                this.CostValue.TintColor = ((!flag) ? this.CantAffordColor : this.CanAffordColor);
                if (this.CostValue.AgeTransform.PixelMarginTop == this.CostTitle.AgeTransform.PixelMarginTop)
                {
                    this.CostValue.AgeTransform.PixelMarginLeft = 2f * this.CostTitle.AgeTransform.PixelMarginLeft + this.CostTitle.Font.ComputeTextWidth(AgeLocalizer.Instance.LocalizeString(this.CostTitle.Text), this.CostTitle.ForceCaps, false);
                }
            }
        }
        yield return(base.OnShow(parameters));

        yield break;
    }