Exemple #1
0
    /// <summary>
    /// Starts the game with a countdown
    /// </summary>
    /// <returns>IEnumerator</returns>
    private IEnumerator StartGame()
    {
        //Lock the players cursor for better flying controlls with the mouse
        Cursor.lockState = CursorLockMode.Locked;

        // Set the state to "preparing"
        State = GameState.Preparing;

        // Update the UI (hide it)
        uiController.ShowBanner("");
        uiController.HideButton();
        uiController.ShowSlider(false);

        // Use the player camera, disable the main camera
        mainCamera.gameObject.SetActive(false);
        player.agentCamera.gameObject.SetActive(true);

        // Show countdown
        uiController.ShowBanner("3");
        yield return(new WaitForSeconds(1f));

        uiController.ShowBanner("2");
        yield return(new WaitForSeconds(1f));

        uiController.ShowBanner("1");
        yield return(new WaitForSeconds(1f));

        uiController.ShowBanner("Go!");
        yield return(new WaitForSeconds(1f));

        uiController.ShowBanner("");

        // Set the state to "playing"
        State = GameState.Playing;

        // Start the game timer
        gameTimerStartTime = Time.time;

        // Unfreeze the agents
        player.UnfreezeAgent();
        opponent.UnfreezeAgent();
    }