/// <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 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 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); } }
public override void ReadDrawerXml(XElement drawer) { DecoratorDrawerData.IconData icon = null; DecoratorDrawerData.ShapeData shape = null; var villageType = (VillageType)Enum.Parse(typeof(VillageType), drawer.Attribute("VillageType").Value); var xShape = drawer.Element("Shape"); if (xShape != null) { shape = new DecoratorDrawerData.ShapeData( xShape.Attribute("Drawer").Value, XmlHelper.GetColor(xShape.Attribute("Color").Value)); } var xIcon = drawer.Element("Icon"); if (xIcon != null) { Color?backgroundColor = null; var xBackgroundColor = xIcon.Attribute("Background"); if (xBackgroundColor != null) { backgroundColor = XmlHelper.GetColor(xBackgroundColor.Value); } icon = new DecoratorDrawerData.IconData( xIcon.Attribute("Icon").Value, (IconOrientation)Enum.Parse(typeof(IconOrientation), xIcon.Attribute("Orientation").Value), backgroundColor); } var data = new DecoratorDrawerData(shape, icon); _cache.Add(villageType, data); }
public IconDrawerDecorator(DecoratorDrawerData.IconData data) { _data = data; }
protected override DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData) { return(null); }
protected abstract DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData);