Ejemplo n.º 1
0
        public Game(
            // Game objects:
            IGameState gameState,
            IMap map,
            IToolset toolset,
            // Processors:
            IDrawMapProcessor drawMapProcessor,
            IDrawToolsetProcessor drawToolsetProcessor,
            ITaskProcessor taskProcessor,
            // Settings:
            IDrawSettings drawSettings,
            IEntityFactory entityFactory,

            ILevelBuilder levelBuilder)
        {
            #region Arguments Validation

            Condition.Requires(gameState, nameof(gameState)).IsNotNull();
            Condition.Requires(map, nameof(map)).IsNotNull();
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();

            Condition.Requires(drawMapProcessor, nameof(drawMapProcessor)).IsNotNull();
            Condition.Requires(drawToolsetProcessor, nameof(drawToolsetProcessor)).IsNotNull();
            Condition.Requires(taskProcessor, nameof(taskProcessor)).IsNotNull();

            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            Condition.Requires(entityFactory, nameof(entityFactory)).IsNotNull();

            Condition.Requires(levelBuilder, nameof(levelBuilder)).IsNotNull();

            #endregion Arguments Validation

            this._levelBuilder = levelBuilder;
            this._state        = gameState;
            this._map          = map;
            this._toolset      = toolset;

            this._drawMapProcessor     = drawMapProcessor;
            this._drawToolsetProcessor = drawToolsetProcessor;
            this._taskProcessor        = taskProcessor;

            this._gameProcessorsBasket = new GameProcessorsBasket(
                this._state,
                this._map,
                this._toolset);

            this.MapLeftButtonMouseController = new MapLeftButtonMouseController(
                drawSettings,
                entityFactory,
                this._map,
                this._taskProcessor,
                this._toolset);

            this.MapRightButtonMouseController = new MapRightButtonMouseController(
                this._toolset);

            this.ToolsLeftButtonMouseController = new ToolsLeftButtonMouseController(
                drawSettings,
                this._toolset);
        }
Ejemplo n.º 2
0
 public CloudVisualizer(IDrawSettings settings, ICloudLayouter layouter, ICloudDrawer cloudDrawer, Size pictureSize)
 {
     Settings         = settings;
     this.layouter    = layouter;
     this.cloudDrawer = cloudDrawer;
     this.pictureSize = pictureSize;
 }
Ejemplo n.º 3
0
        public PointDrawingHelper(IDrawSettings drawSettings, int x, int y)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();

            this._drawSettings = drawSettings;
            this._x            = x;
            this._y            = y;
        }
Ejemplo n.º 4
0
        public LazerRayPainter(IDrawSettings drawSettings)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            this._drawSettings = drawSettings;

            var greenColor = Color.FromArgb(255, 115, 178, 49);

            this._greenPen = new Pen(greenColor, 5);
        }
        public ToolsLeftButtonMouseController(
            IDrawSettings drawSettings,
            IToolset toolset)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();

            this._toolset      = toolset;
            this._drawSettings = drawSettings;
        }
Ejemplo n.º 6
0
        public GroundPainter(
            IDrawSettings drawSettings)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();

            var color = Color.FromArgb(255, 255, 182, 140);

            this._brush        = new SolidBrush(color);
            this._drawSettings = drawSettings;
        }
Ejemplo n.º 7
0
        public FinishPainter(
            IDrawSettings drawSettings)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();

            var color = Color.FromArgb(255, 27, 174, 198);

            this._brush        = new SolidBrush(color);
            this._drawSettings = drawSettings;
        }
Ejemplo n.º 8
0
        public FirePainter(
            IDrawSettings drawSettings)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            this._drawSettings = drawSettings;

            var fireColor = Color.FromArgb(255, 255, 34, 34);

            this._fireBrush = new SolidBrush(fireColor);
        }
        public ToolsetSelectorPainter(
            IDrawSettings drawSettings)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();

            var color = Color.FromArgb(255, 214, 0, 24);
            var brush = new SolidBrush(color);

            this._pen          = new Pen(brush, 4);
            this._drawSettings = drawSettings;
        }
Ejemplo n.º 10
0
        public WallPainter(
            IDrawSettings drawSettings)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();

            var color = Color.FromArgb(255, 214, 117, 99);

            this._brush        = new SolidBrush(color);
            this._drawSettings = drawSettings;
            this._pen          = new Pen(Color.FromArgb(255, 132, 85, 74), 2);
        }
Ejemplo n.º 11
0
        public RofateToLeftPainter(
            IDrawSettings drawSettings)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();

            var color = Color.FromArgb(255, 148, 73, 140);
            var brush = new SolidBrush(color);

            this._pen          = new Pen(brush, 3);
            this._drawSettings = drawSettings;
        }
Ejemplo n.º 12
0
 private void DrawNumeration(Graphics graphics, IList <CloudItem> cloudItems, IDrawSettings settings)
 {
     for (var i = 0; i < cloudItems.Count; i++)
     {
         graphics.DrawString(
             i.ToString(),
             cloudItems[i].Font,
             settings.Colorizer.GetBrush(cloudItems[i]),
             cloudItems[i].Bounds,
             format);
     }
 }
Ejemplo n.º 13
0
        public TorchPainter(IDrawSettings drawSettings)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            this._drawSettings = drawSettings;

            var fireColor = Color.FromArgb(255, 255, 34, 34);

            this._firePen = new Pen(fireColor, 9);

            var stickColor = Color.FromArgb(255, 148, 73, 8);

            this._stickPen = new Pen(stickColor, 5);
        }
Ejemplo n.º 14
0
        public MirrorPainter(IDrawSettings drawSettings)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            this._drawSettings = drawSettings;

            var blueColor = Color.FromArgb(255, 198, 227, 225);

            this._bluePen = new Pen(blueColor, 3);

            var brownColor = Color.FromArgb(255, 148, 73, 8);

            this._brownPen = new Pen(brownColor, 5);
        }
Ejemplo n.º 15
0
        public DrawToolsetProcessor(
            IDrawSettings drawSettings,
            IEntityFactory entityFactory,
            IGameState gameState,
            IToolset toolset)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            Condition.Requires(entityFactory, nameof(entityFactory)).IsNotNull();
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();
            this._toolset = toolset;

            this._toolsetMap       = new ToolsetMap(entityFactory, this._toolset);
            this._drawMapProcessor = new DrawMapProcessor(drawSettings, gameState, this._toolsetMap);
        }
Ejemplo n.º 16
0
        public DrawMapProcessor(
            IDrawSettings drawSettings,
            IGameState gameState,
            IMap map)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            Condition.Requires(gameState, nameof(gameState)).IsNotNull();
            Condition.Requires(map, nameof(map)).IsNotNull();

            this._drawSettings = drawSettings;
            this._gameState    = gameState;
            this._bufferBitmap = new Bitmap(
                this._drawSettings.PointSize * map.Width,
                this._drawSettings.PointSize * map.Height);

            this._map           = map;
            this._mapLayerOrder = new[]
            {
                MapLayer.Ground,
                MapLayer.PlayerBody,
                MapLayer.Air
            };

            var painters = new List <IPainter>
            {
                new GroundPainter(this._drawSettings),
                new WallPainter(this._drawSettings),
                new FinishPainter(this._drawSettings),

                new PlayerPainter(this._drawSettings, this._gameState),

                new PlayerMoverPainter(this._drawSettings),
                new ToolsetSelectorPainter(this._drawSettings),

                new LazerPainter(this._drawSettings),
                new LazerRayPainter(this._drawSettings),
                new MirrorPainter(this._drawSettings),

                new BombPainter(this._drawSettings),
                new FirePainter(this._drawSettings),
                new TorchPainter(this._drawSettings),

                new RofateToLeftPainter(this._drawSettings),
                new RofateToRightPainter(this._drawSettings),
            };

            painters.Add(new ToolOnMapPainter(this._drawSettings, painters));
            this._painters = painters;
        }
Ejemplo n.º 17
0
        public ToolOnMapPainter(
            IDrawSettings drawSettings,
            IEnumerable <IPainter> painters)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            Condition.Requires(painters, nameof(painters)).IsNotNull();
            this._drawSettings = drawSettings;
            this._painters     = painters;

            var backgroundColor = Color.FromArgb(255, 24, 146, 222);

            this._backgroundBrush = new SolidBrush(backgroundColor);

            var greenColor = Color.FromArgb(255, 115, 178, 49);

            this._outlinePen = new Pen(greenColor, 2);
        }
Ejemplo n.º 18
0
        public PlayerPainter(
            IDrawSettings drawSettings,
            IGameState gameState)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            Condition.Requires(gameState, nameof(gameState)).IsNotNull();

            var blackColor = Color.FromArgb(255, 0, 0, 0);

            this._blackBrush = new SolidBrush(blackColor);

            var blueColor = Color.FromArgb(255, 148, 73, 140);

            this._blueBrush    = new SolidBrush(blueColor);
            this._drawSettings = drawSettings;
            this._gameState    = gameState;
        }
Ejemplo n.º 19
0
        public LazerPainter(IDrawSettings drawSettings)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            this._drawSettings = drawSettings;

            var blueColor = Color.FromArgb(255, 49, 52, 189);

            this._blueBrush = new SolidBrush(blueColor);

            var pupleColor = Color.FromArgb(255, 123, 24, 49);

            this._pupleBrush = new SolidBrush(pupleColor);

            var redColor = Color.FromArgb(255, 247, 32, 41);

            this._redPen = new Pen(redColor, 5);
        }
Ejemplo n.º 20
0
        public void Draw(Graphics graphics, IList <CloudItem> cloudItems, IDrawSettings settings)
        {
            if (settings.DrawFormat != DrawFormat.OnlyWords)
            {
                graphics.DrawRectangles(Pens.Black, cloudItems.Select(t => t.Bounds).ToArray());
            }

            if (settings.DrawFormat == DrawFormat.OnlyWords || settings.DrawFormat == DrawFormat.WordsInRectangles)
            {
                DrawAsString(graphics, cloudItems, settings);
            }

            if (settings.DrawFormat == DrawFormat.RectanglesWithNumeration)
            {
                DrawNumeration(graphics, cloudItems, settings);
            }
        }
Ejemplo n.º 21
0
        public BombPainter(
            IDrawSettings drawSettings)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            this._drawSettings = drawSettings;

            var blackcolor = Color.FromArgb(255, 57, 60, 57);

            this._blackBrush = new SolidBrush(blackcolor);

            var activatedWickColor = Color.FromArgb(255, 255, 34, 34);

            this._activatedWickBrush = new SolidBrush(activatedWickColor);

            var normalWickColor = Color.FromArgb(255, 198, 190, 189);

            this._normalWickBrush = new SolidBrush(normalWickColor);
        }
Ejemplo n.º 22
0
        public MapLeftButtonMouseController(
            IDrawSettings drawSettings,
            IEntityFactory entityFactory,
            IMap map,
            ITaskProcessor taskProcessor,
            IToolset toolset)
        {
            Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull();
            Condition.Requires(entityFactory, nameof(entityFactory)).IsNotNull();
            Condition.Requires(map, nameof(map)).IsNotNull();
            Condition.Requires(taskProcessor, nameof(taskProcessor)).IsNotNull();
            Condition.Requires(toolset, nameof(toolset)).IsNotNull();

            this._drawSettings  = drawSettings;
            this._entityFactory = entityFactory;
            this._map           = map;
            this._taskProcessor = taskProcessor;
            this._toolset       = toolset;
        }
Ejemplo n.º 23
0
 private void DrawAsString(Graphics graphics, IEnumerable <CloudItem> cloudItems, IDrawSettings settings)
 {
     foreach (var cloudItem in cloudItems)
     {
         graphics.DrawString(
             cloudItem.Word,
             cloudItem.Font,
             settings.Colorizer.GetBrush(cloudItem),
             cloudItem.Bounds,
             format);
     }
 }