Beispiel #1
0
 private static void ValidateGrapic(IMazeGraphic mazeGraphic)
 {
     if (mazeGraphic is null)
     {
         throw new ArgumentException("No Graphic found cant draw");
     }
 }
Beispiel #2
0
        public void Draw(INode node, IMazeGraphic graphic, IMazeViewData mazeView, Point topLeft, Point topRight, Point bottomLeft, Point bottomRight)
        {
            INode leftNode   = node.GetNeigbour(mazeView, new LeftDirection());
            INode bottomNode = node.GetNeigbour(mazeView, new DownDirection());
            INode rightNode  = node.GetNeigbour(mazeView, new RightDirection());
            INode topNode    = node.GetNeigbour(mazeView, new UpDirection());

            var pen = new Pen(Color.Blue);

            if (!Validator.DoesPathToNodeExist(node, topNode))
            {
                graphic.DrawLine(pen, topLeft, topRight);
            }

            if (!Validator.DoesPathToNodeExist(node, rightNode))
            {
                graphic.DrawLine(pen, topRight, bottomRight);
            }

            if (!Validator.DoesPathToNodeExist(node, bottomNode))
            {
                graphic.DrawLine(pen, bottomRight, bottomLeft);
            }

            if (!Validator.DoesPathToNodeExist(node, leftNode))
            {
                graphic.DrawLine(pen, bottomLeft, topLeft);
            }
        }
Beispiel #3
0
        private void DrawNode(int x, int y, INode node, IMazeGraphic graphic, IMazeViewData mazeView, IUnitList unitList)
        {
            int indeX = GetNodePoint(x, node.SquareSize, mazeView.ViewStart);
            int indeY = GetNodePoint(y, node.SquareSize, mazeView.ViewStart);

            DrawNode(node, graphic, mazeView, indeX, indeY);
            DrawCollectable(node, graphic, indeX, indeY);
            DrawPlayer(node, graphic, unitList, indeX, indeY);
        }
Beispiel #4
0
        public void Draw(IMazeGraphic graphics, Rectangle rectangle, INode node)
        {
            if (!node.Location.Equals(CurrentLocation))
            {
                return;
            }

            graphics?.FillRectangle(Brushes.Red, rectangle);
        }
Beispiel #5
0
        private void DrawNode(INode node, IMazeGraphic graphic, IMazeViewData mazeView, int indeX, int indeY)
        {
            int HalfOfNodeSize = _defaultSettings.HalfOfNodeSize;
            var topLeft        = new Point(indeX - HalfOfNodeSize, indeY - HalfOfNodeSize);
            var topRight       = new Point(indeX + HalfOfNodeSize, indeY - HalfOfNodeSize);
            var bottomLeft     = new Point(indeX - HalfOfNodeSize, indeY + HalfOfNodeSize);
            var bottomRight    = new Point(indeX + HalfOfNodeSize, indeY + HalfOfNodeSize);

            node.Draw(node, graphic, mazeView, topLeft, topRight, bottomLeft, bottomRight);
        }
Beispiel #6
0
        private void DrawCollectable(INode node, IMazeGraphic graphic, int indeX, int indeY)
        {
            int x         = indeX - _defaultSettings.HalfOfCollectableSize;
            int y         = indeY - _defaultSettings.HalfOfCollectableSize;
            int width     = _defaultSettings.CollectableSize;
            int height    = _defaultSettings.CollectableSize;
            var rectangle = new Rectangle(x, y, width, height);

            node.CollectablePoint.Draw(graphic, rectangle);
        }
Beispiel #7
0
        private void DrawPlayer(INode node, IMazeGraphic graphic, IUnitList unitList, int indeX, int indeY)
        {
            IUnit player     = unitList.GetPlayer();
            var   playerRect = new Rectangle(
                indeX - _defaultSettings.HalfOfUnitSize,
                indeY - _defaultSettings.HalfOfUnitSize,
                _defaultSettings.UnitSize,
                _defaultSettings.UnitSize);

            player.Draw(graphic, playerRect, node);
        }
Beispiel #8
0
        public void Draw(IMazeGraphic mazeGraphic, IMazeViewData mazeView, IUnitList unitList)
        {
            ValidateGrapic(mazeGraphic);

            mazeGraphic.Clear(Color.White);
            int index = 0;

            for (int y = mazeView.ViewStart; y <= mazeView.ViewEnd; y++)
            {
                for (int x = mazeView.ViewStart; x <= mazeView.ViewEnd; x++)
                {
                    INode node = mazeView.MazeNodes[index];
                    DrawNode(x, y, node, mazeGraphic, mazeView, unitList);
                    index++;
                }
            }
        }
Beispiel #9
0
 public void Draw(IMazeGraphic graphics, Rectangle rectangle)
 {
     fDoDrawing?.Invoke(graphics, rectangle);
 }