private void SetDataSources() { ComboBoxSize.ItemsSource = Enum.GetValues(typeof(SizePivot)); ComboBoxLandShape.ItemsSource = Enum.GetValues(typeof(LandShapePivot)); ComboBoxLandCoverage.ItemsSource = Enum.GetValues(typeof(LandCoveragePivot)); ComboBoxTemperature.ItemsSource = Enum.GetValues(typeof(TemperaturePivot)); ComboBoxAge.ItemsSource = Enum.GetValues(typeof(AgePivot)); ComboBoxHumidity.ItemsSource = Enum.GetValues(typeof(HumidityPivot)); ComboBoxCivilization.ItemsSource = CivilizationPivot.GetCivilizations(false); }
private void ComboBoxSize_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { var count = CivilizationPivot.GetCivilizations(false).Count; if (ComboBoxSize.SelectedItem != null) { count /= (6 - (int)ComboBoxSize.SelectedItem); } ComboBoxIaPlayersCount.ItemsSource = Enumerable.Range(0, count); ComboBoxIaPlayersCount.SelectedValue = 0; }
/// <summary> /// Constructor. /// </summary> /// <param name="mapSize">Map size.</param> /// <param name="mapShape">Map shape.</param> /// <param name="landCoverage">Map land coverage.</param> /// <param name="temperature">Map temperature.</param> /// <param name="age">Map age.</param> /// <param name="humidity">Map humidity.</param> /// <param name="playerCivilization">Human player civilization.</param> /// <param name="playerGender">The <see cref="PlayerPivot.Gender"/> value.</param> /// <param name="iaPlayersCount">Number of IA civilizations (except barbarians).</param> /// <param name="randomCityNames">Sets <c>True</c> to active random city names for the human player.</param> /// <exception cref="ArgumentNullException"><paramref name="playerCivilization"/> is <c>Null</c>.</exception> /// <exception cref="ArgumentException"><paramref name="iaPlayersCount"/> invalid.</exception> public EnginePivot(SizePivot mapSize, LandShapePivot mapShape, LandCoveragePivot landCoverage, TemperaturePivot temperature, AgePivot age, HumidityPivot humidity, CivilizationPivot playerCivilization, bool playerGender, int iaPlayersCount, bool randomCityNames) { if (playerCivilization == null) { throw new ArgumentNullException(nameof(playerCivilization)); } iaPlayersCount = iaPlayersCount < 0 ? 0 : iaPlayersCount; if (iaPlayersCount > CivilizationPivot.GetCivilizations(false).Count / (6 - (int)mapSize)) { throw new ArgumentException("The IA players count is too high for this map size !", nameof(iaPlayersCount)); } Map = new MapPivot(mapSize, mapShape, landCoverage, temperature, age, humidity); List <MapSquarePivot> excludedSpots = new List <MapSquarePivot>(); HumanPlayer = new PlayerPivot(this, playerCivilization, false, GetRandomLocation(excludedSpots), playerGender, randomCityNames); var allCivs = CivilizationPivot.GetCivilizations(false); for (int i = 0; i < iaPlayersCount; i++) { CivilizationPivot iaCiv = null; do { iaCiv = allCivs.ElementAt(Tools.Randomizer.Next(0, allCivs.Count)); }while (HumanPlayer.Civilization == iaCiv || _opponentPlayers.Any(ia => ia.Civilization == iaCiv)); _opponentPlayers.Add(new PlayerPivot(this, iaCiv, true, GetRandomLocation(excludedSpots), Tools.Randomizer.Next(0, 2) == 0, false)); } BarbarianPlayer = new PlayerPivot(this, CivilizationPivot.Barbarian, true, null, false, true); // Sets war between every civilizations. for (int i = 0; i < Players.Count - 1; i++) { for (int j = i + 1; j < Players.Count; j++) { Players.ElementAt(i).SwitchPeaceStatusWithOpponent(Players.ElementAt(j)); } } CurrentTurn = 0; }