private void AssignLuxuryTypes(Dictionary <string, List <PointOfInterestTemplate> > availableLuxuries) { Random random = new Random(World.Seed); foreach (DepartmentOfScience.ConstructibleElement constructibleElement in this.technologyDatabase) { if (constructibleElement.TechnologyFlags == DepartmentOfScience.ConstructibleElement.TechnologyFlag.KaijuUnlock) { KaijuTechnologyDefinition kaijuTechnologyDefinition = constructibleElement as KaijuTechnologyDefinition; KaijuUnlockCost kaijuUnlockCost = kaijuTechnologyDefinition.KaijuUnlockCost; if (kaijuUnlockCost != null) { List <PointOfInterestTemplate> list = new List <PointOfInterestTemplate>(); list.AddRange(availableLuxuries[kaijuUnlockCost.LuxuryTier]); if (kaijuUnlockCost.LuxuryTier != "Tier3" && availableLuxuries[kaijuUnlockCost.LuxuryTier].Count <= 2) { list.AddRange((!(kaijuUnlockCost.LuxuryTier == "Tier1")) ? availableLuxuries["Tier1"] : availableLuxuries["Tier2"]); } PointOfInterestTemplate pointOfInterestTemplate = list[random.Next(list.Count)]; string empty = string.Empty; if (pointOfInterestTemplate.Properties.TryGetValue("ResourceName", out empty)) { kaijuTechnologyDefinition.SetKaijuUnlockCostResourceName(empty); } } } } }
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; }