コード例 #1
0
    void Update()
    {
        if (!myPause.getPaused() && !deleting && noFallingBubbles() && (myBubbleSystem.getRemainingBubbles() == 0 || myBoard.noMoreBubbles()))
        {
            timeCounter            += Time.deltaTime;
            backgroundAudio.volume -= VOLUME_DECREASE;

            if (myBubbleSystem.isActiveAndEnabled && timeCounter >= WAIT_TIME_TO_COUNT_REMAINING)
            {
                myBubbleSystem.gameObject.SetActive(false);
            }

            if (!myResultSystem.isActiveAndEnabled && timeCounter >= WAIT_TIME_TO_END_LEVEL)
            {
                bool win = myBoard.noMoreBubbles();
                myResultSystem.activate(win);
            }
        }


        if (Input.GetKey(KeyCode.Escape))
        {
            loadLevels();
        }
    }
コード例 #2
0
    void Update()
    {
        Vector2 click       = myBoard.transform.parent.InverseTransformPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)); // myBoard.transform = canvas
        Vector2 forceVector = (click - myFirstBubble.getPosition()).normalized;

        if (canClick && !myPause.getPaused())
        {
            if (Input.GetMouseButtonDown(0) && click.y <= upBound)    // DOWN
            {
                goodClick = true;
            }
            else if (goodClick)
            {
                if (Input.GetMouseButton(0))   // PRESS
                {
                    if (click.y >= downBound)
                    {
                        myLine.placeLine(forceVector);
                    }
                    else
                    {
                        myLine.disableLine();
                    }
                }

                else if (Input.GetMouseButtonUp(0)) // UP
                {
                    myLine.disableLine();
                    goodClick = false;

                    if (click.y >= downBound)
                    {
                        canClick = false;
                        myFirstBubble.setVelocity(forceVector);
                        printRemainingAfterShoot();
                    }
                }
            }
        }
    }