Esempio n. 1
0
 public Camera(Canvas.Canvas canvas)
 {
     this.X      = 0;
     this.Y      = 0;
     this.Width  = canvas.Width;
     this.Height = canvas.Height;
 }
Esempio n. 2
0
        public AddOrnament(CanvasManager canvasManager, List <IFigure> figures)
        {
            canvas = canvasManager.canvas;

            foreach (var fig in figures)
            {
                DecoratedFigure df = fig is DecoratedFigure? (DecoratedFigure)fig : new DecoratedFigure(fig);

                Console.WriteLine("What direction of figure " + fig.ToString() + " do you want to add an ornament?");
                string dir = Console.ReadLine();

                Console.WriteLine("What do you want to write here?");
                string input = Console.ReadLine();

                if (dir == "north" || dir == "up" || dir == "top")
                {
                    df.North(input);
                }
                if (dir == "east" || dir == "right")
                {
                    df.East(input);
                }
                if (dir == "south" || dir == "down" || dir == "bottom")
                {
                    df.South(input);
                }
                if (dir == "west" || dir == "left")
                {
                    df.West(input);
                }
                decFigures.Add(df);
            }
        }
Esempio n. 3
0
 public void Draw(SpriteBatch spriteBatch, Canvas.Canvas canvas, Map map)
 {
     for (int i = 0; i < this.Statics.Count; i++)
     {
         this.Statics[i].Draw(spriteBatch, canvas, map);
     }
 }
Esempio n. 4
0
        public static void Line(SpriteBatch spriteBatch, Canvas.Canvas canvas, float x1, float y1, float x2, float y2, Color color, float lineWidth)
        {
            Draw.vector1.X = (x1 - canvas.Camera.X) * canvas.Width / canvas.Camera.Width;
            Draw.vector1.Y = (y1 - canvas.Camera.Y) * canvas.Height / canvas.Camera.Height;
            Draw.vector2.X = (x2 - canvas.Camera.X) * canvas.Width / canvas.Camera.Width;
            Draw.vector2.Y = (y2 - canvas.Camera.Y) * canvas.Height / canvas.Camera.Height;

            Draw.angle  = (float)Math.Atan2(Draw.vector2.Y - Draw.vector1.Y, Draw.vector2.X - Draw.vector1.X);
            Draw.length = (float)Math.Sqrt((Draw.vector2.Y - Draw.vector1.Y) * (Draw.vector2.Y - Draw.vector1.Y) + (Draw.vector2.X - Draw.vector1.X) * (Draw.vector2.X - Draw.vector1.X));

            Draw.vectorScale.X = Draw.length;

            if (y2 == y1)
            {
                Draw.vectorScale.Y = canvas.Height / canvas.Camera.Height;
            }
            else if (x2 == x1)
            {
                Draw.vectorScale.Y = canvas.Width / canvas.Camera.Width;
            }
            else
            {
                Draw.vectorScale.Y = lineWidth * (float)Math.Sqrt((1 / (x2 - x1) / (x2 - x1)) + (1 / (y2 - y1) / (y2 - y1))) /
                                     (float)Math.Sqrt((1 / (Draw.vector2.X - Draw.vector1.X) / (Draw.vector2.X - Draw.vector1.X)) + (1 / (Draw.vector2.Y - Draw.vector1.Y) / (Draw.vector2.Y - Draw.vector1.Y)));
            }

            spriteBatch.Draw(GraphicManager.WhiteBox, Draw.vector1, null, color, Draw.angle, Vector2.UnitY / 2, Draw.vectorScale, SpriteEffects.None, 0f);
        }
Esempio n. 5
0
 public void Draw(SpriteBatch spriteBatch, Canvas.Canvas canvas)
 {
     if (this.Showing)
     {
         Graphic.Draw.Rectangle(spriteBatch, canvas, this.X, this.Y, this.Width, this.Height, false);
     }
 }
Esempio n. 6
0
        public override void Draw(SpriteBatch spriteBatch, Canvas.Canvas canvas)
        {
            CameraOffsetCaculator.X = (this.Position.X + this.Offset.X - canvas.Camera.X) * canvas.Width / canvas.Camera.Width;
            CameraOffsetCaculator.Y = (this.Position.Y + this.Offset.Y - canvas.Camera.Y) * canvas.Height / canvas.Camera.Height;

            spriteBatch.DrawString(this.Font, this.Text, CameraOffsetCaculator, this.Color);
            base.Draw(spriteBatch, canvas);
        }
Esempio n. 7
0
 public override void Draw(SpriteBatch spriteBatch, Canvas.Canvas canvas)
 {
     for (int i = 0; i < this.Rooms.Count; i++)
     {
         this.Rooms[i].Draw(spriteBatch, canvas, this);
     }
     //base.Draw(spriteBatch);
 }
Esempio n. 8
0
        public Canvas.Canvas DrawLine(string[] args, Canvas.Canvas existingCanvas)
        {
            List <Point> points     = LinePoints(args);
            Point        point1     = points[0];
            Point        point2     = points[1];
            Line         lineToDraw = new Line(point1, point2);

            return(DrawLineInCanvas(lineToDraw, existingCanvas));
        }
Esempio n. 9
0
        public Canvas.Canvas FillColor(string[] args, Canvas.Canvas existingCanvas)
        {
            uint  ptx            = Convert.ToUInt32(args[0]) - 1;
            uint  pty            = existingCanvas.Height - (Convert.ToUInt32(args[1]));
            char  colorChar      = Convert.ToChar(args[2]);
            Point fillStartPoint = new Point(ptx, pty);

            return(this.Fill(fillStartPoint, colorChar, existingCanvas));
        }
Esempio n. 10
0
        public static void Initialize(Game game, GraphicsDeviceManager graphics)
        {
            SceneManager.TransitionCanvas = new Canvas.Canvas(game.GraphicsDevice, Engine.Width, Engine.Height, false);

            //Initialize scenes
            for (int i = 0; i < SceneManager.Scenes.Count; i++)
            {
                SceneManager.Scenes[i].Initialize(game, graphics);
            }
        }
Esempio n. 11
0
        private Canvas.Canvas DrawRectangleInCanvas(Rectangle rectangleToDraw, Canvas.Canvas existingCanvas)
        {
            List <Line.Line> rectangleLines = GetAllLinesForRectangle(rectangleToDraw);

            foreach (Line.Line line in rectangleLines)
            {
                lineOpp.DrawLineInCanvas(line, existingCanvas);
            }
            return(existingCanvas);
        }
Esempio n. 12
0
        public void Draw(SpriteBatch spriteBatch, Canvas.Canvas canvas, Map map)
        {
            this.Rectangle.X      = (int)Math.Floor((this.X - canvas.Camera.X) * canvas.Width / canvas.Camera.Width);
            this.Rectangle.Y      = (int)Math.Floor((this.Y - canvas.Camera.Y) * canvas.Height / canvas.Camera.Height);
            this.Rectangle.Width  = (int)Math.Floor((this.X + map.Data.BlockSize - canvas.Camera.X) * canvas.Width / canvas.Camera.Width) - this.Rectangle.X;
            this.Rectangle.Height = (int)Math.Floor((this.Y + map.Data.BlockSize - canvas.Camera.Y) * canvas.Height / canvas.Camera.Height) - this.Rectangle.Y;

            spriteBatch.Draw(map.TileSet, this.Rectangle, map.Quads[this.QuadId], Color.White);
            this.Box.Draw(spriteBatch, canvas);
        }
Esempio n. 13
0
        public Canvas.Canvas DrawLineInCanvas(Line lineToDraw, Canvas.Canvas existingCanvas)
        {
            List <Point> linePoints = ProcessPoineForLine(lineToDraw, existingCanvas.Height);

            foreach (Point pt in linePoints)
            {
                CanvasCell content = new CanvasCell(ContentCharacter.Line, 'x');
                existingCanvas.Cells[pt.X, pt.Y] = content;
            }
            return(existingCanvas);
        }
Esempio n. 14
0
        public override void Draw(SpriteBatch spriteBatch, Canvas.Canvas canvas)
        {
            this.Rectangle.X = (int)Math.Floor((this.Position.X + this.Offset.X - canvas.Camera.X) * canvas.Width / canvas.Camera.Width);
            this.Rectangle.Y = (int)Math.Floor((this.Position.Y + this.Offset.Y - canvas.Camera.Y) * canvas.Height / canvas.Camera.Height);
            //this.Rectangle.Width = (int)Math.Floor(this.Texture.Width * this.Scale.X * canvas.Width / canvas.Camera.Width);
            //this.Rectangle.Height = (int)Math.Floor(this.Texture.Height * this.Scale.Y * canvas.Height / canvas.Camera.Height);
            this.Rectangle.Width  = (int)Math.Floor((this.Position.X + this.Offset.X + this.Texture.Width * this.Scale.X - canvas.Camera.X) * canvas.Width / canvas.Camera.Width) - this.Rectangle.X;
            this.Rectangle.Height = (int)Math.Floor((this.Position.Y + this.Offset.Y + this.Texture.Height * this.Scale.Y - canvas.Camera.Y) * canvas.Height / canvas.Camera.Height) - this.Rectangle.Y;

            spriteBatch.Draw(this.Texture, this.Rectangle, this.Color);
            base.Draw(spriteBatch, canvas);
        }
Esempio n. 15
0
        public bool ValidateFillColor(Canvas.Canvas existingCanvas, string[] args)
        {
            uint  ptx            = Convert.ToUInt32(args[0]) - 1;
            uint  pty            = existingCanvas.Height - (Convert.ToUInt32(args[1]));
            Point fillStartPoint = new Point(ptx, pty);

            if (canvasOpp.IsPointOutOfBounds(fillStartPoint, existingCanvas))
            {
                Console.WriteLine("Point(s) for the Fill Color are out of Canvas.");
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 16
0
        public bool ValidateLine(Canvas.Canvas existingCanvas, string[] args)
        {
            List <Point> points = LinePoints(args);
            Point        point1 = points[0];
            Point        point2 = points[1];

            if (canvasOpp.IsPointOutOfBounds(point1, existingCanvas) || canvasOpp.IsPointOutOfBounds(point2, existingCanvas))
            {
                Console.WriteLine("Point(s) for the line are out of Canvas.");
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 17
0
        public bool ValidateRectangle(Canvas.Canvas existingCanvas, string[] args)
        {
            Rectangle rect = GetRectangleObjectsFromInput(args);

            if (canvasOpp.IsPointOutOfBounds(rect.TopLeft, existingCanvas) ||
                canvasOpp.IsPointOutOfBounds(rect.TopRight, existingCanvas) ||
                canvasOpp.IsPointOutOfBounds(rect.BottomLeft, existingCanvas) ||
                canvasOpp.IsPointOutOfBounds(rect.BottomRight, existingCanvas))
            {
                Console.WriteLine("Point(s) for the Rectangle are out of Canvas.");
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 18
0
        private Canvas.Canvas Fill(Point fillStartPoint, char colorChar, Canvas.Canvas existingCanvas)
        {
            char contentToFill = existingCanvas.Cells[fillStartPoint.X, fillStartPoint.Y].content;

            List <Point>  pointsFilled = new List <Point>();
            Queue <Point> pointsToFill = new Queue <Point>();

            pointsToFill.Enqueue(fillStartPoint);

            while (pointsToFill.Count > 0)
            {
                Point currentPoint = pointsToFill.Dequeue();
                pointsFilled.Add(currentPoint);
                if (existingCanvas.Cells[currentPoint.X, currentPoint.Y].content == contentToFill)
                {
                    existingCanvas.Cells[currentPoint.X, currentPoint.Y] = new CanvasCell(ContentCharacter.Line, colorChar);

                    Point leftPoint = new Point(currentPoint.X - 1, currentPoint.Y);
                    if (ChechIfToBeFilled(leftPoint, pointsFilled, pointsToFill, existingCanvas))
                    {
                        pointsToFill.Enqueue(leftPoint);
                    }

                    Point rightPoint = new Point(currentPoint.X + 1, currentPoint.Y);
                    if (ChechIfToBeFilled(rightPoint, pointsFilled, pointsToFill, existingCanvas))
                    {
                        pointsToFill.Enqueue(rightPoint);
                    }

                    Point topPoint = new Point(currentPoint.X, currentPoint.Y - 1);
                    if (ChechIfToBeFilled(topPoint, pointsFilled, pointsToFill, existingCanvas))
                    {
                        pointsToFill.Enqueue(topPoint);
                    }

                    Point bottomPoint = new Point(currentPoint.X, currentPoint.Y + 1);
                    if (ChechIfToBeFilled(bottomPoint, pointsFilled, pointsToFill, existingCanvas))
                    {
                        pointsToFill.Enqueue(bottomPoint);
                    }
                }
            }
            return(existingCanvas);
        }
Esempio n. 19
0
        public static void Rectangle(SpriteBatch spriteBatch, Canvas.Canvas canvas, float x, float y, float width, float height, bool fill, Color color)
        {
            Draw.rectangle.X      = (int)Math.Floor((x - canvas.Camera.X) * canvas.Width / canvas.Camera.Width);
            Draw.rectangle.Y      = (int)Math.Floor((y - canvas.Camera.Y) * canvas.Height / canvas.Camera.Height);
            Draw.rectangle.Width  = (int)Math.Floor((x + width - canvas.Camera.X) * canvas.Width / canvas.Camera.Width) - Draw.rectangle.X;
            Draw.rectangle.Height = (int)Math.Floor((y + height - canvas.Camera.Y) * canvas.Height / canvas.Camera.Height) - Draw.rectangle.Y;

            if (fill)
            {
                spriteBatch.Draw(GraphicManager.WhiteBox, Draw.rectangle, color);
            }
            else
            {
                //Top side of rectangle
                Draw.rectangle1        = Draw.rectangle;
                Draw.rectangle1.Height = (int)Math.Floor(canvas.Height / canvas.Camera.Height);
                spriteBatch.Draw(GraphicManager.WhiteBox, Draw.rectangle1, color);

                //Left side of rectangle
                Draw.rectangle2       = Draw.rectangle;
                Draw.rectangle2.Width = (int)Math.Floor(canvas.Width / canvas.Camera.Width);
                spriteBatch.Draw(GraphicManager.WhiteBox, Draw.rectangle2, color);

                //Bottom side of rectangle
                Draw.rectangle3        = Draw.rectangle;
                Draw.rectangle3.Y      = Draw.rectangle.Y + Draw.rectangle.Height - (int)Math.Floor(canvas.Height / canvas.Camera.Height);
                Draw.rectangle3.Height = (int)Math.Floor(canvas.Height / canvas.Camera.Height);
                spriteBatch.Draw(GraphicManager.WhiteBox, Draw.rectangle3, color);

                //Right side of rectangle
                Draw.rectangle4       = Draw.rectangle;
                Draw.rectangle4.X     = Draw.rectangle.X + Draw.rectangle.Width - (int)Math.Floor(canvas.Width / canvas.Camera.Width);
                Draw.rectangle4.Width = (int)Math.Floor(canvas.Width / canvas.Camera.Width);
                spriteBatch.Draw(GraphicManager.WhiteBox, Draw.rectangle4, color);
            }
        }
Esempio n. 20
0
 /// <summary>
 /// Initialises a new instance of the <see cref="WelcomePage"/> class.
 /// </summary>
 public WelcomePage(Canvas.Canvas view) : base(view, false)
 {
     InitializeComponent();
 }
Esempio n. 21
0
 public DrawEngineParser(Canvas.Canvas canvas)
 {
     this.canvas = canvas;
 }
Esempio n. 22
0
 public virtual void Draw(SpriteBatch spriteBatch, Canvas.Canvas canvas)
 {
     //this.Box.Showing = true;
     this.Sprite.Draw(spriteBatch, canvas);
     this.Box.Draw(spriteBatch, canvas);
 }
Esempio n. 23
0
 /// <summary>
 /// Initialises a new instance of the <see cref="ForumPage"/> class with
 /// the specified Canvas and optional separator.
 /// </summary>
 public ForumPage(Canvas.Canvas view, bool separator) : base(view, separator)
 {
     InitializeComponent();
 }
Esempio n. 24
0
 /// <summary>
 /// Initialises a new instance of the <see cref="MessageItem"/> class
 /// with the specified Canvas.
 /// </summary>
 public MessageItem(Canvas.Canvas view)
     : base(view, false)
 {
     IsExpandable = true;
     InitializeComponent();
 }
Esempio n. 25
0
 /// <summary>
 /// Initialises a new instance of the <see cref="ProfileItem"/> class with
 /// the specified Canvas and optional separator.
 /// </summary>
 public ProfileItem(Canvas.Canvas view, bool separator)
     : base(view, separator)
 {
     InitializeComponent();
 }
Esempio n. 26
0
 private bool ChechIfToBeFilled(Point point, List <Point> pointsFilled, Queue <Point> pointsToFill, Canvas.Canvas existingCanvas)
 {
     return(!pointsFilled.Contains(point) && !pointsToFill.Contains(point) && !canvasOpp.IsPointOutOfBounds(point, existingCanvas));
 }
Esempio n. 27
0
 public virtual void Draw(SpriteBatch spriteBatch, Canvas.Canvas canvas)
 {
 }
Esempio n. 28
0
        public Canvas.Canvas DrawRectangle(string[] args, Canvas.Canvas existingCanvas)
        {
            Rectangle RectangleToDraw = GetRectangleObjectsFromInput(args);

            return(DrawRectangleInCanvas(RectangleToDraw, existingCanvas));
        }