示例#1
0
        private void Display_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.Clear(BlockColors.cGrid);
            // g.PageScale
            g.ScaleTransform(scale, scale);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;


            for (int x = 0; x < currentSim.X; x++)
            {
                for (int y = 0; y < currentSim.Y; y++)
                {
                    //int ba = r.x / scale / 9; (i * 9 + 1) * scale < r.x + r.width;
                    // g.PageScale
                    Rectangle         r = new Rectangle(x * 9 + 1, y * 9 + 1, 8, 8);
                    BlockDrawSettings b = new BlockDrawSettings(currentSim.GetBlock(x, y, cZ));
                    if (b.Block.Type == eBlock.WIRE)
                    {
                        drawWire(g, r, x, y, cZ);
                    }
                    else
                    {
                        BlockImages.gDrawBlock(g, r, b);
                    }
                }
            }
        }
示例#2
0
        public static void gDrawWire(Graphics g, Rectangle r, BlockDrawSettings s)
        {
            Brush b = s.Block.Powered ? BlockColors.bWireOn : BlockColors.bWireOff;


            if (s.Mask.HasFlag(WireMask.North))
            {
                g.FillRectangle(b, r.X + 3, r.Y, 2, 5);
            }
            if (s.Mask.HasFlag(WireMask.South))
            {
                g.FillRectangle(b, r.X + 3, r.Y + 3, 2, 5);
            }
            if (s.Mask.HasFlag(WireMask.East))
            {
                g.FillRectangle(b, r.X + 3, r.Y + 3, 5, 2);
            }
            if (s.Mask.HasFlag(WireMask.West))
            {
                g.FillRectangle(b, r.X, r.Y + 3, 5, 2);
            }
            if (s.Mask == WireMask.None)
            {
                g.FillRectangle(b, r.X + 2, r.Y + 2, 4, 4);
            }
        }
        void makeBar()
        {
            bar = new Bitmap((int)((sArray.Length * 9 + 1) * scale), (int)(scale * 10));
            Graphics g = Graphics.FromImage(bar);

            g.Clear(BlockColors.cGrid);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.ScaleTransform(scale, scale);
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            g.FillRectangle(BlockColors.bHilite, (selected * 9), 0, 10, 10);

            for (int i = 0; i < sArray.Length; i++)
            {
                Rectangle         r = new Rectangle(i * 9 + 1, 1, 8, 8);
                BlockDrawSettings b;
                int j = 0;
                if (sArray[i][0].Type == eBlock.BLOCK)
                {
                    if (sArray[i][1].Type == eBlock.BLOCK)
                    {
                        b     = new BlockDrawSettings(sArray[i][2], WireMask.AllDir, true);
                        b.Fog = true;
                    }
                    else
                    {
                        b = new BlockDrawSettings(sArray[i][1], WireMask.AllDir, true);
                    }
                    b.OnBlock = true;
                }
                else
                {
                    b = new BlockDrawSettings(sArray[i][j], WireMask.AllDir, true);
                }

                if (sArray[i][2].Type == eBlock.BLOCK)
                {
                    b.Fog = true;
                }
                BlockImages.gDrawBlock(g, r, b);
            }
            g.Dispose();
            this.MinimumSize = bar.Size;
            this.MaximumSize = bar.Size;
        }
示例#4
0
        private void Display_Paint(object sender, PaintEventArgs e)
        {
            if (!stopPaint)
            {
                Graphics g = e.Graphics;
                g.Clear(BlockColors.cGrid);
                // g.PageScale
                g.ScaleTransform(scale, scale);
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;


                for (int x = 0; x < currentSim.X; x++)
                {
                    for (int y = 0; y < currentSim.Y; y++)
                    {
                        BlockDrawSettings b;
                        BlockVector       v = new BlockVector(x, y, floor);
                        if (currentSim[v].isBlock && (currentSim[v.Up].isWire || currentSim[v.Up].isPreasurePad ||
                                                      ((currentSim[v.Up].isTorch || currentSim[v.Up].isLeaver || currentSim[v.Up].isTorch) && currentSim[v.Up].Place == Direction.DOWN)))
                        {
                            v         = v.Up;
                            b         = new BlockDrawSettings(currentSim[v]);
                            b.OnBlock = true;
                        }
                        else
                        {
                            b = new BlockDrawSettings(currentSim[v]);
                        }

                        if (currentSim[v.Up].isBlock)
                        {
                            b.Fog = true;
                        }
                        Rectangle r = new Rectangle(x * 9 + 1, y * 9 + 1, 8, 8);


                        BlockImages.gDrawBlock(g, r, b);
                    }
                }
            }
        }
示例#5
0
        public Bitmap[] getFoorOneTiles()
        {
            // make them 50x50
            BlockDrawSettings bd;
            Size     s = new Size(10 * ConstScale, 10 * ConstScale);
            Point    p = new Point(0, 0);
            Graphics g;

            Bitmap[] bArray = new Bitmap[selectArray.Length];

            for (int i = 0; i < bArray.Length; i++)
            {
                bArray[i] = new Bitmap(s.Width, s.Height);
                g         = setGraphics(bArray[i]);
                bd        = new BlockDrawSettings(selectArray[i]);
                BlockImages.gDrawBlock(g, new Rectangle(p, s), bd);
                g.Dispose();
            }

            return(bArray);
        }
        private void Display_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.Clear(BlockColors.cGrid);
            // g.PageScale
            g.ScaleTransform(scale, scale);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            for (int x = 0; x < currentSim.X; x++)
                for (int y = 0; y < currentSim.Y; y++)
                {
                    //int ba = r.x / scale / 9; (i * 9 + 1) * scale < r.x + r.width;
                    // g.PageScale
                    Rectangle r = new Rectangle(x * 9 + 1, y * 9 + 1, 8, 8);
                    BlockDrawSettings b = new BlockDrawSettings(currentSim.GetBlock(x,y,cZ));
                    if (b.Block.Type == eBlock.WIRE)
                        drawWire(g, r, x, y, cZ);
                    else
                        BlockImages.gDrawBlock(g, r, b);

                }
        }
        void makeBar()
        {
            bar = new Bitmap((int)((sArray.Length * 10) * scale), (int)(scale * 10));
            Graphics g = Graphics.FromImage(bar);

            g.Clear(BlockColors.cGrid);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.ScaleTransform(scale, scale);
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            g.FillRectangle(BlockColors.bHilite, (selected * 9), 0, 10, 10);

            for (int i = 0; i < sArray.Length; i++)
            {

                Rectangle r = new Rectangle(i * 9 + 1, 1, 8, 8);
                BlockDrawSettings b;
                int j = 0;
                if (sArray[i][j].isBlock)
                {
                    j++;
                    b = new BlockDrawSettings(sArray[i][j],  true);
                    b.OnBlock = true;
                }
                else
                    b = new BlockDrawSettings(sArray[i][j],  true);

                if (sArray[i][j+1].isBlock) b.Fog = true;
                BlockImages.gDrawBlock(g, r, b);
            }
            g.Dispose();
            this.MinimumSize = bar.Size;
            this.MaximumSize = bar.Size;
        }
        public static void gDrawWire(Graphics g, Rectangle r, BlockDrawSettings s)
        {
            Brush b = s.Block.Powered ? BlockColors.bWireOn : BlockColors.bWireOff;

            if (s.Mask.HasFlag(WireMask.North)) g.FillRectangle(b, r.X + 3, r.Y, 2, 5);
            if (s.Mask.HasFlag(WireMask.South)) g.FillRectangle(b, r.X + 3, r.Y + 3, 2, 5);
            if (s.Mask.HasFlag(WireMask.East)) g.FillRectangle(b, r.X + 3, r.Y + 3, 5, 2);
            if (s.Mask.HasFlag(WireMask.West)) g.FillRectangle(b, r.X, r.Y + 3, 5, 2);
            if (s.Mask == WireMask.None) g.FillRectangle(b, r.X + 2, r.Y + 2, 4, 4);
        }
        public static void gDrawBlock(Graphics g, Rectangle r, BlockDrawSettings b)
        {
            if (b.OverShadow) g.FillRectangle(BlockColors.bGrid, r);
            else
                if (b.Block.Type == eBlock.BLOCK || b.OnBlock) g.FillRectangle(BlockColors.bBlock, r);
                else
                    g.FillRectangle(BlockColors.bAir, r);

            /*
             * 0x1: Facing south
               0x2: Facing north
               0x3: Facing west
               0x4: Facing east
             */

            switch (b.Block.Type)
            {
                case eBlock.WIRE:
                    gDrawWire(g, r, b);
                    break;
                case eBlock.REPEATER:
                    Point[] Arrow = new Point[8];
                    int tick = b.Block.Ticks;
                    bool rpow = b.Block.Powered;
                    //b.Mount =
                    switch (b.Block.Mount)
                    {
                        // There a better, fasterway for a vector arrow?
                        case eMount.NORTH:
                            for (int i = 0; i < 8; i++) { Arrow[i] = northArrow[i]; Arrow[i].Offset(r.Location); }
                            r = new Rectangle(r.X + 3, r.Y + 3, 2, 1);
                            r.Offset(0, tick);
                            break;
                        case eMount.SOUTH:
                            for (int i = 0; i < 8; i++) { Arrow[i] = southArrow[i]; Arrow[i].Offset(r.Location); }
                            r = new Rectangle(r.X + 3, r.Y + 4, 2, 1);
                            r.Offset(0, -tick);
                            break;
                        case eMount.WEST:
                            for (int i = 0; i < 8; i++) { Arrow[i] = westArrow[i]; Arrow[i].Offset(r.Location); }
                            r = new Rectangle(r.X + 4, r.Y + 3, 1, 2);
                            r.Offset(-tick, 0);
                            break;
                        case eMount.EAST:
                            for (int i = 0; i < 8; i++) { Arrow[i] = eastArrow[i]; Arrow[i].Offset(r.Location); }
                            r = new Rectangle(r.X + 3, r.Y + 3, 1, 2);
                            r.Offset(tick, 0);
                            break;
                    }
                    g.FillPolygon(BlockColors.bRepeater, Arrow);
                    // If its powered we light it up, if its not powered we don't need to display a single tick
                    if (rpow & tick == 0)
                        g.FillRectangle(BlockColors.bWireOn, r);
                    else
                        if (tick != 0)
                            if (rpow)
                                g.FillRectangle(BlockColors.bWireOn, r);
                            else
                                g.FillRectangle(BlockColors.bWireOff, r);

                    break;
                case eBlock.LEVER:
                    switch (b.Block.Mount)
                    {
                        case eMount.SOUTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y, 2, 5); break;
                        case eMount.NORTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 2, 5); break;
                        case eMount.EAST: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 5, 2); break;
                        case eMount.WEST: g.FillRectangle(BlockColors.bLever, r.X, r.Y + 3, 5, 2); break;
                    }
                    g.FillEllipse(BlockColors.bValve, r.X + 2, r.Y + 2, 4, 4);
                    if (b.Block.Powered)
                        g.FillEllipse(BlockColors.bWireOn, r.X + 3, r.X + 3, 2, 2);
                    break;
                case eBlock.TORCH:
                    switch (b.Block.Mount)
                    {
                        case eMount.SOUTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y, 2, 5); break;
                        case eMount.NORTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 2, 5); break;
                        case eMount.EAST: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 5, 2); break;
                        case eMount.WEST: g.FillRectangle(BlockColors.bLever, r.X, r.Y + 3, 5, 2); break;
                    }

                    if (b.Block.Powered)
                        g.FillEllipse(BlockColors.bWireOn, r.X + 2, r.Y + 2, 4, 4);
                    else
                        g.FillEllipse(BlockColors.bWireOff, r.X + 2, r.Y + 2, 4, 4);

                    break;

                case eBlock.BUTTON:

                    if (b.Block.Powered)
                        switch (b.Block.Mount)
                        {
                            case eMount.NORTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y + 7, 4, 1); break;
                            case eMount.SOUTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y, 4, 1); break;
                            case eMount.EAST: g.FillRectangle(BlockColors.bButton, r.X + 7, r.Y + 2, 1, 4); break;
                            case eMount.WEST: g.FillRectangle(BlockColors.bButton, r.X, r.Y + 2, 1, 4); break;
                        }
                    else
                        switch (b.Block.Mount)
                        {
                            case eMount.SOUTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y + 5, 4, 3); break;
                            case eMount.NORTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y, 4, 3); break;
                            case eMount.EAST: g.FillRectangle(BlockColors.bButton, r.X + 5, r.Y + 2, 3, 4); break;
                            case eMount.WEST: g.FillRectangle(BlockColors.bButton, r.X, r.Y + 2, 3, 4); break;

                        }
                    break;

                case eBlock.PRESS: // '\t'
                    if (b.Block.Powered)
                        g.FillRectangle(BlockColors.bWireOn, r.X + 1, r.Y + 1, 6, 6);
                    else
                        g.FillRectangle(BlockColors.bValve, r.X + 1, r.Y + 1, 6, 6);
                    break;
                case eBlock.DOORB:
                    break; //Check for this
                case eBlock.DOORA: // '\007'
                    if (b.Block.Powered)
                        switch (b.Block.Mount) // THIS IS UNPOWERED, NEEDS TO BE MODIFIED.
                        // JUST LASY AND TESTING RIGHT NOW
                        {
                            // FYI, this is facing, so its hinge to edge not powered
                            case eMount.NORTH: // Hinge, bottom left, Closed
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 2, 8);
                                g.FillRectangle(BlockColors.bWireOff, r.X, r.Y + 6, 2, 2);
                                break;
                            case eMount.SOUTH: // Hinge upper right, Closed
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 2, 8);
                                g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y, 2, 2);
                                break;
                            case eMount.EAST: // Hinge, upper left
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 8, 2);
                                g.FillRectangle(BlockColors.bWireOff, r.X, r.Y, 2, 2);
                                break;
                            case eMount.WEST:  // bottom right
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 8, 2);
                                g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y + 6, 2, 2);
                                break;
                        }
                    else
                        switch (b.Block.Mount)
                        {
                            // FYI, this is facing, so its hinge to edge not powered
                            case eMount.NORTH: // Hinge, bottom left, Closed
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 2, 8);
                                g.FillRectangle(BlockColors.bWireOff, r.X, r.Y + 6, 2, 2);
                                break;
                            case eMount.SOUTH: // Hinge upper right, Closed
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 2, 8);
                                g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y, 2, 2);
                                break;
                            case eMount.EAST: // Hinge, upper left
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 8, 2);
                                g.FillRectangle(BlockColors.bWireOff, r.X, r.Y, 2, 2);
                                break;
                            case eMount.WEST:  // bottom right
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 8, 2);
                                g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y + 6, 2, 2);
                                break;
                        }

                    break;

            }
            if (b.Fog) g.FillRectangle(BlockColors.bCover, r);
        }
        private void Display_Paint(object sender, PaintEventArgs e)
        {
            if (!stopPaint)
            {

                Graphics g = e.Graphics;
                g.Clear(BlockColors.cGrid);
                // g.PageScale
                g.ScaleTransform(scale, scale);
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

                for (int x = 0; x < currentSim.X; x++)
                    for (int y = 0; y < currentSim.Y; y++)
                    {
                        BlockDrawSettings b;
                        BlockVector v = new BlockVector(x, y, floor);
                        if (currentSim[v].isBlock && (currentSim[v.Up].isWire || currentSim[v.Up].isPreasurePad ||
                            ((currentSim[v.Up].isTorch || currentSim[v.Up].isLeaver || currentSim[v.Up].isTorch) && currentSim[v.Up].Place == Direction.DOWN)))
                        {
                            v = v.Up;
                            b = new BlockDrawSettings(currentSim[v]);
                            b.OnBlock = true;
                        }
                        else
                        {
                            b = new BlockDrawSettings(currentSim[v]);
                        }

                        if (currentSim[v.Up].isBlock) b.Fog = true;
                        Rectangle r = new Rectangle(x * 9 + 1, y * 9 + 1, 8, 8);

                        BlockImages.gDrawBlock(g, r, b);

                    }
            }
        }
示例#11
0
        public static void gDrawBlock(Graphics g, Rectangle r, BlockDrawSettings b)
        {
            if (b.OverShadow)
            {
                g.FillRectangle(BlockColors.bGrid, r);
            }
            else
            if (b.Block.Type == eBlock.BLOCK || b.OnBlock)
            {
                g.FillRectangle(BlockColors.bBlock, r);
            }
            else
            {
                g.FillRectangle(BlockColors.bAir, r);
            }

            /*
             * 0x1: Facing south
             * 0x2: Facing north
             * 0x3: Facing west
             * 0x4: Facing east
             */

            switch (b.Block.Type)
            {
            case eBlock.WIRE:
                gDrawWire(g, r, b);
                break;

            case eBlock.REPEATER:
                Point[] Arrow = new Point[8];
                int     tick  = b.Block.Ticks;
                bool    rpow  = b.Block.Powered;
                //b.Mount =
                switch (b.Block.Mount)
                {
                // There a better, fasterway for a vector arrow?
                case eMount.NORTH:
                    for (int i = 0; i < 8; i++)
                    {
                        Arrow[i] = northArrow[i]; Arrow[i].Offset(r.Location);
                    }
                    r = new Rectangle(r.X + 3, r.Y + 3, 2, 1);
                    r.Offset(0, tick);
                    break;

                case eMount.SOUTH:
                    for (int i = 0; i < 8; i++)
                    {
                        Arrow[i] = southArrow[i]; Arrow[i].Offset(r.Location);
                    }
                    r = new Rectangle(r.X + 3, r.Y + 4, 2, 1);
                    r.Offset(0, -tick);
                    break;

                case eMount.WEST:
                    for (int i = 0; i < 8; i++)
                    {
                        Arrow[i] = westArrow[i]; Arrow[i].Offset(r.Location);
                    }
                    r = new Rectangle(r.X + 4, r.Y + 3, 1, 2);
                    r.Offset(-tick, 0);
                    break;

                case eMount.EAST:
                    for (int i = 0; i < 8; i++)
                    {
                        Arrow[i] = eastArrow[i]; Arrow[i].Offset(r.Location);
                    }
                    r = new Rectangle(r.X + 3, r.Y + 3, 1, 2);
                    r.Offset(tick, 0);
                    break;
                }
                g.FillPolygon(BlockColors.bRepeater, Arrow);
                // If its powered we light it up, if its not powered we don't need to display a single tick
                if (rpow & tick == 0)
                {
                    g.FillRectangle(BlockColors.bWireOn, r);
                }
                else
                if (tick != 0)
                {
                    if (rpow)
                    {
                        g.FillRectangle(BlockColors.bWireOn, r);
                    }
                    else
                    {
                        g.FillRectangle(BlockColors.bWireOff, r);
                    }
                }


                break;

            case eBlock.LEVER:
                switch (b.Block.Mount)
                {
                case eMount.SOUTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y, 2, 5); break;

                case eMount.NORTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 2, 5); break;

                case eMount.EAST: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 5, 2); break;

                case eMount.WEST: g.FillRectangle(BlockColors.bLever, r.X, r.Y + 3, 5, 2); break;
                }
                g.FillEllipse(BlockColors.bValve, r.X + 2, r.Y + 2, 4, 4);
                if (b.Block.Powered)
                {
                    g.FillEllipse(BlockColors.bWireOn, r.X + 3, r.X + 3, 2, 2);
                }
                break;

            case eBlock.TORCH:
                switch (b.Block.Mount)
                {
                case eMount.SOUTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y, 2, 5); break;

                case eMount.NORTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 2, 5); break;

                case eMount.EAST: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 5, 2); break;

                case eMount.WEST: g.FillRectangle(BlockColors.bLever, r.X, r.Y + 3, 5, 2); break;
                }

                if (b.Block.Powered)
                {
                    g.FillEllipse(BlockColors.bWireOn, r.X + 2, r.Y + 2, 4, 4);
                }
                else
                {
                    g.FillEllipse(BlockColors.bWireOff, r.X + 2, r.Y + 2, 4, 4);
                }

                break;

            case eBlock.BUTTON:

                if (b.Block.Powered)
                {
                    switch (b.Block.Mount)
                    {
                    case eMount.NORTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y + 7, 4, 1); break;

                    case eMount.SOUTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y, 4, 1); break;

                    case eMount.EAST: g.FillRectangle(BlockColors.bButton, r.X + 7, r.Y + 2, 1, 4); break;

                    case eMount.WEST: g.FillRectangle(BlockColors.bButton, r.X, r.Y + 2, 1, 4); break;
                    }
                }
                else
                {
                    switch (b.Block.Mount)
                    {
                    case eMount.SOUTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y + 5, 4, 3); break;

                    case eMount.NORTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y, 4, 3); break;

                    case eMount.EAST: g.FillRectangle(BlockColors.bButton, r.X + 5, r.Y + 2, 3, 4); break;

                    case eMount.WEST: g.FillRectangle(BlockColors.bButton, r.X, r.Y + 2, 3, 4); break;
                    }
                }
                break;

            case eBlock.PRESS:     // '\t'
                if (b.Block.Powered)
                {
                    g.FillRectangle(BlockColors.bWireOn, r.X + 1, r.Y + 1, 6, 6);
                }
                else
                {
                    g.FillRectangle(BlockColors.bValve, r.X + 1, r.Y + 1, 6, 6);
                }
                break;

            case eBlock.DOORB:
                break;         //Check for this

            case eBlock.DOORA: // '\007'
                if (b.Block.Powered)
                {
                    switch (b.Block.Mount)     // THIS IS UNPOWERED, NEEDS TO BE MODIFIED.
                    // JUST LASY AND TESTING RIGHT NOW
                    {
                    // FYI, this is facing, so its hinge to edge not powered
                    case eMount.NORTH:         // Hinge, bottom left, Closed
                        g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 2, 8);
                        g.FillRectangle(BlockColors.bWireOff, r.X, r.Y + 6, 2, 2);
                        break;

                    case eMount.SOUTH:         // Hinge upper right, Closed
                        g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 2, 8);
                        g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y, 2, 2);
                        break;

                    case eMount.EAST:         // Hinge, upper left
                        g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 8, 2);
                        g.FillRectangle(BlockColors.bWireOff, r.X, r.Y, 2, 2);
                        break;

                    case eMount.WEST:          // bottom right
                        g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 8, 2);
                        g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y + 6, 2, 2);
                        break;
                    }
                }
                else
                {
                    switch (b.Block.Mount)
                    {
                    // FYI, this is facing, so its hinge to edge not powered
                    case eMount.NORTH:         // Hinge, bottom left, Closed
                        g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 2, 8);
                        g.FillRectangle(BlockColors.bWireOff, r.X, r.Y + 6, 2, 2);
                        break;

                    case eMount.SOUTH:         // Hinge upper right, Closed
                        g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 2, 8);
                        g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y, 2, 2);
                        break;

                    case eMount.EAST:         // Hinge, upper left
                        g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 8, 2);
                        g.FillRectangle(BlockColors.bWireOff, r.X, r.Y, 2, 2);
                        break;

                    case eMount.WEST:          // bottom right
                        g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 8, 2);
                        g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y + 6, 2, 2);
                        break;
                    }
                }


                break;
            }
            if (b.Fog)
            {
                g.FillRectangle(BlockColors.bCover, r);
            }
        }
示例#12
0
        public Bitmap[] getFoorOneTiles()
        {
            // make them 50x50
            BlockDrawSettings bd;
            Size s = new Size(10 * ConstScale, 10 * ConstScale);
            Point p = new Point(0, 0);
            Graphics g;
            Bitmap[] bArray = new Bitmap[selectArray.Length];

            for (int i = 0; i < bArray.Length; i++)
            {
                bArray[i] = new Bitmap(s.Width, s.Height);
                g = setGraphics(bArray[i]);
                bd = new BlockDrawSettings(selectArray[i]);
                BlockImages.gDrawBlock(g, new Rectangle(p, s), bd);
                g.Dispose();
            }

            return bArray;
        }
示例#13
0
        public static void gDrawBlock(Graphics g, Rectangle r, BlockDrawSettings b)
        {
            if (b.OverShadow)
            {
                g.FillRectangle(BlockColors.bGrid, r);
            }
            else
            if (b.B.ID == BlockType.BLOCK || b.OnBlock)
            {
                g.FillRectangle(BlockColors.bBlock, r);
            }
            else
            {
                g.FillRectangle(BlockColors.bAir, r);
            }

            /*
             * 0x1: Facing south
             * 0x2: Facing north
             * 0x3: Facing west
             * 0x4: Facing east
             */

            switch (b.B.ID)
            {
            case BlockType.WIRE:
                gDrawWire(g, r, b);
                break;

            case BlockType.REPEATER:
                Point[]   Arrow = new Point[8];
                Rectangle t     = r;
                int       tick  = b.B.Ticks;
                bool      rpow  = b.On;
                //b.Mount =
                switch (b.B.Place)
                {
                // There a better, fasterway for a vector arrow?
                case Direction.NORTH:
                    for (int i = 0; i < 8; i++)
                    {
                        Arrow[i] = northArrow[i]; Arrow[i].Offset(r.Location);
                    }

                    t = new Rectangle(r.X + 3, r.Y + 3, 2, 1);
                    t.Offset(0, tick);
                    break;

                case Direction.SOUTH:
                    for (int i = 0; i < 8; i++)
                    {
                        Arrow[i] = southArrow[i]; Arrow[i].Offset(r.Location);
                    }
                    t = new Rectangle(r.X + 3, r.Y + 4, 2, 1);
                    t.Offset(0, -tick);
                    break;

                case Direction.WEST:
                    for (int i = 0; i < 8; i++)
                    {
                        Arrow[i] = westArrow[i]; Arrow[i].Offset(r.Location);
                    }
                    t = new Rectangle(r.X + 4, r.Y + 3, 1, 2);
                    t.Offset(-tick, 0);
                    break;

                case Direction.EAST:
                    for (int i = 0; i < 8; i++)
                    {
                        Arrow[i] = eastArrow[i]; Arrow[i].Offset(r.Location);
                    }
                    t = new Rectangle(r.X + 3, r.Y + 3, 1, 2);
                    t.Offset(tick, 0);
                    break;
                }
                g.FillPolygon(BlockColors.bRepeater, Arrow);
                // If its powered we light it up, if its not powered we don't need to display a single tick
                if (rpow & tick == 0)
                {
                    g.FillRectangle(BlockColors.bWireOn, t);
                }
                else
                if (tick != 0)
                {
                    if (rpow)
                    {
                        g.FillRectangle(BlockColors.bWireOn, t);
                    }
                    else
                    {
                        g.FillRectangle(BlockColors.bWireOff, t);
                    }
                }

                g.DrawString(((int)(b.B.Delay / 2)).ToString(), new Font("Courier", 4), BlockColors.bDoor, (r.Right + r.Left) / 2, (r.Top + r.Bottom) / 2);
                break;

            case BlockType.LEVER:
                switch (b.B.Place)
                {
                case Direction.SOUTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y, 2, 5); break;

                case Direction.NORTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 2, 5); break;

                case Direction.WEST: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 5, 2); break;

                case Direction.EAST: g.FillRectangle(BlockColors.bLever, r.X, r.Y + 3, 5, 2); break;
                }
                g.FillEllipse(BlockColors.bValve, r.X + 2, r.Y + 2, 4, 4);
                if (b.On)
                {
                    g.FillEllipse(BlockColors.bWireOn, r.X + 3, r.Y + 3, 2, 2);
                }
                break;

            case BlockType.TORCH:
                switch (b.B.Place)
                {
                case Direction.SOUTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y, 2, 5); break;

                case Direction.NORTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 2, 5); break;

                case Direction.WEST: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 5, 2); break;

                case Direction.EAST: g.FillRectangle(BlockColors.bLever, r.X, r.Y + 3, 5, 2); break;
                }

                if (b.On)
                {
                    g.FillEllipse(BlockColors.bWireOn, r.X + 2, r.Y + 2, 4, 4);
                }
                else
                {
                    g.FillEllipse(BlockColors.bWireOff, r.X + 2, r.Y + 2, 4, 4);
                }

                break;

            case BlockType.BUTTON:

                if (b.On)
                {
                    switch (b.B.Place)
                    {
                    case Direction.NORTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y + 7, 4, 1); break;

                    case Direction.SOUTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y, 4, 1); break;

                    case Direction.EAST: g.FillRectangle(BlockColors.bButton, r.X + 7, r.Y + 2, 1, 4); break;

                    case Direction.WEST: g.FillRectangle(BlockColors.bButton, r.X, r.Y + 2, 1, 4); break;
                    }
                }
                else
                {
                    switch (b.B.Place)
                    {
                    case Direction.SOUTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y + 5, 4, 3); break;

                    case Direction.NORTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y, 4, 3); break;

                    case Direction.EAST: g.FillRectangle(BlockColors.bButton, r.X + 5, r.Y + 2, 3, 4); break;

                    case Direction.WEST: g.FillRectangle(BlockColors.bButton, r.X, r.Y + 2, 3, 4); break;
                    }
                }
                break;

            case BlockType.PREASUREPAD:     // '\t'
                if (b.On)
                {
                    g.FillRectangle(BlockColors.bWireOn, r.X + 1, r.Y + 1, 6, 6);
                }
                else
                {
                    g.FillRectangle(BlockColors.bValve, r.X + 1, r.Y + 1, 6, 6);
                }
                break;

                /*   case BlockType.DOORB:
                 *     break; //Check for this
                 * case BlockType.DOORA: // '\007'
                 *     if (b.Block.Powered)
                 *         switch (b.Block.Place) // THIS IS UNPOWERED, NEEDS TO BE MODIFIED.
                 *         // JUST LASY AND TESTING RIGHT NOW
                 *         {
                 *             // FYI, this is facing, so its hinge to edge not powered
                 *             case Direction.NORTH: // Hinge, bottom left, Closed
                 *                 g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 2, 8);
                 *                 g.FillRectangle(BlockColors.bWireOff, r.X, r.Y + 6, 2, 2);
                 *                 break;
                 *             case Direction.SOUTH: // Hinge upper right, Closed
                 *                 g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 2, 8);
                 *                 g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y, 2, 2);
                 *                 break;
                 *             case Direction.EAST: // Hinge, upper left
                 *                 g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 8, 2);
                 *                 g.FillRectangle(BlockColors.bWireOff, r.X, r.Y, 2, 2);
                 *                 break;
                 *             case Direction.WEST:  // bottom right
                 *                 g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 8, 2);
                 *                 g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y + 6, 2, 2);
                 *                 break;
                 *         }
                 *     else
                 *         switch (b.Block.Place)
                 *         {
                 *             // FYI, this is facing, so its hinge to edge not powered
                 *             case Direction.NORTH: // Hinge, bottom left, Closed
                 *                 g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 2, 8);
                 *                 g.FillRectangle(BlockColors.bWireOff, r.X, r.Y + 6, 2, 2);
                 *                 break;
                 *             case Direction.SOUTH: // Hinge upper right, Closed
                 *                 g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 2, 8);
                 *                 g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y, 2, 2);
                 *                 break;
                 *             case Direction.EAST: // Hinge, upper left
                 *                 g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 8, 2);
                 *                 g.FillRectangle(BlockColors.bWireOff, r.X, r.Y, 2, 2);
                 *                 break;
                 *             case Direction.WEST:  // bottom right
                 *                 g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 8, 2);
                 *                 g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y + 6, 2, 2);
                 *                 break;
                 *         }
                 *
                 *
                 *     break;*/
            }
            if (b.Fog)
            {
                g.FillRectangle(BlockColors.bFog, r);
            }
            StringFormat sf = new StringFormat();

            sf.Alignment     = StringAlignment.Near;
            sf.LineAlignment = StringAlignment.Near;
            string s = b.B.Charge.ToString();

            if (b.B.canMount)
            {
                s += '\n' + b.B.Place.ToString()[0].ToString();
            }
            if (!b.B.isAir && !b.B.isRepeater)
            {
                g.DrawString(s, new Font("Courier", 4, FontStyle.Regular, GraphicsUnit.Pixel),
                             BlockColors.bDoor, r, sf);
            }
        }
        public static void gDrawBlock(Graphics g, Rectangle r, BlockDrawSettings b)
        {
            if (b.OverShadow) g.FillRectangle(BlockColors.bGrid, r);
            else
                if (b.B.ID == BlockType.BLOCK || b.OnBlock) g.FillRectangle(BlockColors.bBlock, r);
                else
                    g.FillRectangle(BlockColors.bAir, r);

            /*
             * 0x1: Facing south
               0x2: Facing north
               0x3: Facing west
               0x4: Facing east
             */

            switch (b.B.ID)
            {
                case BlockType.WIRE:
                    gDrawWire(g, r, b);
                    break;
                case BlockType.REPEATER:
                    Point[] Arrow = new Point[8];
                    Rectangle t =r;
                    int tick = b.B.Ticks;
                    bool rpow = b.On;
                    //b.Mount =
                    switch (b.B.Place)
                    {
                        // There a better, fasterway for a vector arrow?
                        case Direction.NORTH:
                            for (int i = 0; i < 8; i++) { Arrow[i] = northArrow[i]; Arrow[i].Offset(r.Location); }

                            t = new Rectangle(r.X + 3, r.Y + 3, 2, 1);
                            t.Offset(0, tick);
                            break;
                        case Direction.SOUTH:
                            for (int i = 0; i < 8; i++) { Arrow[i] = southArrow[i]; Arrow[i].Offset(r.Location); }
                            t = new Rectangle(r.X + 3, r.Y + 4, 2, 1);
                            t.Offset(0, -tick);
                            break;
                        case Direction.WEST:
                            for (int i = 0; i < 8; i++) { Arrow[i] = westArrow[i]; Arrow[i].Offset(r.Location); }
                            t = new Rectangle(r.X + 4, r.Y + 3, 1, 2);
                            t.Offset(-tick, 0);
                            break;
                        case Direction.EAST:
                            for (int i = 0; i < 8; i++) { Arrow[i] = eastArrow[i]; Arrow[i].Offset(r.Location); }
                            t = new Rectangle(r.X + 3, r.Y + 3, 1, 2);
                            t.Offset(tick, 0);
                            break;
                    }
                    g.FillPolygon(BlockColors.bRepeater, Arrow);
                    // If its powered we light it up, if its not powered we don't need to display a single tick
                    if (rpow & tick == 0)
                        g.FillRectangle(BlockColors.bWireOn, t);
                    else
                        if (tick != 0)
                            if (rpow)
                                g.FillRectangle(BlockColors.bWireOn, t);
                            else
                                g.FillRectangle(BlockColors.bWireOff, t);

                        g.DrawString(((int)(b.B.Delay/2)).ToString(), new Font("Courier", 4), BlockColors.bDoor, (r.Right+r.Left)/2, (r.Top+r.Bottom)/2);
                    break;
                case BlockType.LEVER:
                    switch (b.B.Place)
                    {
                        case Direction.SOUTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y, 2, 5); break;
                        case Direction.NORTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 2, 5); break;
                        case Direction.WEST: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 5, 2); break;
                        case Direction.EAST: g.FillRectangle(BlockColors.bLever, r.X, r.Y + 3, 5, 2); break;
                    }
                    g.FillEllipse(BlockColors.bValve, r.X + 2, r.Y + 2, 4, 4);
                    if (b.On)
                        g.FillEllipse(BlockColors.bWireOn, r.X + 3, r.Y + 3, 2, 2);
                    break;
                case BlockType.TORCH:
                    switch (b.B.Place)
                    {
                        case Direction.SOUTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y, 2, 5); break;
                        case Direction.NORTH: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 2, 5); break;
                       case Direction.WEST: g.FillRectangle(BlockColors.bLever, r.X + 3, r.Y + 3, 5, 2); break;
                        case Direction.EAST: g.FillRectangle(BlockColors.bLever, r.X, r.Y + 3, 5, 2); break;
                    }

                    if (b.On)
                        g.FillEllipse(BlockColors.bWireOn, r.X + 2, r.Y + 2, 4, 4);
                    else
                        g.FillEllipse(BlockColors.bWireOff, r.X + 2, r.Y + 2, 4, 4);

                    break;

                case BlockType.BUTTON:

                    if (b.On)
                        switch (b.B.Place)
                        {
                            case Direction.NORTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y + 7, 4, 1); break;
                            case Direction.SOUTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y, 4, 1); break;
                            case Direction.EAST: g.FillRectangle(BlockColors.bButton, r.X + 7, r.Y + 2, 1, 4); break;
                            case Direction.WEST: g.FillRectangle(BlockColors.bButton, r.X, r.Y + 2, 1, 4); break;
                        }
                    else
                        switch (b.B.Place)
                        {
                            case Direction.SOUTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y + 5, 4, 3); break;
                            case Direction.NORTH: g.FillRectangle(BlockColors.bButton, r.X + 2, r.Y, 4, 3); break;
                            case Direction.EAST: g.FillRectangle(BlockColors.bButton, r.X + 5, r.Y + 2, 3, 4); break;
                            case Direction.WEST: g.FillRectangle(BlockColors.bButton, r.X, r.Y + 2, 3, 4); break;

                        }
                    break;

                case BlockType.PREASUREPAD: // '\t'
                    if (b.On)
                        g.FillRectangle(BlockColors.bWireOn, r.X + 1, r.Y + 1, 6, 6);
                    else
                        g.FillRectangle(BlockColors.bValve, r.X + 1, r.Y + 1, 6, 6);
                    break;
             /*   case BlockType.DOORB:
                    break; //Check for this
                case BlockType.DOORA: // '\007'
                    if (b.Block.Powered)
                        switch (b.Block.Place) // THIS IS UNPOWERED, NEEDS TO BE MODIFIED.
                        // JUST LASY AND TESTING RIGHT NOW
                        {
                            // FYI, this is facing, so its hinge to edge not powered
                            case Direction.NORTH: // Hinge, bottom left, Closed
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 2, 8);
                                g.FillRectangle(BlockColors.bWireOff, r.X, r.Y + 6, 2, 2);
                                break;
                            case Direction.SOUTH: // Hinge upper right, Closed
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 2, 8);
                                g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y, 2, 2);
                                break;
                            case Direction.EAST: // Hinge, upper left
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 8, 2);
                                g.FillRectangle(BlockColors.bWireOff, r.X, r.Y, 2, 2);
                                break;
                            case Direction.WEST:  // bottom right
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 8, 2);
                                g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y + 6, 2, 2);
                                break;
                        }
                    else
                        switch (b.Block.Place)
                        {
                            // FYI, this is facing, so its hinge to edge not powered
                            case Direction.NORTH: // Hinge, bottom left, Closed
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 2, 8);
                                g.FillRectangle(BlockColors.bWireOff, r.X, r.Y + 6, 2, 2);
                                break;
                            case Direction.SOUTH: // Hinge upper right, Closed
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 2, 8);
                                g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y, 2, 2);
                                break;
                            case Direction.EAST: // Hinge, upper left
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y, 8, 2);
                                g.FillRectangle(BlockColors.bWireOff, r.X, r.Y, 2, 2);
                                break;
                            case Direction.WEST:  // bottom right
                                g.FillRectangle(BlockColors.bDoor, r.X, r.Y + 6, 8, 2);
                                g.FillRectangle(BlockColors.bWireOff, r.X + 6, r.Y + 6, 2, 2);
                                break;
                        }

                    break;*/

            }
            if (b.Fog) g.FillRectangle(BlockColors.bFog, r);
            StringFormat sf = new StringFormat();
            sf.Alignment=StringAlignment.Near;
            sf.LineAlignment=StringAlignment.Near;
            string s = b.B.Charge.ToString();
            if (b.B.canMount)
                s += '\n' + b.B.Place.ToString()[0].ToString();
            if(!b.B.isAir && !b.B.isRepeater)
                g.DrawString(s, new Font("Courier",4,FontStyle.Regular,GraphicsUnit.Pixel),
                    BlockColors.bDoor,r,sf);
        }