Example #1
0
        private IEnumerator LerpTime(float delay, float targetScale, TutorialSegment segment)
        {
            yield return(new WaitForSecondsRealtime(delay));

            float initialScale = Time.timeScale;
            float startTime    = Time.realtimeSinceStartup;

            TextMeshProUGUI[] textArray = new TextMeshProUGUI[0];
            if (segment)
            {
                textArray = segment.GetFadeTextArray();
            }
            while (Time.realtimeSinceStartup - startTime < lerpDuration)
            {
                float lerpConstant = Mathf.Sqrt((Time.realtimeSinceStartup - startTime) / lerpDuration);
                Time.timeScale = Mathf.Lerp(initialScale, targetScale, lerpConstant);
                foreach (TextMeshProUGUI text in textArray)
                {
                    text.color = Color.Lerp(Color.clear, Color.black, lerpConstant);
                }
                yield return(null);
            }
            Time.timeScale = targetScale;
            timeCoroutine  = null;
        }
        private void SpawnCurrentSegment()
        {
            currentSegment = segmentList[currentSegmentIndex];
            Vector3 spawnPosition = new Vector3(0, player.transform.position.y, zPosition);

            spawnPosition.y += currentSegment.GetSpawnWavelengthDelay() * WavelengthDuration * verticalSpeed;
            Instantiate(currentSegment, spawnPosition, Quaternion.identity, gameObject.transform);
            readyToSpawn = false;
        }
Example #3
0
 //Public Methods
 public void FreezeTime(float delay, TutorialSegment segment)
 {
     if (timeCoroutine == null)
     {
         timeCoroutine = StartCoroutine(LerpTime(delay, 0f, segment));
     }
     else
     {
         Debug.LogWarning("Time Coroutine Already In Progress");
     }
 }