/// <summary>
    /// Called to create the character's death screenshot
    /// </summary>
    /// <param name="deathDir"></param>
    public void CreateCharacterScreenshot(ScreenshotDir deathDir)
    {
        bool   isNewTopScore  = m_currentScore > m_gameSceneMaster.TopScore;
        string topScoreString = isNewTopScore ? "NEW TOP" : "TOP" + m_gameSceneMaster.TopScore.ToString();

        m_charScreenshot = m_gameUI.ScreenshotTaker.TakeScreenshot(m_character.transform.position, deathDir,
                                                                   m_currentScore.ToString(), topScoreString);
    }
Esempio n. 2
0
    /// <summary>
    /// Starts the death
    /// </summary>
    private void StartDeath(DeathType deathType, ScreenshotDir deathDir)
    {
        // Enter death state
        m_state     = State.DEATH;
        m_deathType = deathType;
        m_deathDir  = deathDir;
        DisablePhysics();
        DetachController();

        // Cancel jumps
        m_isJumping        = false;
        m_isRotating       = false;
        m_pendingJumpCount = 0;

        // Inform game manager
        Locator.GetGameManager().NotifyCharacterDeathStart(m_deathType);
        m_deathTimer = 0f;

        switch (m_deathType)
        {
        case DeathType.EAGLE:
            m_eagleNearFlag = false;
            // Get out of platform
            if (m_targetPlatform != null)
            {
                m_targetPlatform.SetPassenger(null);
            }
            transform.parent = null;
            break;

        case DeathType.VEHICLE:
            // Take the screenshot immediately
            Locator.GetGameManager().CreateCharacterScreenshot(m_deathDir);
            PlayDeathSound();
            break;

        case DeathType.DROWN:
            // Get out of platform
            if (m_targetPlatform != null)
            {
                m_targetPlatform.SetPassenger(null);
            }
            transform.parent = null;
            PlayDeathSound();
            break;

        case DeathType.LOG:
            // Take the screenshot immediately
            Locator.GetGameManager().CreateCharacterScreenshot(m_deathDir);
            break;
        }
    }
Esempio n. 3
0
    /// <summary>
    /// Takes a screenshot.
    /// </summary>
    /// <param name="focus">The focus of the screenshot.</param>
    /// <param name="screenshotDir">The screenshot direction.</param>
    /// <returns>The screenshot texture</returns>
    public Texture2D TakeScreenshot(Vector3 focus, ScreenshotDir screenshotDir, string scoreText, string topScoreText)
    {
        // Enable screenshot camera to take the screenshot
        m_screenshotCamera.gameObject.SetActive(true);

        // Lazy init UIText
        if (!m_scoreText.IsInitialized)
        {
            m_scoreText.Initialize();
        }
        if (!m_topScoreText.IsInitialized)
        {
            m_topScoreText.Initialize();
        }

        // Set up score and top score display
        m_scoreText.SetText(scoreText);
        m_topScoreText.SetText(topScoreText);

        // Rotate dir around the x and y axes
        float vertAngle = m_vertAngleOffset + Random.Range(-m_randomDeltaAngle, m_randomDeltaAngle);
        float horAngle  = Random.Range(-m_randomDeltaAngle, m_randomDeltaAngle);
        // Screenshot can be taken obliquely from the right or from the left of the subject
        float horAngleOffsetSign = (Random.value > 0.5f) ? 1.0f : -1.0f;

        switch (screenshotDir)
        {
        case ScreenshotDir.Front:
            horAngle += m_horAngleOffset * horAngleOffsetSign;
            break;

        case ScreenshotDir.Side_Left:
            horAngle += -90.0f;
            break;

        case ScreenshotDir.Side_Right:
            horAngle += 90.0f;
            break;

        case ScreenshotDir.Back:
            horAngle += 180.0f + m_horAngleOffset * horAngleOffsetSign;
            break;
        }
        // Get the direction vector from the subject to the screenshot position
        //  (i.e. where camera should take the screenshot from)
        Vector3 focusToScreenshotPosDir = Quaternion.Euler(vertAngle, -horAngle, 0.0f) * Vector3.back;

        // Set camera distance and vertical offset from the subject
        float camDist = m_screenshotCamDist + Random.Range(-m_randomDeltaDist, m_randomDeltaDist);

        focus.y += m_verticalOffset;
        // Move camera to the screenshot position and make it look at the focus point
        m_screenshotCamera.transform.position = focus + focusToScreenshotPosDir * camDist;
        m_screenshotCamera.transform.LookAt(focus);

        // Take screenshot
        m_screenshotResult = ScreenshotUtils.TakeScreenshot(m_screenshotWidth, m_screenshotHeight, m_screenshotCamera);

        // Disable screenshot camera once screenshot has been taken
        m_screenshotCamera.gameObject.SetActive(false);

        return(m_screenshotResult);
    }