Example #1
0
        private void DrawSingleMiniMapSquare(MapSquarePivot square, bool cleanPreviousSquare)
        {
            var brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(DrawTools.MAP_SQUARE_COLORS[square.Biome.Name]));

            if (cleanPreviousSquare)
            {
                MiniMapCanvas.CleanPreviousChildrenByTag(square);
            }
            else if (!Settings.Default.showFullMap)
            {
                brush = Brushes.Black;
            }

            Rectangle rctMinimap = new Rectangle
            {
                Width  = _minimapSquareSize,
                Height = _minimapSquareSize,
                Fill   = brush
            };

            rctMinimap.SetValue(Canvas.TopProperty, square.Row * _minimapSquareSize);
            rctMinimap.SetValue(Canvas.LeftProperty, square.Column * _minimapSquareSize);
            rctMinimap.Tag = square;
            MiniMapCanvas.Children.Add(rctMinimap);
        }
Example #2
0
        private MapSquarePivot GetRandomLocation(List <MapSquarePivot> excludedSpots)
        {
            MapSquarePivot ms = null;

            do
            {
                var row    = Tools.Randomizer.Next(0, Map.Height);
                var column = Tools.Randomizer.Next(0, Map.Width);
                ms = Map[row, column];
            }while (ms == null || ms.Biome.IsSeaType || Map.Huts.Any(h => h.MapSquareLocation == ms) || excludedSpots.Contains(ms));

            excludedSpots.Add(ms);
            return(ms);
        }
Example #3
0
        internal static void DrawSquareImprovements(this Panel panel, MapSquarePivot square, double defaultDim, Tuple <int, int> gridPositionOffset = null)
        {
            if (panel == null)
            {
                return;
            }

            var newElementsWithZIndex = new Dictionary <FrameworkElement, int>();

            if (square.RailRoad)
            {
                DrawRoad(defaultDim, newElementsWithZIndex, true);
            }
            else if (square.Road)
            {
                DrawRoad(defaultDim, newElementsWithZIndex, false);
            }
            if (square.Irrigate)
            {
                DrawIrrigationSystem(defaultDim, newElementsWithZIndex);
            }
            if (square.Mine)
            {
                DrawImageOnSquare(defaultDim, newElementsWithZIndex, 0.5, "mine", 2);
            }
            if (square.Pollution)
            {
                DrawImageOnSquare(defaultDim, newElementsWithZIndex, 0.8, "pollution", 3);
            }
            if (square.Fortress)
            {
                DrawFortress(defaultDim, newElementsWithZIndex);
            }

            foreach (var element in newElementsWithZIndex.Keys)
            {
                element.SetValue(Grid.RowProperty, square.Row - (gridPositionOffset == null ? 0 : gridPositionOffset.Item1));
                element.SetValue(Grid.ColumnProperty, square.Column - (gridPositionOffset == null ? 0 : gridPositionOffset.Item2));
                element.SetValue(Panel.ZIndexProperty, newElementsWithZIndex[element]);
                element.Tag = square;
                panel.Children.Add(element);
            }
        }
Example #4
0
        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);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Gets a specialist citizen of the specified city (if any), and makes it a regular worker on the specified location.
        /// </summary>
        /// <param name="city">The city.</param>
        /// <param name="mapSquare">The location.</param>
        /// <exception cref="ArgumentNullException"><paramref name="city"/> is <c>Null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="mapSquare"/> is <c>Null</c>.</exception>
        /// <exception cref="ArgumentException">The city is not manage by the human player !</exception>
        /// <exception cref="ArgumentException">The specified square can't be used by the citizen !</exception>
        public void ChangeAnySpecialistToRegular(CityPivot city, MapSquarePivot mapSquare)
        {
            if (city == null)
            {
                throw new ArgumentNullException(nameof(city));
            }

            if (mapSquare == null)
            {
                throw new ArgumentNullException(nameof(mapSquare));
            }

            if (!HumanPlayer.Cities.Contains(city))
            {
                throw new ArgumentException("The city is not manage by the human player !", nameof(city));
            }

            if (!ComputeCityAvailableMapSquares(city).Contains(mapSquare))
            {
                throw new ArgumentException("The specified square can't be used by the citizen !");
            }

            city.ChangeAnySpecialistToRegular(mapSquare);
        }
Example #6
0
 private SubmarinePivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 8, 2, 3, 50, AdvancePivot.MassProduction, null, 450, null, location, player, false, false, 2, 0, false, 1)
 {
 }
Example #7
0
 /// <summary>
 /// Static constructior.
 /// </summary>
 /// <param name="city">The <see cref="UnitPivot.City"/> value.</param>
 /// <param name="location">The <see cref="UnitPivot.MapSquareLocation"/> value if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="player">The <see cref="UnitPivot.Player"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <returns>An instance of <see cref="MusketeerPivot"/>.</returns>
 internal static MusketeerPivot CreateAtLocation(CityPivot city, MapSquarePivot location, PlayerPivot player)
 {
     return(new MusketeerPivot(city, location, player));
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="mapSquare">The <see cref="MapSquare"/> value.</param>
 public SquareChangedEventArgs(MapSquarePivot mapSquare)
 {
     MapSquare = mapSquare;
 }
Example #9
0
 private TransportPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 0, 3, 4, 50, AdvancePivot.Industrialization, null, 450, null, location, player, false, false, 1, 8, false, 1)
 {
 }
Example #10
0
 private ArmorPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 10, 5, 3, 80, AdvancePivot.Automobile, null, 960, null, 0, location, player)
 {
 }
Example #11
0
 private CaravanPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 0, 1, 1, 50, AdvancePivot.Trade, null, 450, null, 0, location, player, ignoreControlZone: true, maintenanceCost: 0)
 {
 }
Example #12
0
 /// <summary>
 /// Checks if a specified <see cref="MapSquarePivot"/> has a <see cref="CityPivot"/> built on it.
 /// </summary>
 /// <param name="square">The <see cref="MapSquarePivot"/>.</param>
 /// <returns><c>True</c> if city; <c>False</c> otherwise.</returns>
 internal bool IsCity(MapSquarePivot square)
 {
     return(GetEveryCities().Any(c => c.MapSquareLocation == square));
 }
Example #13
0
 private bool OccupiedByCity(MapSquarePivot mapSquare, CityPivot exceptCity = null)
 {
     return(GetEveryCities().Any(c => (exceptCity == null || exceptCity != c) && c.AreaMapSquares.Any(ams => ams.MapSquare == mapSquare)));
 }
Example #14
0
 private NuclearPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 99, 0, 16, 160, AdvancePivot.Rocketry, null, 3200, null, location, player, true, false, false, 1, 1, 1)
 {
 }
Example #15
0
 /// <summary>
 /// Computes the distance between two <see cref="MapSquarePivot"/>.
 /// </summary>
 /// <param name="loc1">The first point.</param>
 /// <param name="loc2">The second point.</param>
 /// <returns>The distance.</returns>
 internal static double DistanceBetweenTwoPoints(MapSquarePivot loc1, MapSquarePivot loc2)
 {
     return(Math.Sqrt(Math.Pow(loc2.Row - loc1.Row, 2) + Math.Pow(loc2.Column - loc1.Column, 2)));
 }
Example #16
0
 private TriremePivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 1, 0, 3, 40, AdvancePivot.MapMaking, AdvancePivot.Navigation, 320, null, location, player, false, false, 1, 2, false, 1)
 {
 }
Example #17
0
 private CarrierPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 1, 12, 5, 160, AdvancePivot.AdvancedFlight, null, 3200, null, location, player, false, false, 2, 8, false, 1)
 {
 }
Example #18
0
 private DiplomatPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 0, 0, 2, 30, AdvancePivot.Writing, null, 210, null, 0, location, player, ignoreControlZone: true, maintenanceCost: 0)
 {
 }
Example #19
0
 private KnightPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 4, 2, 2, 40, AdvancePivot.Chivalry, AdvancePivot.Automobile, 320, null, 0, location, player)
 {
 }
Example #20
0
 private CavalryPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 2, 1, 2, 20, AdvancePivot.HorsebackRiding, AdvancePivot.Conscription, 120, null, 0, location, player)
 {
 }
Example #21
0
 private LegionPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 3, 1, 1, 20, AdvancePivot.IronWorking, AdvancePivot.Conscription, 120, null, 0, location, player)
 {
 }
Example #22
0
        internal static void DrawSingleMapSquare(this Panel panel, double defaultDim, MapSquarePivot square, bool cleanPreviousSquare,
                                                 Tuple <int, int> gridPositionOffset = null, Action <object, MouseButtonEventArgs> mouseLeftButtonDownCallback = null)
        {
            if (panel == null)
            {
                return;
            }

            if (cleanPreviousSquare)
            {
                panel.CleanPreviousChildrenByTag(square);
            }
            else if (!Settings.Default.showFullMap)
            {
                var blackRectangle = new Rectangle
                {
                    Fill   = Brushes.Black,
                    Width  = defaultDim,
                    Height = defaultDim,
                    Tag    = square
                };

                blackRectangle.SetValue(Grid.RowProperty, square.Row - (gridPositionOffset == null ? 0 : gridPositionOffset.Item1));
                blackRectangle.SetValue(Grid.ColumnProperty, square.Column - (gridPositionOffset == null ? 0 : gridPositionOffset.Item2));
                panel.Children.Add(blackRectangle);
                return;
            }

            var squareRender = new Border
            {
                Child = new Image
                {
                    Width               = defaultDim,
                    Height              = defaultDim,
                    Source              = GetBitmap(square.Biome.Name, isBiome: true, isBiomeBonus: square.HasBonus),
                    Stretch             = Stretch.Uniform,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center
                }
            };

            squareRender.SetValue(Grid.RowProperty, square.Row - (gridPositionOffset == null ? 0 : gridPositionOffset.Item1));
            squareRender.SetValue(Grid.ColumnProperty, square.Column - (gridPositionOffset == null ? 0 : gridPositionOffset.Item2));
            squareRender.Tag = square;
            panel.Children.Add(squareRender);

            panel.DrawSquareImprovements(square, defaultDim, gridPositionOffset);

            if (mouseLeftButtonDownCallback != null)
            {
                var transparentLayer = new Rectangle
                {
                    Width  = defaultDim,
                    Height = defaultDim,
                    Fill   = Brushes.Transparent,
                    Tag    = square
                };
                transparentLayer.MouseLeftButtonDown += new MouseButtonEventHandler(mouseLeftButtonDownCallback);
                transparentLayer.SetValue(Grid.RowProperty, square.Row - (gridPositionOffset == null ? 0 : gridPositionOffset.Item1));
                transparentLayer.SetValue(Grid.ColumnProperty, square.Column - (gridPositionOffset == null ? 0 : gridPositionOffset.Item2));
                transparentLayer.SetValue(Panel.ZIndexProperty, 10);
                panel.Children.Add(transparentLayer);
            }
        }
Example #23
0
 /// <summary>
 /// Static constructior.
 /// </summary>
 /// <param name="city">The <see cref="UnitPivot.City"/> value.</param>
 /// <param name="location">The <see cref="UnitPivot.MapSquareLocation"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="player">The <see cref="UnitPivot.Player"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <returns>An instance of <see cref="TransportPivot"/>.</returns>
 internal static TransportPivot CreateAtLocation(CityPivot city, MapSquarePivot location, PlayerPivot player)
 {
     return(new TransportPivot(city, location, player));
 }
Example #24
0
 private CatapultPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 6, 1, 1, 40, AdvancePivot.Mathematics, AdvancePivot.Metallurgy, 320, null, 0, location, player)
 {
 }
Example #25
0
 private MusketeerPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 2, 3, 1, 30, AdvancePivot.Gunpowder, AdvancePivot.Conscription, 210, null, 0, location, player)
 {
 }
Example #26
0
 /// <summary>
 /// Static constructior.
 /// </summary>
 /// <param name="city">The <see cref="UnitPivot.City"/> value.</param>
 /// <param name="location">The <see cref="UnitPivot.MapSquareLocation"/> value if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="player">The <see cref="UnitPivot.Player"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <returns>An instance of <see cref="CatapultPivot"/>.</returns>
 internal static CatapultPivot CreateAtLocation(CityPivot city, MapSquarePivot location, PlayerPivot player)
 {
     return(new CatapultPivot(city, location, player));
 }
Example #27
0
 private FrigatePivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 2, 2, 3, 40, AdvancePivot.Magnetism, AdvancePivot.Industrialization, 320, null, location, player, false, false, 1, 4, true, 1)
 {
 }
Example #28
0
 private BomberPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 12, 1, 8, 120, AdvancePivot.AdvancedFlight, null, 1920, null, location, player, false, false, true, 2, 2, 1)
 {
 }
Example #29
0
 /// <summary>
 /// Static constructior.
 /// </summary>
 /// <param name="city">The <see cref="UnitPivot.City"/> value.</param>
 /// <param name="location">The <see cref="UnitPivot.MapSquareLocation"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="player">The <see cref="UnitPivot.Player"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <returns>An instance of <see cref="SubmarinePivot"/>.</returns>
 internal static SubmarinePivot CreateAtLocation(CityPivot city, MapSquarePivot location, PlayerPivot player)
 {
     return(new SubmarinePivot(city, location, player));
 }
Example #30
0
 /// <summary>
 /// Static constructior.
 /// </summary>
 /// <param name="city">The <see cref="UnitPivot.City"/> value.</param>
 /// <param name="location">The <see cref="UnitPivot.MapSquareLocation"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="player">The <see cref="UnitPivot.Player"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <returns>An instance of <see cref="BattleshipPivot"/>.</returns>
 internal static BattleshipPivot CreateAtLocation(CityPivot city, MapSquarePivot location, PlayerPivot player)
 {
     return(new BattleshipPivot(city, location, player));
 }