protected IEnumerator MoveToTransform(Transform target) { float t = 0f; Vector3 startPosition = transform.position; Vector3 startScale = transform.localScale; // Play some particles if we got em if (particles) { particles.Play(); } if (collectAnimation) { Debug.Log("playing collect animation"); collectAnimation.enabled = true; collectAnimation.transform.parent = null; } // Play some audio PlayRandomlyChosenAudioClip audioPlayer = GetComponent <PlayRandomlyChosenAudioClip>(); if (audioPlayer) { audioPlayer.PlayAudio(); } else { AudioSource audioSource = GetComponent <AudioSource>(); if (audioSource) { audioSource.Play(); } } while (t < duration) { t += Time.deltaTime; float ellapsedRatio = t / duration; Vector3 newPos = Vector3.Lerp(startPosition, target.position, ellapsedRatio); newPos.z = startPosition.z - 3f * Mathf.Sin(ellapsedRatio * Mathf.PI); transform.position = newPos; transform.localScale = Vector3.Lerp(startScale, Vector3.one * 0.05f, ellapsedRatio); yield return(null); } transform.position = target.position; transform.localScale = Vector3.zero; yield break; }
public IEnumerator MoveToTransform(Transform target) { yield return(null); float t = 0f; Vector3 startPosition = transform.position; // Play some particles if we got em if (particles) { particles.Play(); } // Play some audio PlayRandomlyChosenAudioClip audioPlayer = GetComponent <PlayRandomlyChosenAudioClip>(); if (audioPlayer) { audioPlayer.PlayAudio(); } else { AudioSource audioSource = GetComponent <AudioSource>(); if (audioSource) { audioSource.Play(); } } while (t < duration) { t += Time.deltaTime; float ellapsedRatio = t / duration; Vector3 newPos = Vector3.Lerp(startPosition, target.position, ellapsedRatio); transform.position = newPos; cg.alpha = Mathf.Clamp01(ellapsedRatio * 10f); yield return(null); } transform.position = target.position; cg.alpha = 1.0f; yield return(new WaitForSeconds(0.5f)); yield break; }
private void DropOffCollectibles() { if (GameState.NewCollectibles.Count > 0) { PlayRandomlyChosenAudioClip audioPlayer = GetComponent <PlayRandomlyChosenAudioClip>(); if (audioPlayer) { audioPlayer.PlayAudio(); } else { AudioSource audioSource = GetComponent <AudioSource>(); if (audioSource) { audioSource.Play(); } } } foreach (var collectible in GameState.NewCollectibles) { Debug.Log("dropping off a collectible"); GameState.CollectedCollectibles.Add(collectible); Vector3 targetPosition = GameState.AvailableDropOffPositions.Dequeue(); Vector3 targetScale = collectible.GetComponent <Collectible>().InitialScale / 2; CollectibleDropOffEffect effect = collectible.GetComponent <CollectibleDropOffEffect>(); if (effect) { Debug.Log("playing drop-off effect"); effect.BeginEffect(basket.position, targetPosition, targetScale); } else { Debug.Log("no drop-off effect found"); GetComponent <Transform>().position = targetPosition; GetComponent <Transform>().localScale = targetScale; } } GameState.NewCollectibles.Clear(); }
public void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "Player") { Debug.Log("Balloon has hit Mama!"); PlayRandomlyChosenAudioClip audioPlayer = GetComponent <PlayRandomlyChosenAudioClip>(); if (audioPlayer) { audioPlayer.PlayAudio(); } else { AudioSource audioSource = GetComponent <AudioSource>(); if (audioSource) { audioSource.Play(); } } } }
protected IEnumerator LandBalloon(Transform balloon) { float t = 0f; Vector3 startPosition = balloon.position; Vector3 startScale = balloon.localScale; // Play some particles if we got em if (particles) { particles.Play(); } // Play some audio PlayRandomlyChosenAudioClip audioPlayer = GetComponent <PlayRandomlyChosenAudioClip>(); if (audioPlayer) { audioPlayer.PlayAudio(); } else { AudioSource audioSource = GetComponent <AudioSource>(); if (audioSource) { audioSource.Play(); } } while (t < duration) { t += Time.deltaTime; float ellapsedRatio = t / duration; Vector3 newPos = Vector3.Lerp(startPosition, target.position, ellapsedRatio); newPos.z = newPos.z - 3f * Mathf.Sin(ellapsedRatio * Mathf.PI); balloon.position = newPos; yield return(null); } balloon.position = target.position; yield return(new WaitForSeconds(0.75f)); MoveRocket rocket = FindObjectOfType <MoveRocket>(); if (rocket) { yield return(StartCoroutine(rocket.MoveToTransform(rocket.target))); } if (MusicPlayer.Instance) { yield return(StartCoroutine(MusicPlayer.Instance.FadeAllVolumes())); } // Load the gallery SceneManager.LoadScene("End Comic"); yield break; }