Advertisement
Guest User

Untitled

a guest
Feb 17th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6.  
  7. public class GameSetup : MonoBehaviour {
  8.  
  9. public Canvas canvas;
  10. public Text gameover_text;
  11. private Color origCol;
  12. public GameObject player;
  13. public GameObject ground;
  14. static GameSetup instance;
  15. void Awake()
  16. {
  17. instance = this;
  18. }
  19. public static GameSetup GetInstance()
  20. {
  21. return instance;
  22. }
  23.  
  24. void Start () {
  25. StartCoroutine(Animate());
  26. Instantiate (player, new Vector3 (-12, 5, 0), Quaternion.identity);
  27. Instantiate (ground, new Vector3 (0, -9, 0), Quaternion.identity);
  28. Instantiate (ground, new Vector3 (0, 9, 0), Quaternion.identity);
  29. }
  30.  
  31. public void GameOver()
  32. {
  33. StartCoroutine(Animate());
  34. Debug.Log("Game Over");
  35. }
  36.  
  37. private IEnumerator Animate()
  38. {
  39. Debug.Log("Coroutine started");
  40. yield return new WaitForSeconds(1f);
  41. for (float f = 0; f <= 1; f += Time.deltaTime)
  42. {
  43. gameover_text.color = new Color32(255, 0, 0, 255);
  44. gameover_text.Rebuild(new CanvasUpdate());
  45. yield return null;
  46. }
  47. Debug.Log("Current state: " + gameover_text.color);
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement