/// <summary> /// Changes the <see cref="CitizenTypePivot"/> of the specified <see cref="CitizenPivot"/>; /// using a static sequence of type [Regular -> Entertainer -> Scientist -> TaxCollector -> Regular]. /// </summary> /// <param name="citizenSource">The citizen.</param> /// <exception cref="ArgumentNullException"><paramref name="citizenSource"/> is <c>Null</c>.</exception> /// <exception cref="ArgumentException">The city is not manage by the human player !</exception> public void SwitchCitizenType(CitizenPivot citizenSource) { if (citizenSource == null) { throw new ArgumentNullException(nameof(citizenSource)); } if (!HumanPlayer.Cities.Contains(citizenSource.City)) { throw new ArgumentException("The city is not manage by the human player !", nameof(citizenSource)); } citizenSource.City.SwitchCitizenType(citizenSource); }
private static Image DrawCitizen(CitizenPivot citizen, int size, double opacity, Action <object, MouseButtonEventArgs> MouseLeftButtonCallback) { Style style = new Style { TargetType = typeof(Image) }; style.Setters.Add(new Setter(OpacityProperty, opacity)); if (opacity < 1) { var trigger = new Trigger { Property = IsMouseOverProperty, Value = true }; trigger.Setters.Add(new Setter(OpacityProperty, Convert.ToDouble(1))); style.Triggers.Add(trigger); } var imgCitizen = new Image { Width = size, Height = size, Source = DrawTools.GetBitmap(citizen.ToString(), isCitizen: true), ToolTip = citizen.ToString(), Style = style, Stretch = System.Windows.Media.Stretch.Uniform, Tag = citizen }; if (MouseLeftButtonCallback != null) { imgCitizen.MouseLeftButtonDown += new MouseButtonEventHandler(MouseLeftButtonCallback); } return(imgCitizen); }
private void DrawCitySquare(Tuple <int, int> gridOffset, MapSquarePivot current, CitizenPivot citizen, bool occupiedByOtherCity, int row, int column) { if (current == null) { GridCityMap.Children.Add(DrawDisableSquare(row, column, 1, 1)); } else { bool isCityRadius = _city.CoordinatesAreCityRadius(row + gridOffset.Item1, column + gridOffset.Item2); bool isCity = _city.CoordinatesAreCityCenter(row + gridOffset.Item1, column + gridOffset.Item2); Action <object, MouseButtonEventArgs> callback = MouseClickOnCityGridEmpty; if (!isCityRadius || occupiedByOtherCity || isCity || citizen != null) { callback = null; } GridCityMap.DrawSingleMapSquare(CITY_GRID_SIZE, current, true, gridOffset, callback); if (isCity) { GridCityMap.DrawMapCity(_city, CITY_GRID_SIZE, 5, true, gridOffset, MouseClickOnCity); } else if (!isCityRadius || occupiedByOtherCity) { GridCityMap.Children.Add(DrawDisableSquare(row, column, 5, 0.4)); } else if (citizen != null) { var imgCitizen = DrawCitizen(citizen, CITIZEN_SIZE_CITYGRID, 0.6, MouseClickOnCitizen); imgCitizen.SetValue(Panel.ZIndexProperty, 2); imgCitizen.SetValue(Grid.RowProperty, row); imgCitizen.SetValue(Grid.ColumnProperty, column); GridCityMap.Children.Add(imgCitizen); } } }