Example #1
0
        private int stageNumFile;                            //ステージのファイル番号

        /// <summary>
        /// シーンの間にゲーム情報を伝える仲介者
        /// </summary>
        /// <param name="gameDevice">ゲームディバイス</param>
        public GameManager(GameDevice gameDevice)
        {
            this.gameDevice = gameDevice;
            mapInstance     = null;

            stageManager        = new StageManager(gameDevice);
            enemySettingManager = new EnemySettingManager(gameDevice);
            blockStyle          = new BlockStyle();
            questManager        = new QuestLoader();
            questManager.Initialize();
            questManager.Load(dungeonProcess, true);
            itemManager    = new ItemManager();
            dungeonProcess = new DungeonProcess();
            enemyName      = new EnemyNameLoader();

            #region Player初期化
            PlayerStatusLoader psLoader = new PlayerStatusLoader();
            int[]  status        = psLoader.LoadStatus();
            Status defaultStatus = new Status(1, status[0], status[1], status[2], status[3], 1);
            playerStatus = new PlayerStatus(defaultStatus, gameDevice);
            playerStatus.Initialize();

            playerItem      = playerStatus.GetInventory();                //道具欄を取得
            playerQuest     = new PlayerQuest();
            playerGuildRank = new PlayerGuildRank();
            #endregion

            Load();
        }
    // This returns null if the texture is not yet loaded
    public Texture2D GetCustomStyleTexture(BlockStyle style)
    {
        Texture2D rv = null;

        customStyleTextures.TryGetValue(style, out rv);
        return(rv);
    }
    private GameObject GetPrefabForWallStyle(BlockStyle style)
    {
        switch (style)
        {
        case BlockStyle.Stone:
            return(stoneStylePrefabs.wallPrefab);

        case BlockStyle.Grass:
            return(grassStylePrefabs.wallPrefab);

        case BlockStyle.Space:
            return(metalStylePrefabs.wallPrefab);

        case BlockStyle.SnowRock:
            return(snowRockStylePrefabs.wallPrefab);

        default:
            int colorId = (int)style;
            if (colorId < 0 || colorId > (int)LastSolidColorStyle)
            {
                Util.LogError($"Bad style given: {style}. Snapping to color 0.");
                colorId = 0;
            }
            return(perColorPrefabs[colorId].wallPrefab);
        }
    }
    public SideValue GetSideValue(Side side)
    {
        bool       on    = database.IsSideSet(side);
        BlockStyle style = on ? database.GetSideStyle(side) : BlockStyle.SolidColor0;

        return(new SideValue {
            on = on, style = style
        });
    }
Example #5
0
 public XParagraph(Func<bool> writeIf, BlockStyle blockStyle = BlockStyle.Normal, params XInline[] children)
     : base(writeIf, blockStyle)
 {
     // Unwrap a single span being passed into a paragraph
     if (children.Length == 1 && children[0] is XSpan)
         this.children = new List<XInline>(((XSpan) children[0]).Children);
     else
         this.children = children.ToList();
 }
Example #6
0
    void RefreshTextureToggles()
    {
        BlockStyle currentBlockStyle = GetBlockStyle();

        ClearTextureToggles();
        UpdateBlockTextureIcons();
        LoadTextureToggles(icons);
        SetBlockStyle(currentBlockStyle);
    }
    void SpawnEdgeAt(Side edge, BlockStyle style)
    {
        GameObject newWall = Instantiate(
            GetPrefabForWallStyle(style),
            GetWallOrigin(edge, style),
            (edge.side == CellSide.West) ? Quaternion.Euler(0, 90, 0) : Quaternion.identity,
            gridParent);

        newWall.SetActive(true);
        edgeInstances.Add(edge, newWall);
    }
Example #8
0
 public XParagraph(Func <bool> writeIf, BlockStyle blockStyle = BlockStyle.Normal, params XInline[] children)
     : base(writeIf, blockStyle)
 {
     // Unwrap a single span being passed into a paragraph
     if (children.Length == 1 && children[0] is XSpan)
     {
         this.children = new List <XInline>(((XSpan)children[0]).Children);
     }
     else
     {
         this.children = children.ToList();
     }
 }
Example #9
0
        private void TreeViewItem_UnSelected(object sender, RoutedEventArgs e)
        {
            if (imgLibrary.Visibility == Visibility.Visible)
            {
                //Bd.BorderBrush = Brushes.Transparent;
                label.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
            }

            if (ItemCategory == TvItemCategory.BLOCK_STYLES)
            {
                BlockStyle bs = Resources["BlockStyleRef"] as BlockStyle;
                bs.ShowControlBorder(false);
            }
        }
Example #10
0
        /// <summary>
        /// Sets the layout using the given block style.
        /// </summary>
        /// <param name="layout">The layout.</param>
        /// <param name="style">The style.</param>
        /// <param name="width">The width.</param>
        public void SetLayout(
            Layout layout,
            BlockStyle style,
            int width)
        {
            // Set the style elements.
            layout.Wrap            = style.GetWrap();
            layout.Alignment       = style.GetAlignment();
            layout.FontDescription = style.GetFontDescription();

            // Check to see if we are doing line wrapping and set the width,
            // minus the padding, margins, and borders.
            layout.Width = Units.FromPixels((int)Math.Ceiling(width - style.Width));
        }
Example #11
0
    private void SetBlockStyle(BlockStyle currentBlockStyle)
    {
        int index = (int)currentBlockStyle;

        // Find the icon corresponding to this..
        for (int i = 0; i < icons.Length; i++)
        {
            if (icons[i].style == currentBlockStyle)
            {
                textureToggles[i].isOn = true;
                break;
            }
        }
    }
Example #12
0
    void UpdateCellsStyle(IEnumerable <Util.Tuple <Cell, CellValue> > cells, BlockStyle blockStyle)
    {
        HashSet <Util.Tuple <Cell, CellValue> > updatedCells = new HashSet <Util.Tuple <Cell, CellValue> >();

        foreach (Util.Tuple <Cell, CellValue> cv in cells)
        {
            CellValue value = terrain.GetCellValue(cv.first);
            value.style = blockStyle;
            terrain.SetCellValue(cv.first, value);
            updatedCells.Add(new Util.Tuple <Cell, CellValue>(cv.first, value));
        }

        operationCandidates = updatedCells;
    }
Example #13
0
    internal void PaintOperationCandidates()
    {
        HashSet <Util.Tuple <Cell, CellValue> > copyOfCandidates = new HashSet <Util.Tuple <Cell, CellValue> >(operationCandidates);
        BlockStyle blockStyle = terrainToolSettings.GetBlockStyle();

        undoStack.Push(new UndoStack.Item
        {
            actionLabel           = $"Painting blocks",
            getUnableToDoReason   = () => null,
            getUnableToUndoReason = () => null,
            doIt = () => UpdateCellsStyle(copyOfCandidates, blockStyle),
            undo = () => CreateCells(copyOfCandidates),
        });
    }
    public void OnSetSide(Side edge, bool on, BlockStyle style)
    {
        GameObject existing = null;

        if (edgeInstances.TryGetValue(edge, out existing))
        {
            Destroy(existing);
            edgeInstances.Remove(edge);
        }

        if (on)
        {
            SpawnEdgeAt(edge, style);
        }
    }
Example #15
0
 public void changedID(string newName)
 {
     if (ItemCategory == TvItemCategory.PARAGRAPH_STYLES)
     {
         ParagraphStyle ps = this.Resources["ParagraphStyleRef"] as ParagraphStyle;
         ps.Id = newName;
     }
     else if (ItemCategory == TvItemCategory.TEXT_STYLES)
     {
         TextStyle ts = this.Resources["TextStyleRef"] as TextStyle;
         ts.Id = newName;
     }
     else if (ItemCategory == TvItemCategory.FONTS)
     {
         FontStyle fs = this.Resources["FontStyleRef"] as FontStyle;
         fs.Id = newName;
     }
     else if (ItemCategory == TvItemCategory.IMAGES)
     {
         ImageStyle iss = this.Resources["ImageStyleRef"] as ImageStyle;
         iss.Id = newName;
     }
     else if (ItemCategory == TvItemCategory.TABLES)
     {
         TableStyle ts = this.Resources["TableStyleRef"] as TableStyle;
         ts.Id = newName;
     }
     else if (ItemCategory == TvItemCategory.LINE_STYLES)
     {
         LineStyle ls = this.Resources["LineStyleRef"] as LineStyle;
         ls.Id = newName;
     }
     else if (ItemCategory == TvItemCategory.BORDER_STYLES)
     {
         BorderStyle bs = this.Resources["BorderStyleRef"] as BorderStyle;
         bs.Id = newName;
     }
     else if (ItemCategory == TvItemCategory.COLORS)
     {
         ColorStyle cs = this.Resources["ColorStyleRef"] as ColorStyle;
         cs.Id = newName;
     }
     else if (ItemCategory == TvItemCategory.BLOCK_STYLES)
     {
         BlockStyle cs = this.Resources["BlockStyleRef"] as BlockStyle;
         cs.Id = newName;
     }
 }
    public void SetSide(Side side, bool on, BlockStyle style)
    {
        var map  = side.side == CellSide.South ? southSideMap : westSideMap;
        var cell = side.GetCell();

        if (on)
        {
            SideInfo info = new SideInfo();
            info.SetStyle(style);
            map[cell] = info;
        }
        else
        {
            map.Remove(cell);
        }
    }
Example #17
0
        private void TreeViewItem_Selected(object sender, RoutedEventArgs e)
        {
            label.Foreground = Brushes.IndianRed;
            if (txtbox.Visibility == Visibility.Visible)
            {
                Keyboard.Focus(txtbox);
            }

            if (DesignerPage.self.chkBlockArrow.IsChecked == true)
            {
                if (ItemCategory == TvItemCategory.BLOCK_STYLES)
                {
                    BlockStyle bs = Resources["BlockStyleRef"] as BlockStyle;
                    bs.ShowControlBorder(true);
                }
            }
        }
Example #18
0
    void SetCellLocally(CellValue val, Cell cell)
    {
        if (terrainV2 == null)
        {
            return;
        }

        BlockStyle style = val.style;

        if (OVERRIDE_STYLE >= 0)
        {
            Util.LogWarning($"Overriding block style to {OVERRIDE_STYLE}");
            style = (BlockStyle)OVERRIDE_STYLE;
        }

        terrainV2.SetCell(cell.ToInt3() + GetV2Offset(), (int)style, (int)val.blockType - 1 /* offset because we use 0 == empty */, (int)val.direction);
    }
Example #19
0
    private void EndPaint()
    {
        operating = false;

        HashSet <Util.Tuple <Cell, CellValue> > copyOfCandidates = new HashSet <Util.Tuple <Cell, CellValue> >(operationCandidates);
        BlockStyle blockStyle = terrainToolSettings.GetBlockStyle();

        undoStack.Push(new UndoStack.Item
        {
            actionLabel           = $"Creating blocks",
            getUnableToDoReason   = () => null,
            getUnableToUndoReason = () => null,
            doIt = () => UpdateCellsStyle(copyOfCandidates, blockStyle),
            undo = () => CreateCells(copyOfCandidates),
        }, false);

        operationCandidates.Clear();
    }
Example #20
0
    protected override void Process()
    {
        if (random.Next(0, 2) == 0)
        {
            this.style = this.style.Flip();
        }
        this.style = this.style.Rotate(random.Next(0, 4));

        int[] place = FindSpace(style.width, style.height, 5);
        if (place == null)
        {
            Debug.Log("NO SPACE");
            return;
        }

        for (int x = 0; x < style.width; x++)
        {
            for (int y = 0; y < style.height; y++)
            {
                var block   = map.blocks[place[0] + x, place[1] + y];
                int tileObj = style.tileObjMap[x, y];
                if (tileObj >= BlockStyle.OBJ_THRESHOLD)
                {
                    tileObj -= BlockStyle.OBJ_THRESHOLD;
                    if (tileObj != MapGenerator.OBJ_NOTHING)
                    {
                        block.tileNumber = MapGenerator.TILE_GLASS;
                        block.objNumber  = tileObj;
                        block.objPlaced  = true;
                    }
                }
                else if (tileObj != MapGenerator.TILE_NOTHING)
                {
                    block.tileNumber = tileObj;
                }
                block.tilePlaced = style.blockMap[x, y] == 1;
                map.blocks[place[0] + x, place[1] + y] = block;
                if (style.itemMap[x, y] != 0)
                {
                    map.itemPositions.Add(new Vector2(place[0] + x, place[1] + y));
                }
            }
        }
    }
Example #21
0
    //1,2,3
    //4,5,6
    //7,8,9
    //->
    //7,4,1
    //8,5,2
    //9,6,3
    public BlockStyle RotateOnce()
    {
        BlockStyle s = new BlockStyle();

        s.width      = height;
        s.height     = width;
        s.tileObjMap = new int[height, width];
        s.itemMap    = new int[height, width];
        s.blockMap   = new int[height, width];
        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                s.tileObjMap[height - y - 1, x] = tileObjMap[x, y];
                s.itemMap[height - y - 1, x]    = itemMap[x, y];
                s.blockMap[height - y - 1, x]   = blockMap[x, y];
            }
        }
        return(s);
    }
Example #22
0
    //1,2,3
    //4,5,6
    //7,8,9
    //->
    //9,8,7
    //6,5,4
    //3,2,1
    public BlockStyle Rotate180()
    {
        BlockStyle s = new BlockStyle();

        s.height     = height;
        s.width      = width;
        s.tileObjMap = new int[width, height];
        s.itemMap    = new int[width, height];
        s.blockMap   = new int[width, height];
        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                s.tileObjMap[width - x - 1, height - y - 1] = tileObjMap[x, y];
                s.itemMap[width - x - 1, height - y - 1]    = itemMap[x, y];
                s.blockMap[width - x - 1, height - y - 1]   = blockMap[x, y];
            }
        }
        return(s);
    }
    void SpawnCellBlock(BlockShape blockType, Cell cell, BlockDirection direction, BlockStyle style)
    {
        GameObject newBlock = Instantiate(
            GetPrefabForBlockType(blockType, style),
            TerrainManager.GetCellCenter(cell),
            GetBlockDirectionAsQuaternion(direction),
            gridParent);

        var tag = newBlock.AddComponent <BlockTag>();

        tag.style = style;

        // Hide here instead of for the prefab...the prefab is still used for
        // preview - blah!
        foreach (var r in newBlock.GetComponentsInChildren <MeshRenderer>())
        {
            MonoBehaviour.Destroy(r);
        }

        newBlock.SetActive(true);
        cellInstances.Add(cell, newBlock);
    }
        /// <summary>
        /// Draws a layout with a given style to the render context.
        /// </summary>
        /// <param name="displayContext">The display context.</param>
        /// <param name="renderContext">The render context.</param>
        /// <param name="region">The region for the various elements.</param>
        /// <param name="layout">The layout to use for text.</param>
        /// <param name="style">The style used for borders and padding.</param>
        public static void DrawLayout(
            IDisplayContext displayContext,
            IRenderContext renderContext,
            Rectangle region,
            Layout layout,
            BlockStyle style)
        {
            // Get the style for the line number.
            Spacing margins = style.GetMargins();
            Spacing padding = style.GetPadding();
            Borders borders = style.GetBorders();

            double marginLeftX  = margins.Left + borders.Left.LineWidth;
            double paddingLeftX = marginLeftX + padding.Left;

            // Draw the layout borders and background.
            DrawLayout(displayContext, renderContext, region, style);

            // Figure out the extents of the layout.
            int layoutWidth,
                layoutHeight;

            layout.GetPixelSize(out layoutWidth, out layoutHeight);

            // Add the padding to the x coordinate since the only thing left is
            // to render the text.
            double textX = region.X + paddingLeftX;

            // Shift down based on the top-spacing.
            double textY = region.Y + style.Top;

            // Render out the line number. Since this is right-aligned, we need
            // to get the text and start it to the right.
            displayContext.GdkWindow.DrawLayout(
                displayContext.GtkStyle.TextGC(StateType.Normal),
                (int)textX,
                (int)textY,
                layout);
        }
    Vector3 GetWallOrigin(Side edge, BlockStyle style)
    {
        bool isWest = edge.side == CellSide.West;

        Vector3 offsetBlocks;

        if (style == BlockStyle.Stone)
        {
            offsetBlocks = isWest ?
                           new Vector3(-0.5f, -0.5f, -0.5f)
       : new Vector3(0.5f, -0.5f, -0.5f);
        }
        else
        {
            offsetBlocks = isWest ?
                           new Vector3(-0.5f, -0.5f, 0.5f)
      : new Vector3(-0.5f, -0.5f, -0.5f);
        }

        var cellCenter = GetCellCenter(new Cell(edge.x, edge.y, edge.z));

        return(cellCenter + Vector3.Scale(BLOCK_SIZE, offsetBlocks));
    }
Example #26
0
 public BlockStyler(BlockStyle style)
 {
     this.style = style;
 }
Example #27
0
        public static void SelfFrame8Way(int i, int j, Tile centerTile, bool resetFrame)
        {
            if (!centerTile.active())
            {
                return;
            }
            BlockStyle blockStyle  = FindBlockStyle(centerTile);
            int        num         = 0;
            BlockStyle blockStyle2 = default(BlockStyle);

            if (blockStyle.top)
            {
                Tile tileSafely = GetTileSafely(i, j - 1);
                if (tileSafely.active() && WillItBlend(centerTile.type, tileSafely.type))
                {
                    blockStyle2 = FindBlockStyle(tileSafely);
                    if (blockStyle2.bottom)
                    {
                        num |= 1;
                    }
                    else
                    {
                        blockStyle2.Clear();
                    }
                }
            }
            BlockStyle blockStyle3 = default(BlockStyle);

            if (blockStyle.left)
            {
                Tile tileSafely2 = GetTileSafely(i - 1, j);
                if (tileSafely2.active() && WillItBlend(centerTile.type, tileSafely2.type))
                {
                    blockStyle3 = FindBlockStyle(tileSafely2);
                    if (blockStyle3.right)
                    {
                        num |= 2;
                    }
                    else
                    {
                        blockStyle3.Clear();
                    }
                }
            }
            BlockStyle blockStyle4 = default(BlockStyle);

            if (blockStyle.right)
            {
                Tile tileSafely3 = GetTileSafely(i + 1, j);
                if (tileSafely3.active() && WillItBlend(centerTile.type, tileSafely3.type))
                {
                    blockStyle4 = FindBlockStyle(tileSafely3);
                    if (blockStyle4.left)
                    {
                        num |= 4;
                    }
                    else
                    {
                        blockStyle4.Clear();
                    }
                }
            }
            BlockStyle blockStyle5 = default(BlockStyle);

            if (blockStyle.bottom)
            {
                Tile tileSafely4 = GetTileSafely(i, j + 1);
                if (tileSafely4.active() && WillItBlend(centerTile.type, tileSafely4.type))
                {
                    blockStyle5 = FindBlockStyle(tileSafely4);
                    if (blockStyle5.top)
                    {
                        num |= 8;
                    }
                    else
                    {
                        blockStyle5.Clear();
                    }
                }
            }
            if (blockStyle2.left && blockStyle3.top)
            {
                Tile tileSafely5 = GetTileSafely(i - 1, j - 1);
                if (tileSafely5.active() && WillItBlend(centerTile.type, tileSafely5.type))
                {
                    BlockStyle blockStyle6 = FindBlockStyle(tileSafely5);
                    if (blockStyle6.right && blockStyle6.bottom)
                    {
                        num |= 0x10;
                    }
                }
            }
            if (blockStyle2.right && blockStyle4.top)
            {
                Tile tileSafely6 = GetTileSafely(i + 1, j - 1);
                if (tileSafely6.active() && WillItBlend(centerTile.type, tileSafely6.type))
                {
                    BlockStyle blockStyle7 = FindBlockStyle(tileSafely6);
                    if (blockStyle7.left && blockStyle7.bottom)
                    {
                        num |= 0x20;
                    }
                }
            }
            if (blockStyle5.left && blockStyle3.bottom)
            {
                Tile tileSafely7 = GetTileSafely(i - 1, j + 1);
                if (tileSafely7.active() && WillItBlend(centerTile.type, tileSafely7.type))
                {
                    BlockStyle blockStyle8 = FindBlockStyle(tileSafely7);
                    if (blockStyle8.right && blockStyle8.top)
                    {
                        num |= 0x40;
                    }
                }
            }
            if (blockStyle5.right && blockStyle4.bottom)
            {
                Tile tileSafely8 = GetTileSafely(i + 1, j + 1);
                if (tileSafely8.active() && WillItBlend(centerTile.type, tileSafely8.type))
                {
                    BlockStyle blockStyle9 = FindBlockStyle(tileSafely8);
                    if (blockStyle9.left && blockStyle9.top)
                    {
                        num |= 0x80;
                    }
                }
            }
            if (resetFrame)
            {
                centerTile.frameNumber((byte)WorldGen.genRand.Next(0, 3));
            }
            Point16 point = selfFrame8WayLookup[num][centerTile.frameNumber()];

            centerTile.frameX = point.X;
            centerTile.frameY = point.Y;
        }
Example #28
0
 public static void Initialize()
 {
     selfFrame8WayLookup = new Point16[256][];
     frameSize8Way       = new Point16(18, 18);
     Add8WayLookup(0, 9, 3, 10, 3, 11, 3);
     Add8WayLookup(1, 6, 3, 7, 3, 8, 3);
     Add8WayLookup(2, 12, 0, 12, 1, 12, 2);
     Add8WayLookup(3, 15, 2);
     Add8WayLookup(4, 9, 0, 9, 1, 9, 2);
     Add8WayLookup(5, 13, 2);
     Add8WayLookup(6, 6, 4, 7, 4, 8, 4);
     Add8WayLookup(7, 14, 2);
     Add8WayLookup(8, 6, 0, 7, 0, 8, 0);
     Add8WayLookup(9, 5, 0, 5, 1, 5, 2);
     Add8WayLookup(10, 15, 0);
     Add8WayLookup(11, 15, 1);
     Add8WayLookup(12, 13, 0);
     Add8WayLookup(13, 13, 1);
     Add8WayLookup(14, 14, 0);
     Add8WayLookup(15, 14, 1);
     Add8WayLookup(19, 1, 4, 3, 4, 5, 4);
     Add8WayLookup(23, 16, 3);
     Add8WayLookup(27, 17, 0);
     Add8WayLookup(31, 13, 4);
     Add8WayLookup(37, 0, 4, 2, 4, 4, 4);
     Add8WayLookup(39, 17, 3);
     Add8WayLookup(45, 16, 0);
     Add8WayLookup(47, 12, 4);
     Add8WayLookup(55, 1, 2, 2, 2, 3, 2);
     Add8WayLookup(63, 6, 2, 7, 2, 8, 2);
     Add8WayLookup(74, 1, 3, 3, 3, 5, 3);
     Add8WayLookup(75, 17, 1);
     Add8WayLookup(78, 16, 2);
     Add8WayLookup(79, 13, 3);
     Add8WayLookup(91, 4, 0, 4, 1, 4, 2);
     Add8WayLookup(95, 11, 0, 11, 1, 11, 2);
     Add8WayLookup(111, 17, 4);
     Add8WayLookup(127, 14, 3);
     Add8WayLookup(140, 0, 3, 2, 3, 4, 3);
     Add8WayLookup(141, 16, 1);
     Add8WayLookup(142, 17, 2);
     Add8WayLookup(143, 12, 3);
     Add8WayLookup(159, 16, 4);
     Add8WayLookup(173, 0, 0, 0, 1, 0, 2);
     Add8WayLookup(175, 10, 0, 10, 1, 10, 2);
     Add8WayLookup(191, 15, 3);
     Add8WayLookup(206, 1, 0, 2, 0, 3, 0);
     Add8WayLookup(207, 6, 1, 7, 1, 8, 1);
     Add8WayLookup(223, 14, 4);
     Add8WayLookup(239, 15, 4);
     Add8WayLookup(255, 1, 1, 2, 1, 3, 1);
     blockStyleLookup             = new BlockStyle[6];
     blockStyleLookup[0]          = new BlockStyle(up: true, down: true, left: true, right: true);
     blockStyleLookup[1]          = new BlockStyle(up: false, down: true, left: true, right: true);
     blockStyleLookup[2]          = new BlockStyle(up: false, down: true, left: true, right: false);
     blockStyleLookup[3]          = new BlockStyle(up: false, down: true, left: false, right: true);
     blockStyleLookup[4]          = new BlockStyle(up: true, down: false, left: true, right: false);
     blockStyleLookup[5]          = new BlockStyle(up: true, down: false, left: false, right: true);
     phlebasTileFrameNumberLookup = new int[4][]
     {
         new int[3]
         {
             2,
             4,
             2
         },
         new int[3]
         {
             1,
             3,
             1
         },
         new int[3]
         {
             2,
             2,
             4
         },
         new int[3]
         {
             1,
             1,
             3
         }
     };
     lazureTileFrameNumberLookup = new int[2][]
     {
         new int[2]
         {
             1,
             3
         },
         new int[2]
         {
             2,
             4
         }
     };
     centerWallFrameLookup = new int[3][]
     {
         new int[3]
         {
             2,
             0,
             0
         },
         new int[3]
         {
             0,
             1,
             4
         },
         new int[3]
         {
             0,
             3,
             0
         }
     };
     wallFrameLookup = new Point16[20][];
     wallFrameSize   = new Point16(36, 36);
     AddWallFrameLookup(0, 9, 3, 10, 3, 11, 3, 6, 6);
     AddWallFrameLookup(1, 6, 3, 7, 3, 8, 3, 4, 6);
     AddWallFrameLookup(2, 12, 0, 12, 1, 12, 2, 12, 5);
     AddWallFrameLookup(3, 1, 4, 3, 4, 5, 4, 3, 6);
     AddWallFrameLookup(4, 9, 0, 9, 1, 9, 2, 9, 5);
     AddWallFrameLookup(5, 0, 4, 2, 4, 4, 4, 2, 6);
     AddWallFrameLookup(6, 6, 4, 7, 4, 8, 4, 5, 6);
     AddWallFrameLookup(7, 1, 2, 2, 2, 3, 2, 3, 5);
     AddWallFrameLookup(8, 6, 0, 7, 0, 8, 0, 6, 5);
     AddWallFrameLookup(9, 5, 0, 5, 1, 5, 2, 5, 5);
     AddWallFrameLookup(10, 1, 3, 3, 3, 5, 3, 1, 6);
     AddWallFrameLookup(11, 4, 0, 4, 1, 4, 2, 4, 5);
     AddWallFrameLookup(12, 0, 3, 2, 3, 4, 3, 0, 6);
     AddWallFrameLookup(13, 0, 0, 0, 1, 0, 2, 0, 5);
     AddWallFrameLookup(14, 1, 0, 2, 0, 3, 0, 1, 5);
     AddWallFrameLookup(15, 1, 1, 2, 1, 3, 1, 2, 5);
     AddWallFrameLookup(16, 6, 1, 7, 1, 8, 1, 7, 5);
     AddWallFrameLookup(17, 6, 2, 7, 2, 8, 2, 8, 5);
     AddWallFrameLookup(18, 10, 0, 10, 1, 10, 2, 10, 5);
     AddWallFrameLookup(19, 11, 0, 11, 1, 11, 2, 11, 5);
 }
Example #29
0
 public XSection(BlockStyle blockStyle, params XTextElement[] children)
     : base(blockStyle)
 {
     this.children = children.ToList();
 }
Example #30
0
 public XSection(Func<bool> writeIf, BlockStyle blockStyle, params XTextElement[] children)
     : base(writeIf, blockStyle)
 {
     this.children = children.ToList();
 }
 public void SetStyle(BlockStyle style)
 {
     Debug.Assert((int)style < 64);
     this.b1 = (byte)style;
 }
Example #32
0
 protected XBlock(BlockStyle blockStyle = BlockStyle.Normal)
     : base(null)
 {
     BlockStyle = blockStyle;
 }
Example #33
0
 protected XBlock(Func<bool> writeIf, BlockStyle blockStyle = BlockStyle.Normal)
     : base(writeIf)
 {
     BlockStyle = blockStyle;
 }
Example #34
0
 public XSubHeading(Func<bool> writeIf, string text, BlockStyle blockStyle = BlockStyle.Normal)
     : base(writeIf, blockStyle)
 {
     Text = text;
 }
Example #35
0
 public XParagraph(BlockStyle blockStyle = BlockStyle.Normal, params XInline[] children)
     : this(() => true, blockStyle, children)
 {
 }
        /// <summary>
        /// Draws a layout with a given style to the render context.
        /// </summary>
        /// <param name="displayContext">The display context.</param>
        /// <param name="renderContext">The render context.</param>
        /// <param name="region">The region for the various elements.</param>
        /// <param name="style">The style used for borders and padding.</param>
        public static void DrawLayout(
            IDisplayContext displayContext,
            IRenderContext renderContext,
            Rectangle region,
            BlockStyle style)
        {
            // If we don't have a style, then don't do anything.
            if (style == null)
            {
                return;
            }

            // Get the style for the line number.
            Spacing margins = style.GetMargins();
            Borders borders = style.GetBorders();

            double marginLeftX  = margins.Left + borders.Left.LineWidth;
            double marginRightX = margins.Right + borders.Right.LineWidth;

            // Get the context and save settings because we use anti-aliasing
            // to get a sharper line.
            Context   cairoContext = renderContext.CairoContext;
            Antialias oldAntialias = cairoContext.Antialias;

            try
            {
                // Draw the background color.
                Color?backgroundColor = style.GetBackgroundColor();

                if (backgroundColor.HasValue)
                {
                    var cairoArea = new Rectangle(
                        region.X + marginLeftX,
                        region.Y,
                        region.Width - marginLeftX - marginRightX,
                        region.Height);

                    cairoContext.Color = backgroundColor.Value;
                    cairoContext.Rectangle(cairoArea);
                    cairoContext.Fill();
                }

                // Figure out the width for rendering the horizontal borders so
                // they line up a little bit nicer. We adjust for half the border
                // width because Cairo draws in the middle and we have to shift by
                // half that to get the side to line up with the end of the
                // horizontal.
                double topMarginY    = region.Y + margins.Top;
                double bottomMarginY = region.Y + region.Height - margins.Bottom;

                double leftMarginX  = region.X + margins.Left + (borders.Left.LineWidth / 2);
                double rightMarginX = leftMarginX + region.Width - margins.Width;

                // Draw the border lines.
                cairoContext.Antialias = Antialias.None;

                if (borders.Top.LineWidth > 0)
                {
                    // Set up the line width and colors.
                    cairoContext.LineWidth = borders.Top.LineWidth;
                    cairoContext.Color     = borders.Top.Color;

                    cairoContext.MoveTo(leftMarginX, topMarginY);
                    cairoContext.LineTo(rightMarginX, topMarginY);
                    cairoContext.Stroke();
                }

                if (borders.Bottom.LineWidth > 0)
                {
                    cairoContext.LineWidth = borders.Bottom.LineWidth;
                    cairoContext.Color     = borders.Bottom.Color;

                    cairoContext.MoveTo(leftMarginX, bottomMarginY);
                    cairoContext.LineTo(rightMarginX, bottomMarginY);
                    cairoContext.Stroke();
                }

                if (borders.Left.LineWidth > 0)
                {
                    cairoContext.LineWidth = borders.Left.LineWidth;
                    cairoContext.Color     = borders.Left.Color;

                    cairoContext.MoveTo(region.X + marginLeftX, topMarginY);
                    cairoContext.LineTo(region.X + marginLeftX, bottomMarginY);
                    cairoContext.Stroke();
                }

                if (borders.Right.LineWidth > 0)
                {
                    cairoContext.LineWidth = borders.Right.LineWidth;
                    cairoContext.Color     = borders.Right.Color;

                    cairoContext.MoveTo(region.X + region.Width - margins.Right, topMarginY);
                    cairoContext.LineTo(region.X + region.Width - margins.Right, bottomMarginY);
                    cairoContext.Stroke();
                }
            }
            finally
            {
                // Restore the context.
                cairoContext.Antialias = oldAntialias;
            }
        }
Example #37
0
 public XParagraph(BlockStyle blockStyle = BlockStyle.Normal, params XInline[] children)
     : this(() => true, blockStyle, children)
 {
 }