コード例 #1
0
        public void drawTiles()
        {
            if (mode != Mode.paste)
            {
                return;
            }

            GraphicsComponent gc       = editor.engine.graphicsComponent;
            RectangleF        viewRect = gc.camera.viewRect;

            Mapfile.TileData ignoreTile = new Mapfile.TileData("");
            ignoreTile.setToIgnore();

            for (int x = 0; x <= (int)selection.width; x++)
            {
                for (int y = 0; y <= (int)selection.height; y++)
                {
                    if (ignoreTile.Equals(copiedTileData[x, y]))
                    {
                        continue;                                         //Not commutative
                    }
                    Tile t = new Tile(editor.engine.world, (int)selection.left + x, (int)selection.top + y, copiedTiles[x, y].tileData);

                    Vector2 pos      = gc.camera.world2Screen(new Vector2(t.x, t.y));
                    Vector2 specPos  = gc.camera.world2Screen(new Vector2(t.x + Tile.size / 2, t.y + Tile.size / 2));
                    int     flagSize = (int)(editor.editorGui.solid.getResource <Texture2D>().width *gc.camera.scale);

                    //texture
                    if (t.texture.key == "")
                    {
                        gc.drawText("nul", (int)pos.x, (int)pos.y, editor.editorGui.font, Color.WHITE, (int)(12 * gc.camera.scale));
                    }
                    else
                    {
                        gc.drawTex(editor.engine.resourceComponent.get(copiedTileData[x, y].texture), (int)pos.x, (int)pos.y, (int)(t.imageWidth * gc.camera.scale), (int)(t.imageHeight * gc.camera.scale), new Color(1, 1, 1, .4f));
                    }

                    //Nonstandard overlay
                    if (t.tileData.isNonstandard())
                    {
                        editor.editorGui.graphics.drawRect((int)(pos.x + (2 * gc.camera.scale)), (int)(pos.y + (2 * gc.camera.scale)), (int)((Tile.size - 4) * gc.camera.scale), (int)((Tile.size - 4) * gc.camera.scale), new Color(1, 0, 1, .3f));
                    }

                    //solidity
                    if (t.solidity)
                    {
                        gc.drawTex(editor.editorGui.solid, (int)pos.x, (int)pos.y, flagSize, flagSize, new Color(1, 1, 1, .8f));
                    }
                    else
                    {
                        gc.drawTex(editor.editorGui.solidX, (int)pos.x, (int)pos.y, flagSize, flagSize, new Color(1, 1, 1, .8f));
                    }

                    //opacity
                    if (t.opacityFlip)
                    {
                        gc.drawTex(editor.editorGui.opaque, (int)(specPos.x), (int)(specPos.y), flagSize, flagSize, new Color(1, 1, 1, .8f));
                    }
                    else
                    {
                        gc.drawTex(editor.editorGui.opacityX, (int)(specPos.x), (int)(specPos.y), flagSize, flagSize, new Color(1, 1, 1, .8f));
                    }
                }
            }
        }