Пример #1
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;
     }
 }
Пример #2
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;
    }