Example #1
0
    private void HorizontalGate(Vector2 pos, bool Released)
    {
        RaycastHit2D hit1 = Physics2D.Raycast(pos, Vector2.left, Mathf.Infinity);
        RaycastHit2D hit2 = Physics2D.Raycast(pos, Vector2.right, Mathf.Infinity);

        if (hit1.collider && hit2.collider != null && !Released &&
            (dottedLineStatus == DottedLineStatus.upDown || dottedLineStatus == DottedLineStatus.none))
        {
            DottedLine.Instance.DestroyDottedLine();
            DottedLine.Instance.DrawDottedLine(hit1.point, hit2.point);
            dottedLineStatus = DottedLineStatus.leftRight;
        }
        else if (hit1.collider && hit2.collider != null && Released)
        {
            DottedLine.Instance.DestroyDottedLine();
            GameObject lineGO = Instantiate(linePrefab);
            lines.Add(lineGO);
            activeLine = lineGO.GetComponent <Line>();
            if (activeLine != null)
            {
                activeLine.DrawLine(hit1.point, hit2.point);
            }
            int YCod    = (int)hit1.point.y;
            int minXCod = Mathf.RoundToInt(hit1.point.x);
            int maxXCod = Mathf.RoundToInt(hit2.point.x) - 1;
            //Debug.Log(YCod);
            //Debug.Log(minXCod + ", " + maxXCod);
            for (int i = minXCod; i <= maxXCod; i++)
            {
                //Debug.Log(new Vector2(i, YCod));
                SetLineAt(new Vector2(i, YCod), true);
            }
            dottedLineStatus = DottedLineStatus.none;
        }
    }
Example #2
0
    private void Awake()
    {
        // set 60 fps for mobile devices
        Application.targetFrameRate = 60;

        // init games
        state            = State.Loaded;
        dottedLineStatus = DottedLineStatus.none;
        balls            = new List <GameObject>();

        boardWidth  = (int)gameBoard.transform.localScale.x;
        boardHeight = (int)gameBoard.transform.localScale.y;
        grid        = new bool[boardWidth, boardHeight];
    }