public override void LoadContent() { base.LoadContent(); this.UnlocksRect = new Rectangle(this.MidContainer.X + 20, this.MidContainer.Y + this.MidContainer.Height - 20, this.r.Width - 40, this.r.Height - this.MidContainer.Height - this.TitleRect.Height - 20); Submenu UnlocksSubMenu = new Submenu(base.ScreenManager, this.UnlocksRect); this.UnlockSL = new ScrollList(UnlocksSubMenu, 100); Technology unlockedTech = ResourceManager.TechTree[this.TechUID]; foreach (Technology.UnlockedMod UnlockedMod in unlockedTech.ModulesUnlocked) { if (EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).data.Traits.ShipType == UnlockedMod.Type || UnlockedMod.Type == null || UnlockedMod.Type == EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).GetTDict()[this.TechUID].AcquiredFrom) { UnlockItem unlock = new UnlockItem() { Type = "SHIPMODULE", module = ResourceManager.ShipModulesDict[UnlockedMod.ModuleUID], Description = Localizer.Token(ResourceManager.ShipModulesDict[UnlockedMod.ModuleUID].DescriptionIndex), privateName = Localizer.Token(ResourceManager.ShipModulesDict[UnlockedMod.ModuleUID].NameIndex) }; this.UnlockSL.AddItem(unlock); } } foreach (Technology.UnlockedTroop troop in unlockedTech.TroopsUnlocked) { if (troop.Type == EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).data.Traits.ShipType || troop.Type == "ALL" || troop.Type == null || troop.Type == EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).GetTDict()[this.TechUID].AcquiredFrom) { UnlockItem unlock = new UnlockItem() { Type = "TROOP", troop = ResourceManager.TroopsDict[troop.Name] }; this.UnlockSL.AddItem(unlock); } } foreach (Technology.UnlockedHull hull in unlockedTech.HullsUnlocked) { if (EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).data.Traits.ShipType == hull.ShipType || hull.ShipType == null || hull.ShipType == EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).GetTDict()[this.TechUID].AcquiredFrom) { UnlockItem unlock = new UnlockItem() { Type = "HULL", privateName = hull.Name, HullUnlocked = ResourceManager.HullsDict[hull.Name].Name }; int size = 0; foreach (ModuleSlotData moduleSlotList in ResourceManager.HullsDict[hull.Name].ModuleSlotList) { size++; } unlock.Description = string.Concat(Localizer.Token(4042), " ", Localizer.GetRole(ResourceManager.HullsDict[hull.Name].Role, EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty))); this.UnlockSL.AddItem(unlock); } } foreach (Technology.UnlockedBuilding UnlockedBuilding in unlockedTech.BuildingsUnlocked) { if (EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).data.Traits.ShipType == UnlockedBuilding.Type || UnlockedBuilding.Type == null || UnlockedBuilding.Type == EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).GetTDict()[this.TechUID].AcquiredFrom) { UnlockItem unlock = new UnlockItem() { Type = "BUILDING", building = ResourceManager.BuildingsDict[UnlockedBuilding.Name] }; this.UnlockSL.AddItem(unlock); } } foreach (Technology.UnlockedBonus UnlockedBonus in unlockedTech.BonusUnlocked) { if (EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).data.Traits.ShipType == UnlockedBonus.Type || UnlockedBonus.Type == null || UnlockedBonus.Type == EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).GetTDict()[this.TechUID].AcquiredFrom) { UnlockItem unlock = new UnlockItem() { Type = "ADVANCE", privateName = UnlockedBonus.Name, Description = Localizer.Token(UnlockedBonus.BonusIndex) }; this.UnlockSL.AddItem(unlock); } } }
public TreeNode(Vector2 Position, TechEntry Tech, ResearchScreenNew screen) { if (GlobalStats.Config.Language == "Russian" || GlobalStats.Config.Language == "Polish") { this.TitleFont = Fonts.Arial10; } this.screen = screen; this.tech = Tech; this.TechName = string.Concat(Localizer.Token(ResourceManager.TechTree[Tech.UID].NameIndex), ResourceManager.TechTree[Tech.UID].MaxLevel > 1 ? " " + NumberToRomanConvertor.NumberToRoman(Tech.level) + "/" + NumberToRomanConvertor.NumberToRoman(ResourceManager.TechTree[Tech.UID].MaxLevel) : ""); this.BaseRect.X = (int)Position.X; this.BaseRect.Y = (int)Position.Y; this.progressRect = new Rectangle(this.BaseRect.X + 14, this.BaseRect.Y + 21, 1, 34); int numUnlocks = 0; for (int i = 0; i < ResourceManager.TechTree[this.tech.UID].ModulesUnlocked.Count; i++) { if (numUnlocks > 3) break; if (ResourceManager.TechTree[this.tech.UID].ModulesUnlocked[i].Type == EmpireManager.GetEmpireByName(screen.empireUI.screen.PlayerLoyalty).data.Traits.ShipType || ResourceManager.TechTree[this.tech.UID].ModulesUnlocked[i].Type == null || ResourceManager.TechTree[this.tech.UID].ModulesUnlocked[i].Type == EmpireManager.GetEmpireByName(screen.empireUI.screen.PlayerLoyalty).GetTDict()[this.tech.UID].AcquiredFrom) { UnlockItem unlock = new UnlockItem(); unlock.module = ResourceManager.ShipModulesDict[ResourceManager.TechTree[this.tech.UID].ModulesUnlocked[i].ModuleUID]; unlock.privateName = Localizer.Token(unlock.module.NameIndex); unlock.Description = Localizer.Token(unlock.module.DescriptionIndex); unlock.Type = "SHIPMODULE"; this.Unlocks.Add(unlock); numUnlocks++; } } for (int i = 0; i < ResourceManager.TechTree[this.tech.UID].BonusUnlocked.Count; i++) { if (numUnlocks > 3) break; if (ResourceManager.TechTree[this.tech.UID].BonusUnlocked[i].Type == EmpireManager.GetEmpireByName(screen.empireUI.screen.PlayerLoyalty).data.Traits.ShipType || ResourceManager.TechTree[this.tech.UID].BonusUnlocked[i].Type == null || ResourceManager.TechTree[this.tech.UID].BonusUnlocked[i].Type == EmpireManager.GetEmpireByName(screen.empireUI.screen.PlayerLoyalty).GetTDict()[this.tech.UID].AcquiredFrom) { UnlockItem unlock = new UnlockItem() { privateName = ResourceManager.TechTree[this.tech.UID].BonusUnlocked[i].Name, Description = Localizer.Token(ResourceManager.TechTree[this.tech.UID].BonusUnlocked[i].BonusIndex), Type = "ADVANCE" }; numUnlocks++; this.Unlocks.Add(unlock); } } for (int i = 0; i < ResourceManager.TechTree[this.tech.UID].BuildingsUnlocked.Count; i++) { if (numUnlocks > 3) break; if (ResourceManager.TechTree[this.tech.UID].BuildingsUnlocked[i].Type == EmpireManager.GetEmpireByName(screen.empireUI.screen.PlayerLoyalty).data.Traits.ShipType || ResourceManager.TechTree[this.tech.UID].BuildingsUnlocked[i].Type == null || ResourceManager.TechTree[this.tech.UID].BuildingsUnlocked[i].Type == EmpireManager.GetEmpireByName(screen.empireUI.screen.PlayerLoyalty).GetTDict()[this.tech.UID].AcquiredFrom) { UnlockItem unlock = new UnlockItem(); unlock.building = ResourceManager.BuildingsDict[ResourceManager.TechTree[this.tech.UID].BuildingsUnlocked[i].Name]; unlock.privateName = Localizer.Token(unlock.building.NameTranslationIndex); unlock.Description = Localizer.Token(unlock.building.DescriptionIndex); unlock.Type = "BUILDING"; numUnlocks++; this.Unlocks.Add(unlock); } } for (int i = 0; i < ResourceManager.TechTree[this.tech.UID].HullsUnlocked.Count; i++) { if (numUnlocks > 3) break; if (ResourceManager.TechTree[this.tech.UID].HullsUnlocked[i].ShipType == EmpireManager.GetEmpireByName(screen.empireUI.screen.PlayerLoyalty).data.Traits.ShipType || ResourceManager.TechTree[this.tech.UID].HullsUnlocked[i].ShipType == null || ResourceManager.TechTree[this.tech.UID].HullsUnlocked[i].ShipType == EmpireManager.GetEmpireByName(screen.empireUI.screen.PlayerLoyalty).GetTDict()[this.tech.UID].AcquiredFrom) { UnlockItem unlock = new UnlockItem() { HullUnlocked = ResourceManager.TechTree[this.tech.UID].HullsUnlocked[i].Name, privateName = ResourceManager.TechTree[this.tech.UID].HullsUnlocked[i].Name, Description = "", Type = "HULL" }; numUnlocks++; this.Unlocks.Add(unlock); } } for (int i = 0; i < ResourceManager.TechTree[this.tech.UID].TroopsUnlocked.Count; i++) { if (numUnlocks > 3) break; if (ResourceManager.TechTree[this.tech.UID].TroopsUnlocked[i].Type == EmpireManager.GetEmpireByName(screen.empireUI.screen.PlayerLoyalty).data.Traits.ShipType || ResourceManager.TechTree[this.tech.UID].TroopsUnlocked[i].Type == "ALL" || ResourceManager.TechTree[this.tech.UID].TroopsUnlocked[i].Type == null || ResourceManager.TechTree[this.tech.UID].TroopsUnlocked[i].Type == EmpireManager.GetEmpireByName(screen.empireUI.screen.PlayerLoyalty).GetTDict()[this.tech.UID].AcquiredFrom) { UnlockItem unlock = new UnlockItem(); //{ unlock.troop = ResourceManager.TroopsDict[ResourceManager.TechTree[this.tech.UID].TroopsUnlocked[i].Name]; unlock.privateName = ResourceManager.TechTree[this.tech.UID].TroopsUnlocked[i].Name; unlock.Description = unlock.troop.Description; unlock.Type = "TROOP"; //}; numUnlocks++; this.Unlocks.Add(unlock); } } int numColumns = numUnlocks / 2 + numUnlocks % 2; this.IconRect = new Rectangle(this.BaseRect.X + this.BaseRect.Width / 2 - 29, this.BaseRect.Y + this.BaseRect.Height / 2 - 24 - 10, 58, 49); if (numUnlocks <= 1) { this.UnlocksRect = new Rectangle(this.IconRect.X + this.IconRect.Width, this.IconRect.Y + this.IconRect.Height - 5, 35, 32); this.UnlocksRect.Y = this.UnlocksRect.Y - this.UnlocksRect.Height; Rectangle drawRect = this.UnlocksRect; drawRect.X = drawRect.X + 3; this.grid = new UnlocksGrid(this.Unlocks, drawRect); } else { this.UnlocksRect = new Rectangle(this.IconRect.X + this.IconRect.Width, this.IconRect.Y + this.IconRect.Height - 5, 13 + numColumns * 32, (numUnlocks == 1 ? 32 : 64)); this.UnlocksRect.Y = this.UnlocksRect.Y - this.UnlocksRect.Height; Rectangle drawRect = this.UnlocksRect; drawRect.X = drawRect.X + 13; this.grid = new UnlocksGrid(this.Unlocks, drawRect); } this.UnlocksRect.X = this.UnlocksRect.X - 2; this.UnlocksRect.Width = this.UnlocksRect.Width + 4; this.UnlocksRect.Y = this.UnlocksRect.Y - 2; this.UnlocksRect.Height = this.UnlocksRect.Height + 4; this.TitleRect = new Rectangle(this.BaseRect.X + 8, this.BaseRect.Y - 15, 82, 29); if (GlobalStats.Config.Language == "German" || GlobalStats.Config.Language == "Polish") { this.TitleRect.X = this.TitleRect.X - 5; this.TitleRect.Width = this.TitleRect.Width + 5; TreeNode titleWidth = this; titleWidth.TitleWidth = titleWidth.TitleWidth + 10f; } this.CostPos = new Vector2(65f, 70f) + new Vector2((float)this.BaseRect.X, (float)this.BaseRect.Y); float x = this.CostPos.X; SpriteFont titleFont = this.TitleFont; float cost = (float)((int)EmpireManager.GetEmpireByName(this.screen.empireUI.screen.PlayerLoyalty).TechnologyDict[this.tech.UID].GetTechCost()) * UniverseScreen.GamePaceStatic; this.CostPos.X = x - titleFont.MeasureString(cost.ToString()).X; this.CostPos.X = (float)((int)this.CostPos.X); this.CostPos.Y = (float)((int)this.CostPos.Y - 3); }