public void DoSwap() { BlockGroup[] SwapGroups = { new BlockGroup(1, 1, this), new BlockGroup(1, 1, this) }; if (!ValidSwap()) { return; } for (int i = 0; i < 2; i++) { if (_Blocks[_SelectorRow, _SelectorCol + i] != null) { _Blocks[_SelectorRow, _SelectorCol + i].State = BlockState.Swapping; SwapGroups[i].Add(_Blocks[_SelectorRow, _SelectorCol + i], 0, 0); } else { Block emptyBlock = new Block(BlockType.Empty); emptyBlock.State = BlockState.Swapping; SwapGroups[i].Add(emptyBlock, 0, 0); _Blocks[_SelectorRow, _SelectorCol + i] = emptyBlock; } SwapGroups[i].Row = _SelectorRow; SwapGroups[i].Col = _SelectorCol + i; } _SwapBlocks.Add(SwapGroups); }
private bool TryChainExplode(Block b, int r, int c, BlockGroup chainGroup) { if (InBounds(r, c, this) && !BlockIsEmpty(r, c)) { Block target = _Blocks[r, c]; if (target.State == BlockState.Normal && target.Type == b.Type && !target.IsEmpty) { target.State = BlockState.Exploding; chainGroup.Add(target, r, c); return true; } } return false; }
public void Add(Block block, int row, int col) { _Blocks[row,col] = block; }