void SetElectricity(int i, int j, PixelDirection dir) { if (i > 0 && i < totalRow && j > 0 && j < totalCol) { pixelArray[i, j].content = PixelContent.Electricity; pixelArray[i, j].dir = dir; renderQueue.Enqueue(pixelArray[i, j]); } }
Pixel GetPixelToSwap(Pixel px, PixelDirection dir) { switch (dir) { case PixelDirection.Up: if (px.row > 0) { return(pixelArray[px.row - 1, px.col]); } break; case PixelDirection.Down: if (px.row < totalRow - 1) { return(pixelArray[px.row + 1, px.col]); } break; case PixelDirection.Left: if (px.col > 0) { return(pixelArray[px.row, px.col - 1]); } break; case PixelDirection.Right: if (px.col < totalCol - 1) { return(pixelArray[px.row, px.col + 1]); } break; default: break; } return(null); }
void SetElectricity(Pixel px, PixelDirection dir) { px.content = PixelContent.Electricity; px.dir = dir; renderQueue.Enqueue(px); }