CheckConnectionResult CheckConnection(int x, int z) { CheckConnectionResult res = new CheckConnectionResult(); List <BlockModel> blocks = res.blocks; BlockModel block = grid.Get(x, z); if (block == null) { return(res); // no block in the current position } blocks.Add(block); BlockWithDir next = new BlockWithDir(block, block.dir2); while ((next = GetNext(next)) != null) { if (block == next.Block) { break; } blocks.Add(next.Block); } if (next != null) { res.isLoop = true; return(res); // a loop is available } next = new BlockWithDir(block, block.dir1); while ((next = GetNext(next)) != null) { blocks.Add(next.Block); } return(res); // no loop available }
public void Bomb(int x, int z) { CheckConnectionResult res = CheckConnection(x, z); Remove(res.blocks); newPiece(this, new ListOfBlockEventArgs(pieces.Get())); Time = 0.0f; placeBomb(this, new EventArgs()); }
public void Push(List <BlockModel> blocks) { Add(blocks); foreach (BlockModel block in blocks) { CheckConnectionResult res = CheckConnection(block.x, block.z); if (res.isLoop) { Score += nbBlockToScoreIncrease(res.blocks.Count); Remove(res.blocks); loopCompleted(this, new EventArgs()); } } newPiece(this, new ListOfBlockEventArgs(pieces.Get())); Time = 0.0f; placePiece(this, new EventArgs()); }