Example #1
0
    // Update is called once per frame
    void Update()
    {
        // Wait for lerp in
        if (m_transitionState == -1)
        {
            initialWaitTimer -= Time.deltaTime;
            if (initialWaitTimer <= 0)
            {
                m_transitionState = 1;
            }
        }
        // Lerp in
        else if (m_transitionState == 1)
        {
            transitionProgress += transitionSpeed * Time.deltaTime;
            if (transitionProgress >= 1)
            {
                transitionProgress = 1;
                m_transitionState  = 2;
                //waitForRotationTimer = waitForRotationLength;
                startLightWaitTimer = startLightWaitLength;
                lightWaitTimer      = 0;
                AudioLibrary.PlayPressurePlateOn();
            }

            if (transitionProgress > 0.8f && !stasisFitParticles.isPlaying)
            {
                stasisFitParticles.Play();
            }

            panelRT.anchoredPosition = Vector2.Lerp(transitionStartPos, transitionEndPos, transitionProgress);
            panelRT.localScale       = Vector2.Lerp(transitionStartScale, transitionEndScale, transitionProgress);
            stasisCanvasGroup.alpha  = transitionProgress;
        }
        else if (m_transitionState >= 2)
        {
            if (startLightWaitTimer > 0)
            {
                startLightWaitTimer -= Time.deltaTime;
                return;
            }

            lightWaitTimer -= Time.deltaTime;

            if (lightWaitTimer <= 0)
            {
                stasisLightParticles[m_transitionState - 2].Play();
                AudioLibrary.PlayStasisBubbleRemove();
                m_transitionState++;

                if (m_transitionState - 2 < stasisLightParticles.Length)
                {
                    lightWaitTimer = lightWaitLength;
                }
                else
                {
                    m_transitionState             = 0;
                    GameManager.inst.canUseStasis = true;
                }
            }
        }


        /*
         * lightWaitTimer -= Time.deltaTime;
         *
         * if (lightWaitTimer <= 0)
         * {
         *      Debug.Log("lightWaitTimer reached zero. TransitionState = " + m_transitionState);
         *
         *      stasisLightParticles[m_transitionState - 2].Play();
         *
         *      if (m_transitionState - 1 < stasisLightParticles.Length)
         *      {
         *              lightWaitTimer = lightWaitLength;
         *              m_transitionState++;
         *      }
         *      else
         *      {
         *              m_transitionState = 0;
         *      }
         * }
         * }*/

        // Wait for rotation

        /*
         * else if (transitionState == 2)
         * {
         *      waitForRotationTimer -= Time.deltaTime;
         *      if (waitForRotationTimer <= 0)
         *      {
         *              transitionState = 3;
         *      }
         * }
         * // Rotate
         * else if (transitionState == 3)
         * {
         *      panelRT.localEulerAngles = new Vector3 (0, 0, Mathf.Lerp(panelRT.localEulerAngles.z, endRotZ, spinSpeed * Time.deltaTime));
         *
         *      if (Mathf.Abs(panelRT.localEulerAngles.z - endRotZ) < 0.01f)
         *      {
         *              panelRT.localEulerAngles = new Vector3 (0, 0, endRotZ);
         *
         *              // TODO
         *              // Play particle effect here
         *
         *              transitionState = 0;
         *      }
         * }
         */
    }