コード例 #1
0
        /// <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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: PointsView.cs プロジェクト: kindam/TWTactics
        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);
        }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        /// <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);
            }
        }
コード例 #7
0
 protected abstract DrawerBase CreateVillageDrawerCore(Village.BonusType bonusType, BackgroundDrawerData data, Marker marker);
コード例 #8
0
ファイル: DrawerFactoryBase.cs プロジェクト: kindam/TWTactics
 protected abstract DrawerBase CreateVillageDrawerCore(Village.BonusType bonusType, BackgroundDrawerData data, Marker marker);
コード例 #9
0
ファイル: DrawerFactoryBase.cs プロジェクト: kindam/TWTactics
 protected abstract DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData);
コード例 #10
0
ファイル: DrawerFactoryBase.cs プロジェクト: kindam/TWTactics
 /// <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;
 }
コード例 #11
0
ファイル: DrawerFactoryBase.cs プロジェクト: kindam/TWTactics
 /// <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;
 }
コード例 #12
0
ファイル: ViewsCollection.cs プロジェクト: windygu/TWTactics
 public IEnumerable <DrawerBase> GetDecoratorDrawers(DrawerFactoryBase drawerFactory, Village village, BackgroundDrawerData mainData)
 {
     return(_decorators
            .Select(decorator => decorator.GetDecoratorDrawer(drawerFactory, village, mainData))
            .Where(drawer => drawer != null));
 }
コード例 #13
0
ファイル: IconDrawerFactory.cs プロジェクト: kindam/TWTactics
        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);
        }
コード例 #14
0
        /// <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);
        }
コード例 #15
0
 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);
 }
コード例 #16
0
 protected override DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData)
 {
     return null;
 }
コード例 #17
0
        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);
            }
        }
コード例 #18
0
        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);
            }
        }
コード例 #19
0
ファイル: VillageTypeView.cs プロジェクト: windygu/TWTactics
        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));
        }
コード例 #20
0
 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));
 }
コード例 #21
0
ファイル: IconDrawerFactory.cs プロジェクト: kindam/TWTactics
 /// <summary>
 /// A VillageType decorator (off, def, ... icons)
 /// </summary>
 protected override DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData)
 {
     return new IconDrawerDecorator(data.Icon);
 }
コード例 #22
0
 protected abstract DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData);
コード例 #23
0
        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));
        }
コード例 #24
0
 protected override DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData)
 {
     return(null);
 }
コード例 #25
0
ファイル: ViewsCollection.cs プロジェクト: windygu/TWTactics
        public BackgroundDrawerData GetBackgroundDrawerData(Village village, Marker marker)
        {
            BackgroundDrawerData data = _backgroundViews[marker.Settings.View].GetBackgroundDrawer(village);

            return(data);
        }