Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        AssignBallType();
        IsTurnReady = CheckTurn();
        if (cue.CueBallHit)
        {
            player1Turn    = !player1Turn;
            cue.CueBallHit = false;
            // turn off trigger for all balls when cue ball is hit
            foreach (Ball ball in table.GetBallObjects())
            {
                ball.GetComponent <Collider2D>().isTrigger = false;
            }
        }

        if (IsTurnReady)
        {
            // turn on trigger for normal ball except cue ball
            Ball[] balls = table.GetBallObjects();
            for (int i = 0; i < balls.Length - 1; i++)
            {
                balls[i].GetComponent <Collider2D>().isTrigger = true;
            }
        }
        else
        {
            cue.GetCollider().isTrigger = true;
        }
    }