/// <summary> /// Create drawer to further decorate a village drawn by <see cref="CreateVillageDrawer"/> /// </summary> /// <param name="data">The shape of the drawer</param> /// <param name="colors">The colors for the drawer</param> /// <param name="mainData">The data for the main drawer (used for BorderDrawer)</param> public DrawerBase CreateVillageDecoratorDrawer(DecoratorDrawerData data, BackgroundDrawerData mainData) { Debug.Assert(SupportDecorators); DrawerBase drawer = CreateVillageDecoratorDrawerCore(data, mainData); return(drawer); }
public override void ReadDrawerXml(XElement drawer) { int pointsTreshold = int.Parse(drawer.Attribute("VillagePoints").Value); var data = new BackgroundDrawerData( drawer.Attribute("ShapeDrawer").Value, drawer.Attribute("IconDrawer").Value, drawer.Attribute("BonusIconDrawer").Value); _drawers.Add(pointsTreshold, data); }
protected override DrawerBase CreateVillageDrawerCore(Village.BonusType villageBonus, BackgroundDrawerData data, Marker marker) { switch (data.ShapeDrawer) { case "RectangleDrawer": return new ShapeDrawer(false, marker); case "EllipseDrawer": return new ShapeDrawer(true, marker); default: return null; } }
protected override DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData) { if (data.Shape == null) { return null; } switch (data.Shape.Drawer) { case "BorderDrawer": var drawer = mainData.ShapeDrawer == "EllipseDrawer" ? BorderDrawer.EllipseDrawer : BorderDrawer.RectangleDrawer; return new BorderDrawer(data.Shape.Color, drawer); default: throw new Exception("Not implemented: " + data.Shape.Drawer); } }
/// <summary> /// Draws a village on the map /// </summary> /// <param name="g">The graphics object</param> /// <param name="game">The game location of the village</param> /// <param name="mapVillage">Where and how big to draw the village</param> private void Paint(Graphics g, Point game, Rectangle mapVillage) { if (!(game.X >= 0 && game.X < 1000 && game.Y >= 0 && game.Y < 1000)) { return; } Village village; DrawerBase finalCache = null; if (World.Default.Villages.TryGetValue(game, out village)) { Marker marker = _markers.GetMarker(Settings, village); if (marker != null) { // Paint village icon/shape BackgroundDrawerData mainData = World.Default.Views.GetBackgroundDrawerData(village, marker); if (mainData != null) { finalCache = _drawerFactoryStrategy.CreateVillageDrawer(village.Bonus, mainData, marker); if (finalCache != null) { finalCache.PaintVillage(g, mapVillage); if (_drawerFactoryStrategy.SupportDecorators && village.Type != VillageType.None) { // Paint extra village decorators foreach (DrawerBase decorator in World.Default.Views.GetDecoratorDrawers(_drawerFactoryStrategy, village, mainData)) { decorator.PaintVillage(g, mapVillage); } } } } } } if (finalCache == null) { PaintNonVillage(g, game, mapVillage); } }
protected abstract DrawerBase CreateVillageDrawerCore(Village.BonusType bonusType, BackgroundDrawerData data, Marker marker);
protected abstract DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData);
/// <summary> /// Create drawer for village background (Shape/Icon) /// </summary> /// <param name="bonusType">Bonus villages have a different icon</param> /// <param name="data">The shape of the drawer</param> /// <param name="colors">The colors for the drawer</param> public DrawerBase CreateVillageDrawer(Village.BonusType bonusType, BackgroundDrawerData data, Marker colors) { DrawerBase drawer = CreateVillageDrawerCore(bonusType, data, colors); return drawer; }
/// <summary> /// Create drawer to further decorate a village drawn by <see cref="CreateVillageDrawer"/> /// </summary> /// <param name="data">The shape of the drawer</param> /// <param name="colors">The colors for the drawer</param> /// <param name="mainData">The data for the main drawer (used for BorderDrawer)</param> public DrawerBase CreateVillageDecoratorDrawer(DecoratorDrawerData data, BackgroundDrawerData mainData) { Debug.Assert(SupportDecorators); DrawerBase drawer = CreateVillageDecoratorDrawerCore(data, mainData); return drawer; }
public IEnumerable <DrawerBase> GetDecoratorDrawers(DrawerFactoryBase drawerFactory, Village village, BackgroundDrawerData mainData) { return(_decorators .Select(decorator => decorator.GetDecoratorDrawer(drawerFactory, village, mainData)) .Where(drawer => drawer != null)); }
protected override DrawerBase CreateVillageDrawerCore(Village.BonusType villageBonus, BackgroundDrawerData data, Marker marker) { string iconName = villageBonus == Village.BonusType.None ? data.IconDrawer : data.BonusIconDrawer; if (string.IsNullOrEmpty(iconName)) { return null; } var icon = (Bitmap)Icons.Villages.ResourceManager.GetObject(iconName); Debug.Assert(icon != null); return new IconDrawer(icon, marker.Settings); }
/// <summary> /// Create drawer for village background (Shape/Icon) /// </summary> /// <param name="bonusType">Bonus villages have a different icon</param> /// <param name="data">The shape of the drawer</param> /// <param name="colors">The colors for the drawer</param> public DrawerBase CreateVillageDrawer(Village.BonusType bonusType, BackgroundDrawerData data, Marker colors) { DrawerBase drawer = CreateVillageDrawerCore(bonusType, data, colors); return(drawer); }
protected override DrawerBase CreateVillageDrawerCore(Village.BonusType villageBonus, BackgroundDrawerData data, Marker marker) { if (marker.Settings.ExtraColor != Color.Transparent) return new MiniMapDrawer(marker.Settings.ExtraColor); return new MiniMapDrawer(marker.Settings.Color); }
protected override DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData) { return null; }
protected override DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData) { if (data.Shape == null) { return(null); } switch (data.Shape.Drawer) { case "BorderDrawer": var drawer = mainData.ShapeDrawer == "EllipseDrawer" ? BorderDrawer.EllipseDrawer : BorderDrawer.RectangleDrawer; return(new BorderDrawer(data.Shape.Color, drawer)); default: throw new Exception("Not implemented: " + data.Shape.Drawer); } }
protected override DrawerBase CreateVillageDrawerCore(Village.BonusType villageBonus, BackgroundDrawerData data, Marker marker) { switch (data.ShapeDrawer) { case "RectangleDrawer": return(new ShapeDrawer(false, marker)); case "EllipseDrawer": return(new ShapeDrawer(true, marker)); default: return(null); } }
public DrawerBase GetDecoratorDrawer(DrawerFactoryBase drawerFactory, Village village, BackgroundDrawerData mainData) { DecoratorDrawerData data = _cache .Where(x => village.Type.HasFlag(x.Key)) .Select(x => x.Value) .FirstOrDefault(); if (data == null) { return(null); } return(drawerFactory.CreateVillageDecoratorDrawer(data, mainData)); }
protected override DrawerBase CreateVillageDrawerCore(Village.BonusType villageBonus, BackgroundDrawerData data, Marker marker) { if (marker.Settings.ExtraColor != Color.Transparent) { return(new MiniMapDrawer(marker.Settings.ExtraColor)); } return(new MiniMapDrawer(marker.Settings.Color)); }
/// <summary> /// A VillageType decorator (off, def, ... icons) /// </summary> protected override DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData) { return new IconDrawerDecorator(data.Icon); }
protected override DrawerBase CreateVillageDrawerCore(Village.BonusType villageBonus, BackgroundDrawerData data, Marker marker) { string iconName = villageBonus == Village.BonusType.None ? data.IconDrawer : data.BonusIconDrawer; if (string.IsNullOrEmpty(iconName)) { return(null); } var icon = (Bitmap)Icons.Villages.ResourceManager.GetObject(iconName); Debug.Assert(icon != null); return(new IconDrawer(icon, marker.Settings)); }
protected override DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData) { return(null); }
public BackgroundDrawerData GetBackgroundDrawerData(Village village, Marker marker) { BackgroundDrawerData data = _backgroundViews[marker.Settings.View].GetBackgroundDrawer(village); return(data); }