コード例 #1
0
    // Check if either team is hogging all the balls
    void CheckHogg()
    {
        int ballsInCourt1 = 0;
        int ballsInCourt2 = 0;

        // check for every ball on which side of the court they are
        for (int i = 0; i < balls.Count; i++)
        {
            float x = balls[i].transform.position.x;

            if (x <= 0)
            {
                ballsInCourt1++;
            }
            if (x >= 0)
            {
                ballsInCourt2++;
            }
        }

        if (ballsInCourt1 == 0)
        {
            scoreboardManager.Hogg(2);
        }
        else
        {
            scoreboardManager.NotHogg(2);
        }

        if (ballsInCourt2 == 0)
        {
            scoreboardManager.Hogg(1);
        }
        else
        {
            scoreboardManager.NotHogg(1);
        }
    }