Exemplo n.º 1
0
    /*private void SetNeighbours(int startingCircleNeighbourDirection)
     * {
     *  // 0-top, 1-right, 2-bottom, 3-left
     *
     *  // if there's no neighobur in that direction, then set it. Otherwise don't
     *  if (!startingCircleScript.GetNeighbour(startingCircleNeighbourDirection))
     *  {
     *      startingCircleScript.SetNeighbour(startingCircleNeighbourDirection);
     *      endingCircleScript.SetNeighbour((startingCircleNeighbourDirection + 2) % 4);
     *  }
     *  else
     *  {
     *      throw new System.ArgumentException("invalid neighbour");
     *  }
     * }*/

    private void MarkBiscuitsSide(float lineX, float lineY, bool lineIsRotated)
    {
        biscuitMatrix = createBiscuit.GetBiscuitMatrix();
        int top = 0, right = 1, bottom = 2, left = 3;

        if (lineIsRotated) // the squares are left-right neighbours
        {
            float y = lineY;
            float xOfFirstSquare  = lineX - 0.5f;
            float xOfSecondSquare = lineX + 0.5f;
            biscuitMatrix.SetLine(xOfFirstSquare, y, right);
            CheckForSquare(xOfFirstSquare, y);
            biscuitMatrix.SetLine(xOfSecondSquare, y, left);
            CheckForSquare(xOfSecondSquare, y);
        }
        else // the squares are top-bottom neighbours
        {
            float x = lineX;
            float yOfFirstSquare  = lineY - 0.5f;
            float yOfSecondSquare = lineY + 0.5f;
            biscuitMatrix.SetLine(x, yOfFirstSquare, top);
            CheckForSquare(x, yOfFirstSquare);
            biscuitMatrix.SetLine(x, yOfSecondSquare, bottom);
            CheckForSquare(x, yOfSecondSquare);
        }
    }