Ejemplo n.º 1
0
 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]);
     }
 }
Ejemplo n.º 2
0
    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);
    }
Ejemplo n.º 3
0
 void SetElectricity(Pixel px, PixelDirection dir)
 {
     px.content = PixelContent.Electricity;
     px.dir     = dir;
     renderQueue.Enqueue(px);
 }