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);
        }
    }
Exemplo n.º 2
0
    public GameObject CreateBiscuit(int height, SmartFox sfsReference)
    {
        if (sfsReference != null)
        {
            sfs = sfsReference;
            sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
        }

        float x = 10f;            // the middle of the screen on the x axis
        float y = 8 + height / 2; // 16 is the highest point on the y axis of the camera, so the biscuit matrix will start from the middle of it( 16/2 =8) with an offset of the given height/2

        heightLevel    = 0;
        maxHeightLevel = height;

        References = new List <GameObject>();

        biscuitContainer = Instantiate(biscuitParent) as GameObject;
        biscuitContainer.transform.position = new Vector3(10f, 8f, 0);// in the middle of the screen
        biscuitMatrix = biscuitContainer.GetComponent <BiscuitMatrix>();
        References.Add(biscuitContainer);

        while (heightLevel <= maxHeightLevel / 2)
        {
            PlaceBiscuit(x, y);
            heightLevel++;
        }

        return(biscuitContainer);
    }