private void SetEmpireData(EmpireData data) { this.RaceSummary.ShipType = data.Traits.ShipType; this.FlagIndex = data.Traits.FlagIndex; this.currentObjectColor = new Color((byte)data.Traits.R, (byte)data.Traits.G, (byte)data.Traits.B, 255); this.RaceName.Text = data.Traits.Name; this.SingEntry.Text = data.Traits.Singular; this.PlurEntry.Text = data.Traits.Plural; this.HomeSystemEntry.Text = data.Traits.HomeSystemName; this.HomeSystemName = data.Traits.HomeSystemName; this.HomeWorldName = data.Traits.HomeworldName; this.TotalPointsUsed = 8; foreach (TraitEntry t in this.AllTraits) { t.Selected = false; //Added by McShooterz: Searches for new trait tags if ((data.Traits.ConsumptionModifier > 0f || data.Traits.PhysicalTraitGluttonous) && t.trait.ConsumptionModifier > 0f || t.trait.ConsumptionModifier < 0f && (data.Traits.ConsumptionModifier < 0f || data.Traits.PhysicalTraitEfficientMetabolism) || (data.Traits.DiplomacyMod > 0f || data.Traits.PhysicalTraitAlluring) && t.trait.DiplomacyMod > 0f || t.trait.DiplomacyMod < 0f && (data.Traits.DiplomacyMod < 0f || data.Traits.PhysicalTraitRepulsive) || (data.Traits.EnergyDamageMod > 0f || data.Traits.PhysicalTraitEagleEyed) && t.trait.EnergyDamageMod > 0f || t.trait.EnergyDamageMod < 0f && (data.Traits.EnergyDamageMod < 0f || data.Traits.PhysicalTraitBlind) || (data.Traits.MaintMod > 0f || data.Traits.SociologicalTraitWasteful) && t.trait.MaintMod > 0f || t.trait.MaintMod < 0f && (data.Traits.MaintMod < 0f || data.Traits.SociologicalTraitEfficient) || (data.Traits.PopGrowthMax > 0f || data.Traits.PhysicalTraitLessFertile) && t.trait.PopGrowthMax > 0f || (data.Traits.PopGrowthMin > 0f || data.Traits.PhysicalTraitFertile) && t.trait.PopGrowthMin > 0f || (data.Traits.ResearchMod > 0f || data.Traits.PhysicalTraitSmart) && t.trait.ResearchMod > 0f || t.trait.ResearchMod < 0f && (data.Traits.ResearchMod < 0f || data.Traits.PhysicalTraitDumb) || t.trait.ShipCostMod < 0f && (data.Traits.ShipCostMod < 0f || data.Traits.HistoryTraitNavalTraditions) || (data.Traits.TaxMod > 0f || data.Traits.SociologicalTraitMeticulous) && t.trait.TaxMod > 0f || t.trait.TaxMod < 0f && (data.Traits.TaxMod < 0f || data.Traits.SociologicalTraitCorrupt) || (data.Traits.ProductionMod > 0f || data.Traits.SociologicalTraitIndustrious) && t.trait.ProductionMod > 0f || t.trait.ProductionMod < 0f && (data.Traits.ProductionMod < 0f || data.Traits.SociologicalTraitLazy) || (data.Traits.ModHpModifier > 0f || data.Traits.SociologicalTraitSkilledEngineers) && t.trait.ModHpModifier > 0f || t.trait.ModHpModifier < 0f && (data.Traits.ModHpModifier < 0f || data.Traits.SociologicalTraitHaphazardEngineers) || (data.Traits.Mercantile > 0f || data.Traits.SociologicalTraitMercantile) && t.trait.Mercantile > 0f || (data.Traits.GroundCombatModifier > 0f || data.Traits.PhysicalTraitSavage) && t.trait.GroundCombatModifier > 0f || t.trait.GroundCombatModifier < 0f && (data.Traits.GroundCombatModifier < 0f || data.Traits.PhysicalTraitTimid) || (data.Traits.Cybernetic > 0 || data.Traits.HistoryTraitCybernetic) && t.trait.Cybernetic > 0 || (data.Traits.DodgeMod > 0f || data.Traits.PhysicalTraitReflexes) && t.trait.DodgeMod > 0f || t.trait.DodgeMod < 0f && (data.Traits.DodgeMod < 0f || data.Traits.PhysicalTraitPonderous) || (data.Traits.HomeworldSizeMod > 0f || data.Traits.HistoryTraitHugeHomeWorld) && t.trait.HomeworldSizeMod > 0f || t.trait.HomeworldSizeMod < 0f && (data.Traits.HomeworldSizeMod < 0f || data.Traits.HistoryTraitSmallHomeWorld) || t.trait.HomeworldFertMod < 0f && (data.Traits.HomeworldFertMod < 0f || data.Traits.HistoryTraitPollutedHomeWorld) && t.trait.HomeworldRichMod == 0f || t.trait.HomeworldFertMod < 0f && (data.Traits.HomeworldFertMod < 0f || data.Traits.HistoryTraitIndustrializedHomeWorld) && t.trait.HomeworldRichMod != 0f || (data.Traits.Militaristic > 0 || data.Traits.HistoryTraitMilitaristic) && t.trait.Militaristic > 0 || (data.Traits.PassengerModifier > 1 || data.Traits.HistoryTraitManifestDestiny) && t.trait.PassengerModifier > 1 || (data.Traits.BonusExplored > 0 || data.Traits.HistoryTraitAstronomers) && t.trait.BonusExplored > 0 || (data.Traits.Spiritual > 0f || data.Traits.HistoryTraitSpiritual) && t.trait.Spiritual > 0f || (data.Traits.Prototype > 0 || data.Traits.HistoryTraitPrototypeFlagship) && t.trait.Prototype > 0 || (data.Traits.Pack || data.Traits.HistoryTraitPackMentality) && t.trait.Pack || (data.Traits.SpyMultiplier > 0f || data.Traits.HistoryTraitDuplicitous) && t.trait.SpyMultiplier > 0f || (data.Traits.SpyMultiplier < 0f || data.Traits.HistoryTraitHonest) && t.trait.SpyMultiplier < 0f) { t.Selected = true; RaceDesignScreen raceDesignScreen12 = this; this.TotalPointsUsed -= t.trait.Cost; } if (!t.Selected) { continue; } this.SetExclusions(t); } this.DoRaceDescription(); }
public void HandleInputorig(InputState input) { this.currentMouse = Mouse.GetState(); Vector2 mousePos = new Vector2((float)this.currentMouse.X, (float)this.currentMouse.Y); foreach (UIButton b in this.Buttons) { if (!HelperFunctions.CheckIntersection(b.Rect, mousePos)) { b.State = UIButton.PressState.Normal; } else { if (b.State != UIButton.PressState.Hover && b.State != UIButton.PressState.Pressed) { AudioManager.PlayCue("mouse_over4"); } b.State = UIButton.PressState.Hover; if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Pressed) { b.State = UIButton.PressState.Pressed; } if (this.currentMouse.LeftButton != ButtonState.Pressed || this.previousMouse.LeftButton != ButtonState.Released) { continue; } string launches = b.Launches; string str = launches; if (launches == null) { continue; } if (str == "Engage") { AudioManager.PlayCue("echo_affirm"); this.OnEngage(); } else if (str == "Rule Options") { base.ScreenManager.AddScreen(new RuleOptionsScreen()); AudioManager.PlayCue("echo_affirm"); } else if (str == "Abort") { AudioManager.PlayCue("echo_affirm"); this.ExitScreen(); } else if (str == "Clear") { foreach (TraitEntry trait in this.AllTraits) { trait.Selected = false; } } } } this.DescriptionSL.HandleInput(input); if (!this.DrawingColorSelector) { this.selector = null; foreach (ScrollList.Entry e in this.RaceArchetypeSL.Entries) { if (!HelperFunctions.CheckIntersection(e.clickRect, mousePos) || this.currentMouse.LeftButton != ButtonState.Pressed || this.previousMouse.LeftButton != ButtonState.Released) { continue; } this.SelectedData = e.item as EmpireData; AudioManager.PlayCue("echo_affirm"); this.SetEmpireData(this.SelectedData); } this.RaceArchetypeSL.HandleInput(input); this.Traits.HandleInput(this); if (!HelperFunctions.CheckIntersection(this.RaceName.ClickableArea, mousePos)) { this.RaceName.Hover = false; } else { this.RaceName.Hover = true; if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released && !this.SingEntry.HandlingInput && !this.PlurEntry.HandlingInput && !this.HomeSystemEntry.HandlingInput) { this.RaceName.HandlingInput = true; } } if (!HelperFunctions.CheckIntersection(this.SingEntry.ClickableArea, mousePos)) { this.SingEntry.Hover = false; } else { this.SingEntry.Hover = true; if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released && !this.RaceName.HandlingInput && !this.PlurEntry.HandlingInput && !this.HomeSystemEntry.HandlingInput) { this.SingEntry.HandlingInput = true; } } if (!HelperFunctions.CheckIntersection(this.PlurEntry.ClickableArea, mousePos)) { this.PlurEntry.Hover = false; } else { this.PlurEntry.Hover = true; if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released && !this.RaceName.HandlingInput && !this.SingEntry.HandlingInput && !this.HomeSystemEntry.HandlingInput) { this.PlurEntry.HandlingInput = true; } } if (!HelperFunctions.CheckIntersection(this.HomeSystemEntry.ClickableArea, mousePos)) { this.HomeSystemEntry.Hover = false; } else { this.HomeSystemEntry.Hover = true; if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released && !this.RaceName.HandlingInput && !this.SingEntry.HandlingInput && !this.PlurEntry.HandlingInput) { this.HomeSystemEntry.HandlingInput = true; } } if (this.RaceName.HandlingInput) { this.RaceName.HandleTextInput(ref this.RaceName.Text); } if (this.SingEntry.HandlingInput) { this.SingEntry.HandleTextInput(ref this.SingEntry.Text); } if (this.PlurEntry.HandlingInput) { this.PlurEntry.HandleTextInput(ref this.PlurEntry.Text); } if (this.HomeSystemEntry.HandlingInput) { this.HomeSystemEntry.HandleTextInput(ref this.HomeSystemEntry.Text); } this.traitsSL.HandleInput(input); for (int i = this.traitsSL.indexAtTop; i < this.traitsSL.Entries.Count && i < this.traitsSL.indexAtTop + this.traitsSL.entriesToDisplay; i++) { ScrollList.Entry f = this.traitsSL.Entries[i]; if (!HelperFunctions.CheckIntersection(f.clickRect, mousePos)) { f.clickRectHover = 0; } else { if (f.clickRectHover == 0) { AudioManager.PlayCue("sd_ui_mouseover"); } this.selector = new Selector(base.ScreenManager, f.clickRect); f.clickRectHover = 1; TraitEntry t = f.item as TraitEntry; if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released) { if (t.Selected && this.TotalPointsUsed + t.trait.Cost >= 0) { t.Selected = !t.Selected; RaceDesignScreen totalPointsUsed = this; totalPointsUsed.TotalPointsUsed = totalPointsUsed.TotalPointsUsed + t.trait.Cost; AudioManager.GetCue("blip_click").Play(); int excludes = t.trait.Excludes; foreach (TraitEntry ex in this.AllTraits) { if (t.trait.Excludes != ex.trait.TraitName) { continue; } ex.Excluded = false; } } else if (this.TotalPointsUsed - t.trait.Cost < 0 || t.Selected) { AudioManager.PlayCue("UI_Misc20"); } else { bool OK = true; int num = t.trait.Excludes; foreach (TraitEntry ex in this.AllTraits) { if (t.trait.Excludes != ex.trait.TraitName || !ex.Selected) { continue; } OK = false; } if (OK) { t.Selected = true; RaceDesignScreen raceDesignScreen = this; raceDesignScreen.TotalPointsUsed = raceDesignScreen.TotalPointsUsed - t.trait.Cost; AudioManager.GetCue("blip_click").Play(); int excludes1 = t.trait.Excludes; foreach (TraitEntry ex in this.AllTraits) { if (t.trait.Excludes != ex.trait.TraitName) { continue; } ex.Excluded = true; } } } this.DoRaceDescription(); } } } if (HelperFunctions.CheckIntersection(this.GalaxySizeRect, mousePos) && this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released) { AudioManager.GetCue("blip_click").Play(); RaceDesignScreen galaxysize = this; galaxysize.Galaxysize = (RaceDesignScreen.GalSize)((int)galaxysize.Galaxysize + (int)RaceDesignScreen.GalSize.Small); if (this.Galaxysize > RaceDesignScreen.GalSize.Epic) { this.Galaxysize = RaceDesignScreen.GalSize.Tiny; } } if (HelperFunctions.CheckIntersection(this.NumberStarsRect, mousePos) && this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released) { AudioManager.GetCue("blip_click").Play(); RaceDesignScreen starEnum = this; starEnum.StarEnum = (RaceDesignScreen.StarNum)((int)starEnum.StarEnum + (int)RaceDesignScreen.StarNum.Uncommon); if (this.StarEnum > RaceDesignScreen.StarNum.Crowded) { this.StarEnum = RaceDesignScreen.StarNum.Rare; } } if (HelperFunctions.CheckIntersection(this.NumOpponentsRect, mousePos) && this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released) { AudioManager.GetCue("blip_click").Play(); RaceDesignScreen raceDesignScreen1 = this; raceDesignScreen1.numOpponents = raceDesignScreen1.numOpponents + 1; if (this.numOpponents > 7) { this.numOpponents = 1; } } HelperFunctions.CheckIntersection(this.GameModeRect, mousePos); if (HelperFunctions.CheckIntersection(this.ScaleRect, mousePos)) { if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released) { AudioManager.GetCue("blip_click").Play(); RaceDesignScreen gameScale = this; gameScale.GameScale = gameScale.GameScale + 1; if (this.GameScale > 4) { this.GameScale = 1; } } if (input.RightMouseClick) { AudioManager.GetCue("blip_click").Play(); RaceDesignScreen gameScale1 = this; gameScale1.GameScale = gameScale1.GameScale - 1; if (this.GameScale < 1) { this.GameScale = 4; } } } if (HelperFunctions.CheckIntersection(this.PacingRect, mousePos)) { if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released) { AudioManager.GetCue("blip_click").Play(); RaceDesignScreen pacing = this; pacing.Pacing = pacing.Pacing + 25; if (this.Pacing > 400) { this.Pacing = 100; } } if (input.RightMouseClick) { AudioManager.GetCue("blip_click").Play(); RaceDesignScreen pacing1 = this; pacing1.Pacing = pacing1.Pacing - 25; if (this.Pacing < 100) { this.Pacing = 400; } } } if (HelperFunctions.CheckIntersection(this.DifficultyRect, mousePos)) { if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released) { AudioManager.GetCue("blip_click").Play(); RaceDesignScreen raceDesignScreen2 = this; raceDesignScreen2.difficulty = (UniverseData.GameDifficulty)((int)raceDesignScreen2.difficulty + (int)UniverseData.GameDifficulty.Normal); if (this.difficulty > UniverseData.GameDifficulty.Brutal) { this.difficulty = UniverseData.GameDifficulty.Easy; } } if (input.RightMouseClick) { AudioManager.GetCue("blip_click").Play(); RaceDesignScreen raceDesignScreen3 = this; raceDesignScreen3.difficulty = (UniverseData.GameDifficulty)((int)raceDesignScreen3.difficulty - (int)UniverseData.GameDifficulty.Normal); if (this.difficulty < UniverseData.GameDifficulty.Easy) { this.difficulty = UniverseData.GameDifficulty.Brutal; } } } if (HelperFunctions.CheckIntersection(this.FlagRect, mousePos) && this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released) { this.DrawingColorSelector = !this.DrawingColorSelector; } if (HelperFunctions.CheckIntersection(this.FlagRight, mousePos) && this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released) { if (ResourceManager.FlagTextures.Count - 1 <= this.FlagIndex) { this.FlagIndex = 0; } else { RaceDesignScreen flagIndex = this; flagIndex.FlagIndex = flagIndex.FlagIndex + 1; } AudioManager.GetCue("blip_click").Play(); } if (HelperFunctions.CheckIntersection(this.FlagLeft, mousePos) && this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released) { if (this.FlagIndex <= 0) { this.FlagIndex = ResourceManager.FlagTextures.Count - 1; } else { RaceDesignScreen flagIndex1 = this; flagIndex1.FlagIndex = flagIndex1.FlagIndex - 1; } AudioManager.GetCue("blip_click").Play(); } } else if (!HelperFunctions.CheckIntersection(this.ColorSelector, input.CursorPosition)) { if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released) { this.DrawingColorSelector = false; } } else if (this.currentMouse.LeftButton == ButtonState.Pressed) { int yPosition = this.ColorSelector.Y + 10; int xPositionStart = this.ColorSelector.X + 10; for (int i = 0; i <= 255; i++) { for (int j = 0; j <= 255; j++) { Color thisColor = new Color(Convert.ToByte(i), Convert.ToByte(j), this.currentObjectColor.B); Rectangle ColorRect = new Rectangle(2 * j + xPositionStart - 4, yPosition - 4, 8, 8); if (HelperFunctions.CheckIntersection(ColorRect, input.CursorPosition)) { this.currentObjectColor = thisColor; } } yPosition = yPosition + 2; } yPosition = this.ColorSelector.Y + 10; for (int i = 0; i <= 255; i++) { Color thisColor = new Color(this.currentObjectColor.R, this.currentObjectColor.G, Convert.ToByte(i)); Rectangle ColorRect = new Rectangle(this.ColorSelector.X + 10 + 575, yPosition, 20, 2); if (HelperFunctions.CheckIntersection(ColorRect, input.CursorPosition)) { this.currentObjectColor = thisColor; } yPosition = yPosition + 2; } } this.previousMouse = this.currentMouse; if (input.Escaped) { this.ExitScreen(); } }
private void SaveRace(Empire empire) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(EmpireData)); EmpireData empireData = new EmpireData(); empireData.Traits = empire.data.Traits; TextWriter textWriter = (TextWriter)new StreamWriter("Content/Races/test.xml"); xmlSerializer.Serialize(textWriter, (object)empireData); textWriter.Close(); }
public override void LoadContent() { if (base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth <= 1366 || base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight <= 720) { this.LowRes = true; } Rectangle titleRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 203, (this.LowRes ? 10 : 44), 406, 80); this.TitleBar = new Menu2(base.ScreenManager, titleRect); this.TitlePos = new Vector2((float)(titleRect.X + titleRect.Width / 2) - Fonts.Laserian14.MeasureString(Localizer.Token(18)).X / 2f, (float)(titleRect.Y + titleRect.Height / 2 - Fonts.Laserian14.LineSpacing / 2)); Rectangle nameRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - (int)((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 0.5f) / 2, titleRect.Y + titleRect.Height + 5, (int)((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 0.5f), 150); this.Name = new Menu1(base.ScreenManager, nameRect); Rectangle nsubRect = new Rectangle(nameRect.X + 20, nameRect.Y - 5, nameRect.Width - 40, nameRect.Height - 15); this.NameSub = new Submenu(base.ScreenManager, nsubRect); this.ColorSelector = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 310, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 280, 620, 560); this.ColorSelectMenu = new Menu1(base.ScreenManager, this.ColorSelector); this.RaceNamePos = new Vector2((float)(nameRect.X + 40), (float)(nameRect.Y + 30)); this.FlagPos = new Vector2((float)(nameRect.X + nameRect.Width - 80 - 100), (float)(nameRect.Y + 30)); Rectangle leftRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - (int)((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 0.5f) / 2, nameRect.Y + nameRect.Height + 5, (int)((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 0.5f), base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - (titleRect.Y + titleRect.Height) - (int)(0.28f * (float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight)); if (leftRect.Height > 580) { leftRect.Height = 580; } this.Left = new Menu1(base.ScreenManager, leftRect); Vector2 Position = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 84), (float)(leftRect.Y + leftRect.Height + 10)); this.RulesOptions = new UIButton() { Rect = new Rectangle((int)Position.X, (int)Position.Y, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Text = Localizer.Token(4006), Launches = "Rule Options" }; this.Buttons.Add(this.RulesOptions); Rectangle ChooseRaceRect = new Rectangle(5, (this.LowRes ? nameRect.Y : leftRect.Y), leftRect.X - 10, (this.LowRes ? leftRect.Y + leftRect.Height - nameRect.Y : leftRect.Height)); this.ChooseRaceMenu = new Menu1(base.ScreenManager, ChooseRaceRect); Rectangle smaller = ChooseRaceRect; smaller.Y = smaller.Y - 20; smaller.Height = smaller.Height + 20; this.arch = new Submenu(base.ScreenManager, smaller); this.RaceArchetypeSL = new ScrollList(this.arch, 135); ResourceManager.Empires.Clear(); ResourceManager.WhichModPath = "Content"; if (GlobalStats.ActiveModInfo != null && !GlobalStats.ActiveModInfo.DisableDefaultRaces) { //ResourceManager.WhichModPath = string.Concat("Mods/", GlobalStats.ActiveMod.ModPath); ResourceManager.LoadEmpires(); //ResourceManager.LoadSubsetEmpires(); } else if (GlobalStats.ActiveModInfo == null || !GlobalStats.ActiveModInfo.DisableDefaultRaces) { ResourceManager.LoadEmpires(); //ResourceManager.LoadSubsetEmpires(); } else { ResourceManager.LoadSubsetEmpires(); } if (GlobalStats.ActiveMod != null) { ResourceManager.WhichModPath = string.Concat("Mods/", GlobalStats.ActiveMod.ModPath); ResourceManager.LoadModdedEmpires(); } foreach (EmpireData e in ResourceManager.Empires) { if (e.Faction == 1 || e.MinorRace) { continue; } this.RaceArchetypeSL.AddItem(e); if (string.IsNullOrEmpty(e.Traits.VideoPath)) { continue; } this.TextureDict.Add(e, ResourceManager.TextureDict[string.Concat("Races/", e.Traits.VideoPath)]); } foreach (EmpireData e in ResourceManager.Empires) { if (e.Traits.Singular != "Human") { continue; } this.SelectedData = e; } this.RaceName.Text = this.SelectedData.Traits.Name; this.SingEntry.Text = this.SelectedData.Traits.Singular; this.PlurEntry.Text = this.SelectedData.Traits.Plural; this.HomeSystemEntry.Text = this.SelectedData.Traits.HomeSystemName; this.HomeWorldName = this.SelectedData.Traits.HomeworldName; this.GalaxySizeRect = new Rectangle(nameRect.X + nameRect.Width + 40 - 22, nameRect.Y + 5, (int)Fonts.Arial12.MeasureString("Galaxy Size ").X, Fonts.Arial12.LineSpacing); this.NumberStarsRect = new Rectangle(this.GalaxySizeRect.X, this.GalaxySizeRect.Y + Fonts.Arial12.LineSpacing + 10, this.GalaxySizeRect.Width, this.GalaxySizeRect.Height); this.NumOpponentsRect = new Rectangle(this.NumberStarsRect.X, this.NumberStarsRect.Y + Fonts.Arial12.LineSpacing + 10, this.NumberStarsRect.Width, this.NumberStarsRect.Height); this.GameModeRect = new Rectangle(this.NumOpponentsRect.X, this.NumOpponentsRect.Y + Fonts.Arial12.LineSpacing + 10, this.NumberStarsRect.Width, this.NumOpponentsRect.Height); this.PacingRect = new Rectangle(this.GameModeRect.X, this.GameModeRect.Y + Fonts.Arial12.LineSpacing + 10, this.GameModeRect.Width, this.GameModeRect.Height); this.DifficultyRect = new Rectangle(this.PacingRect.X, this.PacingRect.Y + Fonts.Arial12.LineSpacing + 10, this.PacingRect.Width, this.PacingRect.Height); Rectangle dRect = new Rectangle(leftRect.X + leftRect.Width + 5, leftRect.Y, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - leftRect.X - leftRect.Width - 10, leftRect.Height); this.Description = new Menu1(base.ScreenManager, dRect, true); this.dslrect = new Rectangle(leftRect.X + leftRect.Width + 5, leftRect.Y, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - leftRect.X - leftRect.Width - 10, leftRect.Height - 160); Submenu dsub = new Submenu(base.ScreenManager, this.dslrect); this.DescriptionSL = new ScrollList(dsub, Fonts.Arial12.LineSpacing); Rectangle psubRect = new Rectangle(leftRect.X + 20, leftRect.Y + 20, leftRect.Width - 40, leftRect.Height - 40); this.Traits = new Submenu(base.ScreenManager, psubRect); this.Traits.AddTab(Localizer.Token(19)); this.Traits.AddTab(Localizer.Token(20)); this.Traits.AddTab(Localizer.Token(21)); int size = 55; if (GlobalStats.Config.Language != "German" && base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth <= 1280) { size = 65; } if (GlobalStats.Config.Language == "Russian" || GlobalStats.Config.Language == "Polish") { size = 70; } this.traitsSL = new ScrollList(this.Traits, size); foreach (TraitEntry t in this.AllTraits) { if (t.trait.Category == "Physical") this.traitsSL.AddItem(t); } this.Engage = new UIButton() { Rect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 140, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 40, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_pressed"], Text = Localizer.Token(22), Launches = "Engage" }; this.Buttons.Add(this.Engage); this.Abort = new UIButton() { Rect = new Rectangle(10, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 40, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_pressed"], Text = Localizer.Token(23), Launches = "Abort" }; this.Buttons.Add(this.Abort); this.ClearTraits = new UIButton() { Rect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 150, this.Description.Menu.Y + this.Description.Menu.Height - 40, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_pressed"], Text = "Clear Traits", Launches = "Clear" }; this.Buttons.Add(this.ClearTraits); this.DoRaceDescription(); this.SetEmpireData(this.SelectedData); base.LoadContent(); }
private Empire CreateEmpireFromEmpireData(EmpireData data) { Empire empire = new Empire(); if (data.Faction == 1) empire.isFaction = true; if (data.MinorRace) empire.MinorRace = true; int index1 = (int)RandomMath.RandomBetween(0.0f, (float)this.dtraits.DiplomaticTraitsList.Count); data.DiplomaticPersonality = this.dtraits.DiplomaticTraitsList[index1]; while (!this.CheckPersonality(data)) { int index2 = (int)RandomMath.RandomBetween(0.0f, (float)this.dtraits.DiplomaticTraitsList.Count); data.DiplomaticPersonality = this.dtraits.DiplomaticTraitsList[index2]; } int index3 = (int)RandomMath.RandomBetween(0.0f, (float)this.dtraits.EconomicTraitsList.Count); data.EconomicPersonality = this.dtraits.EconomicTraitsList[index3]; while (!this.CheckEPersonality(data)) { int index2 = (int)RandomMath.RandomBetween(0.0f, (float)this.dtraits.EconomicTraitsList.Count); data.EconomicPersonality = this.dtraits.EconomicTraitsList[index2]; } empire.data = data; //Added by McShooterz: set values for alternate race file structure data.Traits.SetValues(); empire.dd = ResourceManager.DDDict[data.DiplomacyDialogPath]; empire.data.SpyModifier = data.Traits.SpyMultiplier; empire.data.Traits.Spiritual = data.Traits.Spiritual; data.Traits.PassengerModifier += data.Traits.PassengerBonus; empire.PortraitName = data.PortraitName; empire.data.Traits = data.Traits; empire.EmpireColor = new Color((byte)data.Traits.R, (byte)data.Traits.G, (byte)data.Traits.B); empire.Initialize(); return empire; }
private bool CheckPersonality(EmpireData data) { foreach (string str in data.ExcludedDTraits) { if (str == data.DiplomaticPersonality.Name) return false; } return true; }
private bool CheckEPersonality(EmpireData data) { foreach (string str in data.ExcludedETraits) { if (str == data.EconomicPersonality.Name) return false; } return true; }
public static Empire CreateRebelsFromEmpireData(EmpireData data, Empire parent) { Empire empire = new Empire(); empire.isFaction = true; empire.data = CreatingNewGameScreen.CopyEmpireData(data); //Added by McShooterz: mod folder support DiplomaticTraits diplomaticTraits = (DiplomaticTraits)new XmlSerializer(typeof(DiplomaticTraits)).Deserialize((Stream)new FileInfo(File.Exists(string.Concat(Ship_Game.ResourceManager.WhichModPath, "/Diplomacy/DiplomaticTraits.xml")) ? string.Concat(Ship_Game.ResourceManager.WhichModPath, "/Diplomacy/DiplomaticTraits.xml") : "Content/Diplomacy/DiplomaticTraits.xml").OpenRead()); int index1 = (int)RandomMath.RandomBetween(0.0f, (float)diplomaticTraits.DiplomaticTraitsList.Count); empire.data.DiplomaticPersonality = diplomaticTraits.DiplomaticTraitsList[index1]; int index2 = (int)RandomMath.RandomBetween(0.0f, (float)diplomaticTraits.DiplomaticTraitsList.Count); empire.data.DiplomaticPersonality = diplomaticTraits.DiplomaticTraitsList[index2]; int index3 = (int)RandomMath.RandomBetween(0.0f, (float)diplomaticTraits.EconomicTraitsList.Count); empire.data.EconomicPersonality = diplomaticTraits.EconomicTraitsList[index3]; int index4 = (int)RandomMath.RandomBetween(0.0f, (float)diplomaticTraits.EconomicTraitsList.Count); empire.data.EconomicPersonality = diplomaticTraits.EconomicTraitsList[index4]; empire.data.SpyModifier = data.Traits.SpyMultiplier; empire.PortraitName = data.PortraitName; empire.EmpireColor = new Color(128, 128, 128, 256); empire.Initialize(); return empire; }
public static EmpireData CopyEmpireData(EmpireData data) { EmpireData empireData = new EmpireData(); empireData.ArmorPiercingBonus = data.ArmorPiercingBonus; empireData.BaseReproductiveRate = data.BaseReproductiveRate; empireData.BonusFighterLevels = data.BonusFighterLevels; empireData.CounterIntelligenceBudget = 0.0f; empireData.DefaultColonyShip = data.DefaultColonyShip; empireData.DefaultSmallTransport = data.DefaultSmallTransport; empireData.DefaultTroopShip = data.DefaultTroopShip; empireData.DefaultConstructor = data.DefaultConstructor; empireData.DefaultShipyard = data.DefaultShipyard; empireData.DiplomacyDialogPath = data.DiplomacyDialogPath; empireData.DiplomaticPersonality = data.DiplomaticPersonality; empireData.EconomicPersonality = data.EconomicPersonality; empireData.EmpireFertilityBonus = data.EmpireFertilityBonus; empireData.EmpireWideProductionPercentageModifier = data.EmpireWideProductionPercentageModifier; empireData.ExcludedDTraits = data.ExcludedDTraits; empireData.ExcludedETraits = data.ExcludedETraits; empireData.ExplosiveRadiusReduction = data.ExplosiveRadiusReduction; empireData.FlatMoneyBonus = 0.0f; empireData.FTLModifier = data.FTLModifier; empireData.FTLPowerDrainModifier = data.FTLPowerDrainModifier; empireData.FuelCellModifier = data.FuelCellModifier; empireData.Inhibitors = data.Inhibitors; empireData.MassModifier = data.MassModifier; //Doctor: Armour Mass Mod empireData.ArmourMassModifier = data.ArmourMassModifier; empireData.MissileDodgeChance = data.MissileDodgeChance; empireData.MissileHPModifier = data.MissileHPModifier; empireData.OrdnanceEffectivenessBonus = data.OrdnanceEffectivenessBonus; empireData.Privatization = data.Privatization; empireData.SensorModifier = data.SensorModifier; empireData.SpyModifier = data.SpyModifier; empireData.SpoolTimeModifier = data.SpoolTimeModifier; empireData.StartingScout = data.StartingScout; empireData.StartingShip = data.StartingShip; empireData.SubLightModifier = data.SubLightModifier; empireData.TaxRate = data.TaxRate; empireData.TroopDescriptionIndex = data.TroopDescriptionIndex; empireData.TroopNameIndex = data.TroopNameIndex; empireData.PowerFlowMod = data.PowerFlowMod; empireData.ShieldPowerMod = data.ShieldPowerMod; //Doctor: Civilian Maint Mod empireData.CivMaintMod = data.CivMaintMod; empireData.Traits = new RacialTrait(); empireData.Traits.Aquatic = data.Traits.Aquatic; empireData.Traits.Assimilators = data.Traits.Assimilators; empireData.Traits.B = 128f; empireData.Traits.Blind = data.Traits.Blind; empireData.Traits.BonusExplored = data.Traits.BonusExplored; empireData.Traits.Burrowers = data.Traits.Burrowers; empireData.Traits.ConsumptionModifier = data.Traits.ConsumptionModifier; empireData.Traits.Cybernetic = data.Traits.Cybernetic; empireData.Traits.DiplomacyMod = data.Traits.DiplomacyMod; empireData.Traits.DodgeMod = data.Traits.DodgeMod; empireData.Traits.EnergyDamageMod = data.Traits.EnergyDamageMod; empireData.Traits.FlagIndex = data.Traits.FlagIndex; empireData.Traits.G = 128f; empireData.Traits.GenericMaxPopMod = data.Traits.GenericMaxPopMod; empireData.Traits.GroundCombatModifier = data.Traits.GroundCombatModifier; empireData.Traits.InBordersSpeedBonus = data.Traits.InBordersSpeedBonus; empireData.Traits.MaintMod = data.Traits.MaintMod; empireData.Traits.Mercantile = data.Traits.Mercantile; empireData.Traits.Militaristic = data.Traits.Militaristic; empireData.Traits.Miners = data.Traits.Miners; empireData.Traits.ModHpModifier = data.Traits.ModHpModifier; empireData.Traits.PassengerModifier = data.Traits.PassengerModifier; empireData.Traits.ProductionMod = data.Traits.ProductionMod; empireData.Traits.R = 128f; empireData.Traits.RepairMod = data.Traits.RepairMod; empireData.Traits.ReproductionMod = data.Traits.ReproductionMod; empireData.Traits.PopGrowthMax = data.Traits.PopGrowthMax; empireData.Traits.PopGrowthMin = data.Traits.PopGrowthMin; empireData.Traits.ResearchMod = data.Traits.ResearchMod; empireData.Traits.ShipCostMod = data.Traits.ShipCostMod; empireData.Traits.ShipType = data.Traits.ShipType; empireData.Traits.Singular = data.RebelSing; empireData.Traits.Plural = data.RebelPlur; empireData.Traits.Spiritual = data.Traits.Spiritual; empireData.Traits.SpyMultiplier = data.Traits.SpyMultiplier; empireData.Traits.TaxMod = data.Traits.TaxMod; empireData.TurnsBelowZero = 0; return empireData; }