public BlockPage Process(BlockPage page2) { var page = page2 as BlockPage2; if (page == null) { PdfReaderException.AlwaysThrow("ResizeSequentialLayout must execute AFTER OrganizePageLayout"); } var result = new BlockPage2(); foreach (var segment in page.Segments) { BlockPageSegment newsegment = new BlockPageSegment(result, segment.NumberOfColumns); foreach (var column in segment.Columns) { BlockColumn newcolumn = new BlockColumn(result, column.ColumnType, column.X1, column.W); float minX = column.Min(b => b.GetX()); float maxX = column.Max(b => b.GetX() + b.GetWidth()); foreach (var block in column) { var bset = block as IBlockSet <IBlock>; if (block is TableSet || block is ImageBlock) { newcolumn.Add(block); continue; } if (bset == null) { PdfReaderException.AlwaysThrow("not expected"); } var resizeBset = ResizeBlockSet(bset, minX, maxX); newcolumn.Add(resizeBset); } newsegment.AddColumn(newcolumn); } result.AddSegment(newsegment); } return(result); }
private void arrangeColumns() { // cleanup this.Columns = new ArrayList(); foreach (CalendarDayEventView e in events) { e.Column = null; } // there always will be at least one column because arrangeColumns is called only from Add() createColumn(); foreach (CalendarDayEventView e in events) { foreach (BlockColumn col in Columns) { if (col.CanAdd(e)) { col.Add(e); break; } } // it wasn't placed if (e.Column == null) { BlockColumn col = createColumn(); col.Add(e); } } }
void Update() { while (0 < _blockColumn.Blocks.Count && _blockColumn.Blocks.Count < WallHeight) { var topBlock = _blockColumn.Blocks[_blockColumn.Blocks.Count - 1].gameObject; var bottomBlock = _blockColumn.Blocks[0].gameObject; var isTopOfWallOpen = topBlock.transform.position.y <= bottomBlock.transform.position.y + WallHeight - 1; if (!isTopOfWallOpen) { return; } GameObject newTopBlock; var maxChance = Mathf.Max(25, Mathf.RoundToInt(timeToScaleDifficulty) - Mathf.RoundToInt(Time.time)); if (_blockColumn.Blocks.Count > 8 && Random.Range(1, maxChance) <= 3) { newTopBlock = Instantiate(BlockColumnManager.Instance.BombBlockPrefab); } else if (_blockColumn.Blocks.Count > 8 && _consecutiveMovableBlocks > _consecutiveMovableBlocksBeforeImmovableBlock) { newTopBlock = Instantiate(BlockColumnManager.Instance.ImmovableBlockPrefab); _consecutiveMovableBlocks = 0; _consecutiveMovableBlocksBeforeImmovableBlock = Random.Range(ConsecutiveMovableBlockMin, ConsecutiveMovableBlockMax); //decrease over time to half of original min/max _consecutiveMovableBlocksBeforeImmovableBlock *= Mathf.RoundToInt(Mathf.Max(0.5f, (timeToScaleDifficulty * 2 - Time.time) / timeToScaleDifficulty * 2)); } else { newTopBlock = Instantiate(BlockColumnManager.Instance.BlockPrefab); _consecutiveMovableBlocks++; } newTopBlock.transform.position = bottomBlock.transform.position + Vector3.up * WallHeight; _blockColumn.Add(newTopBlock); if (IsInitialized) { newTopBlock.GetComponent <Block>().MakeFallAfterSlideBlockDelay(); } else { newTopBlock.GetComponent <Block>().MakeFallAfterDelay(Random.Range(0.0f, 0.1f)); } if (_blockColumn.Blocks.Count == WallHeight) { IsInitialized = true; GameController.Instance.IsStarted = true; } } }
BlockColumn CopyColumnMetadata(BlockPage2 blocksetInfo, BlockColumn column) { var columnInfo = new BlockColumn(blocksetInfo, column.ColumnType, column.X1, column.W); var block = new Block() { H = column.GetH(), X = column.GetX(), Height = column.GetHeight(), Width = column.GetWidth(), Text = $"Column [{columnInfo.ColumnType}:{columnInfo.X1}]" }; var bset = new BlockSet <IBlock>(blocksetInfo); bset.Add(block); columnInfo.Add(bset); return(columnInfo); }
public BlockPage Process(BlockPage page2) { var page = page2 as BlockPage2; if (page == null) { PdfReaderException.AlwaysThrow("MergeSequentialLayout must execute AFTER OrganizePageLayout"); } var result = new BlockPage2(); foreach (var segment in page.Segments) { BlockPageSegment newsegment = new BlockPageSegment(result, segment.NumberOfColumns); foreach (var column in segment.Columns) { BlockColumn newcolumn = new BlockColumn(result, column.ColumnType, column.X1, column.W); IBlock last = null; var orderedColumns = column.OrderByDescending(b => b.GetH()); foreach (var block in orderedColumns) { if (last != null) { var b1 = last as IBlockSet <IBlock>; var b2 = block as IBlockSet <IBlock>; if (block is TableSet || block is ImageBlock || last is TableSet || last is ImageBlock) { newcolumn.Add(last); last = block; continue; } if (b1 == null || b2 == null) { PdfReaderException.AlwaysThrow("not expected"); } if (Block.SameHeight(b1, b2)) { last = Merge(b1, b2); // merge continue; } newcolumn.Add(last); } last = block; } if (last != null) { newcolumn.Add(last); } newsegment.AddColumn(newcolumn); } result.AddSegment(newsegment); } return(result); }