Beispiel #1
0
 /// <summary>
 /// Start this instance.
 /// </summary>
 private void Start()
 {
     m_creditsAnimator = new UIAnimator(this.transform);
     m_creditsAnimator.SetPositionAnimation(m_creditsAnimStartPos.position, m_creditsAnimEndPos.position);
     m_creditsAnimator.SetAnimSpeed(0.1f);
     m_creditsAnimator.AnimateToState2();
 }
    /// <summary>
    /// Initializes this instance.
    /// </summary>
    public void Initialize(CoinWinAnimator coinWinUI, float initialSpeed, float initialRotSpeed,
                           Vector3 moveDir, float deceleration)
    {
        m_coinWinUI    = coinWinUI;
        m_speed        = initialSpeed;
        m_rotSpeed     = initialRotSpeed;
        m_moveDir      = moveDir;
        m_deceleration = deceleration;

        // Initialize coin animator
        //  State 1: Zero scale
        //  State 2: Normal scale
        m_coinScaleAnimator = new UIAnimator(m_coinSprite.transform);
        m_coinScaleAnimator.SetScaleAnimation(Vector3.zero, m_coinSprite.transform.localScale);
        m_coinScaleAnimator.SetAnimSpeed(m_coinScaleAnimSpeed);

        // Initialize collect animator
        //  State 1: Original scale
        //  State 2: Zero scale
        m_collectAnimator = new UIAnimator(m_collectSprite.transform);
        m_collectAnimator.SetScaleAnimation(m_collectSprite.transform.localScale, Vector3.zero);
        m_collectAnimator.SetAnimSpeed(m_collectAnimSpeed);

        Reset();

        // Start coin scale animation
        m_coinScaleAnimator.AnimateToState2();

        // Set the initialized flag
        m_isInitialized = true;
    }
Beispiel #3
0
    /// <summary>
    /// Updates the credits animation.
    /// </summary>
    private void UpdateCreditsAnimation()
    {
        if (!m_creditsUIRoot.activeSelf)
        {
            return;
        }

        m_creditsFader.Update(Time.deltaTime);
        m_creditsScroller.Update(Time.deltaTime);
        m_creditsBSATFader.Update(Time.deltaTime);

        switch (m_creditsBSATFader.UIAnimState)
        {
        case UIAnimator.UIAnimationState.STATE1:
            // Show "Be Safe Around Trains" message when credits scrolling is about to end
            if (m_bsatTrigger.position.y > Locator.GetSceneMaster().UICamera.ScreenMaxWorld.y)
            {
                m_bsatMessage.gameObject.SetActive(true);
                m_creditsBSATFader.AnimateToState2();
            }
            break;

        case UIAnimator.UIAnimationState.TO_STATE2:
        case UIAnimator.UIAnimationState.STATE2:
            // Show psycho character when "Be Safe Around Trains" fades in
            m_timeSinceBSATFadeStart += Time.deltaTime;
            if (m_timeSinceBSATFadeStart > m_timeFromBSATToPsychoAnim &&
                m_psychoAnimator.speed == 0.0f)
            {
                m_psychoAnimator.speed = 1.0f;
            }
            break;
        }
    }
Beispiel #4
0
    /// <summary>
    /// Shows the credits UI.
    /// </summary>
    /// <param name="show">If set to <c>true</c> show the credits UI. Else, hide it.</param>
    private void ShowCreditsUI(bool show = true)
    {
        // Start "Be Safe Around Trains" message hidden
        m_bsatMessage.SetAlpha(0.0f);

        // Start psycho character hidden
        m_psychoAnimator.Play(PSYCHO_CREDITS_ANIM_NAME);
        m_psychoAnimator.speed   = 0.0f;
        m_timeSinceBSATFadeStart = 0.0f;

        if (show)
        {
            // Start credits animation
            m_creditsFader.AnimateToState2();
            m_creditsScroller.AnimateToState2();
        }
        else
        {
            // Reset animation
            m_creditsFader.ResetToState(UIAnimator.UIAnimationState.STATE1);
            m_creditsScroller.ResetToState(UIAnimator.UIAnimationState.STATE1);
            m_creditsBSATFader.ResetToState(UIAnimator.UIAnimationState.STATE1);
        }

        // Enable/disable UI
        m_creditsUIRoot.SetActive(show);
        m_bsatMessage.gameObject.SetActive(show);
    }
Beispiel #5
0
 /// <summary>
 /// Enables the instruction end animations.
 /// </summary>
 private void EnableInstructionEndAnimations()
 {
     if (m_endAnimator0 != null)
     {
         m_endAnimator0.AnimateToState2();
     }
     if (m_endAnimator1 != null)
     {
         m_endAnimator1.AnimateToState2();
     }
 }
Beispiel #6
0
    /// <summary>
    /// Starts the lose animation.
    /// </summary>
    protected override void StartLoseAnimation()
    {
        m_endScreen.SetActive(true);
        m_endAnimWin.gameObject.SetActive(false);
        m_endAnimLose.gameObject.SetActive(true);
        AddToAnimatorList(m_endAnimLose);

        // Use UIAnimator to change character color and alpha as if electrocuted
        m_loseAnimator = new UIAnimator(m_endAnimCharLose, UIAnimator.UIAnimatorType.COLOR, true, true);
        m_loseAnimator.SetColorAnimation(Color.white, m_loseBlinkColor);
        m_loseAnimator.SetAnimSpeed(m_loseAnimSpeed);
        m_loseAnimator.AnimateToState2();

        m_electrocuteSound = Locator.GetSoundSystem().PlaySound(SoundInfo.SFXID.FORK_ELECTROCUTE);
    }
Beispiel #7
0
    /// <summary>
    /// Updates the screenshot animation.
    /// </summary>
    private void UpdateAnimState()
    {
        m_stillShotAnimator.Update(Time.deltaTime);

        switch (m_state)
        {
        case ScreenshotAnimState.IDLE:
            break;

        case ScreenshotAnimState.SCALE_UP:
            // Update scale up animation
            m_scaleUpAnimator.Update(Time.deltaTime);
            // When screenshot reaches normal scale, proceed to next anim state
            if (m_scaleUpAnimator.IsInState2)
            {
                // Start slide animation
                m_slideAnimator.AnimateToState2();
                m_state = ScreenshotAnimState.SLIDE;
            }
            break;

        case ScreenshotAnimState.SLIDE:
            // Update slide animation
            m_slideAnimator.Update(Time.deltaTime);
            // When screenshot reaches target position, proceed to next anim state
            if (m_slideAnimator.IsInState2)
            {
                // Start scale down animation
                m_scaleDownAnimator.AnimateToState2();
                m_state = ScreenshotAnimState.SCALE_DOWN;
            }
            break;

        case ScreenshotAnimState.SCALE_DOWN:
            // Update scale down animation
            m_scaleDownAnimator.Update(Time.deltaTime);
            // When screenshot reaches zero scale (becomes hidden), end the animation
            if (m_scaleDownAnimator.IsInState2)
            {
                m_state = ScreenshotAnimState.IDLE;

                // Hide screenshot UI
                Hide();
            }
            break;
        }
    }
    /// <summary>
    /// Updates the win coins wait time.
    /// </summary>
    private void UpdateWaitWinCoins()
    {
        if (!m_waitWinCoins)
        {
            return;
        }

        m_timeSinceGiftOpened += Time.deltaTime;
        if (m_timeSinceGiftOpened > m_winCoinsAnimDelay)
        {
            m_waitWinCoins        = false;
            m_timeSinceGiftOpened = 0.0f;

            // Animate white overlay
            m_giftOverlay.gameObject.SetActive(true);
            m_giftOverlayAnimator.AnimateToState2();
        }
    }
Beispiel #9
0
    /// <summary>
    /// Updates the lose animation.
    /// </summary>
    protected override void UpdateLoseAnimation()
    {
        if (m_loseAnimator == null)
        {
            return;
        }

        m_loseAnimator.Update(Time.deltaTime);

        // Make lose animation loop until SceneMaster ends the scene
        if (m_loseAnimator.IsInState1)
        {
            m_loseAnimator.AnimateToState2();
        }
        else if (m_loseAnimator.IsInState2)
        {
            m_loseAnimator.AnimateToState1();
        }
    }
Beispiel #10
0
    /// <summary>
    /// Shows or hides the safety pledge UI.
    /// </summary>
    /// <param name="show">If set to <c>true</c> show the pledge UI.</param>
    private void ShowPledgeUI(bool show = true)
    {
        if (show)
        {
            m_pledgeRoot.SetActive(true);
            m_pledgeOverlay.gameObject.SetActive(true);

            m_pledgeUIAnimator.AnimateToState2();
            m_pledgeOverlayAnimator.AnimateToState2();
        }
        else
        {
            m_pledgeUIAnimator.AnimateToState1();
            m_pledgeOverlayAnimator.AnimateToState1();
        }

        // Enable/Disable buttons behind the pledge UI
        m_playAgainButton.GetComponent <Collider2D>().enabled = !show;
        m_mainMenuButton.GetComponent <Collider2D>().enabled  = !show;
        m_pledgeButton.GetComponent <Collider2D>().enabled    = !show;
    }
Beispiel #11
0
 /// <summary>
 /// Shows the pledge thanks UI.
 /// </summary>
 private void ShowPledgeThanks()
 {
     m_pledgeThanks.SetActive(true);
     m_pledgeThanksState = PledgeThanksState.SHOWING;
     m_pledgeThanksAnimator.AnimateToState2();
 }