Пример #1
0
    void Update()
    {
        if (!isPaused)
        {
            if (Input.GetKeyDown(KeyCode.P) || Input.GetKeyDown(KeyCode.Escape))
            {
                PauseGame();
            }

            for (int i = 0; i < NUM_PLAYERS; i++)
            {
                if (Input.GetKey(players[i].Left))
                {
                    bool player = i == 0 ? false : true;
                    GearSystem.Rotate(player, false);
                }

                if (Input.GetKey(players[i].Right))
                {
                    bool player = i == 0 ? false : true;
                    GearSystem.Rotate(player, true);
                }

                if (Input.GetKeyDown(players[i].Next))
                {
                    bool player = i == 0 ? false : true;
                    GearSystem.ChangeGearSystem(player, true);
                }

                if (Input.GetKeyDown(players[i].Previous))
                {
                    bool player = i == 0 ? false : true;
                    GearSystem.ChangeGearSystem(player, false);
                }
            }
        }
        else
        {
            if (Input.GetKeyDown(KeyCode.P) || Input.GetKeyDown(KeyCode.Escape))
            {
                UnpauseGame();
            }
        }

        score1.text = "Player 1\nScore: " + players[0].Score;
        score2.text = "Player 2\nScore: " + players[1].Score;
        time.text   = "Time Remaining\n" + (int)(gameEndTime - Time.time);

        if (Time.time > gameEndTime)
        {
            GameOver();
        }

        if (ballSpawner.BallSat * ballSpawner.BallSat < players[0].Score + players[1].Score)
        {
            ballSpawner.IncreaseSaturation();
        }
    }