You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.3 KiB

  1. using UnityEngine;
  2. using System.Collections;
  3. public class titleScript : MonoBehaviour {
  4. public float finishScale;
  5. public float scaleTime;
  6. public GameObject confetti;
  7. public GameObject title;
  8. public GameObject fractTitle;
  9. public GameObject pressButtText;
  10. public GameObject menu;
  11. private bool onTitle = true;
  12. private bool finishExplosion = false;
  13. // Use this for initialization
  14. void Start () {
  15. title.SetActive (true);
  16. pressButtText.SetActive (true);
  17. title.transform.localScale = Vector3.one;
  18. StartCoroutine(scaleTitle(finishScale,scaleTime));
  19. }
  20. // Update is called once per frame
  21. void Update () {
  22. if (onTitle)
  23. newconfetti ();
  24. if (Input.anyKeyDown) {
  25. onTitle = false;
  26. title.SetActive(false);
  27. fractTitle.SetActive(true);
  28. pressButtText.SetActive(false);
  29. fractTitle.GetComponent<fracExplosion>().triggerExplos = true;
  30. //menu.SetActive(true);
  31. }
  32. }
  33. public void newconfetti ()
  34. {
  35. Vector3 pos = new Vector3 (Random.Range (-5, 5), 3.88f, 0);
  36. Instantiate (confetti, pos, title.transform.rotation);
  37. }
  38. IEnumerator scaleTitle (float finishScale,float scaleTime) {
  39. float startScale = title.transform.localScale.x;
  40. for (float i = 0; i < 1; i += Time.deltaTime/scaleTime) {
  41. title.transform.localScale = Vector3.one * Mathf.Lerp(startScale,finishScale,i);
  42. yield return null;
  43. }
  44. }
  45. }