using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Game200
{
    public class Segment
    {
        public Vec position;
        public Texture2D image;
        bool isWall;
        public bool isX, isDone, isWallCopy;
        public Rectangle rec;
        public Color color, curColor;

        public Segment(int x, int y, bool isX, bool isWall)
        {
            position = new Vec(x, y);
            this.isWall = isWall;
            this.isX = isX;
            image = C.LoadImage("pixel");
            if (isWall)
                color = Color.Black;
            else
                color = Color.White;
            curColor = color;
            if (isX)
                rec = new Rectangle(C.FromCoord(position), new Point(C.length, 2));
            else
                rec = new Rectangle(C.FromCoord(position), new Point(2, C.length));
            isDone = false;
            isWallCopy = isWall;
        }

        public void Update()
        {
            curColor = color;
        }

        public void EditorUpd()
        {
            isWall = !isWall;
            isWallCopy = isWall;
            if (isWall)
                color = Color.Black;
            else
                color = Color.White;
            curColor = color;
        }

        public bool IsWall()
        {
            isDone = true;
            return isWall;
        }

        public void Draw()
        {
            if (curColor != Color.White)
                C.spriteBatch.Draw(image, rec, curColor);
        }

        public void EditorDraw()
        {
            C.spriteBatch.Draw(image, rec, curColor);
        }
    }
}
