コード例 #1
0
    IEnumerator GameOver()
    {
        // "Kill" the character
        GlobalData.PlayerDeath = true;

        // Fade out the game.
        gameUIScript.StartGameFadeOut();

        // Wait for the game to fade out, and then move the character and the camera to the checkpoint's position.
        yield return(new WaitForSeconds(1f));

        playerTransform.position = playerCameraTransform.position = checkPoint.position;
        playerTransform.rotation = playerCameraTransform.rotation = checkPoint.rotation;

        // Enable/Disable the camera scripts
        fixedCameraMovementScript.enabled = checkPointFixedCameraEnabled;
        freeCameraMovementScript.enabled  = checkPointFreeCameraEnabled;

        if (checkPointFixedCameraEnabled)
        {
            fixedCameraMovementScript.StartCameraTransition();
        }
        if (checkPointFreeCameraEnabled)
        {
            freeCameraMovementScript.CenterCamera();
        }

        // Wait for the camera to move properly to the character position and then fade in.
        yield return(new WaitForSeconds(0.5f));

        gameUIScript.StartGameFadeIn();

        // "Revive" the character
        GlobalData.PlayerDeath = false;
    }
コード例 #2
0
    IEnumerator GameOver()
    {
        // "Kill" the character
        GlobalData.PlayerMovementScript.DisableInput();
        GlobalData.PlayerDeath = true;

        // Fade out the game.
        gameUIScript.StartGameFadeOut();

        Analytics.CustomEvent("Game Over", new Dictionary <string, object> {
            { "Acons left", GlobalData.AcornCount }
        });

        // Wait for the game to fade out, and then move the character and the camera to the checkpoint's position.
        yield return(new WaitForSeconds(1f));

        playerTransform.position = playerCameraTransform.position = GlobalData.currentCheckPoint.position;
        playerTransform.rotation = playerCameraTransform.rotation = GlobalData.currentCheckPoint.rotation;

        // Enable/Disable the camera scripts
        fixedCameraMovementScript.enabled = checkPointFixedCameraEnabled;
        freeCameraMovementScript.enabled  = checkPointFreeCameraEnabled;

        if (checkPointFixedCameraEnabled)
        {
            fixedCameraMovementScript.StartCameraTransition();
        }
        if (checkPointFreeCameraEnabled)
        {
            freeCameraMovementScript.CenterCamera();
        }

        // Wait for the camera to move properly to the character position and then fade in.
        yield return(new WaitForSeconds(0.5f));

        gameUIScript.StartGameFadeIn();

        // If the character loses all the acorns, reload the scene.
        if (GlobalData.AcornCount == 0)
        {
            GlobalData.AcornCount = GlobalData.MinimumAcornCount;
            gameUIScript.UpdateAcornCounter();


            ChangeScene(SceneManager.GetActiveScene().name);
        }

        // "Revive" the character and show the health in the UI again.
        GlobalData.PlayerMovementScript.EnableInput();
        GlobalData.PlayerDeath = false;
    }
コード例 #3
0
 // Call the function in the CameraMovementScript
 public static void CenterCamera()
 {
     FreeCameraMovementScript.CenterCamera();
 }