Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.14 KB | None | 0 0
  1. public GameObject blood;
  2.     public GameObject chat;
  3.     public Text text;
  4.     public Text best;
  5.     public int scorerun, bestscore;
  6.     public static gamemeneger I;
  7.     public float diedtime;
  8.     bool can_enter = false;
  9.     bool can_enter2 = true;
  10.     Image img;
  11.     private void Awake()
  12.     {
  13.         I = this;
  14.     }
  15.  
  16.     void Start()
  17.     {
  18.         bestscore = PlayerPrefs.GetInt("bestscore");
  19.         StringBuilder MyString = new StringBuilder(bestscore);
  20.         MyString.Append(bestscore);
  21.         best.text = MyString.ToString();
  22.         InvokeRepeating("score", 0, 0.5f);
  23.  
  24.  
  25.  
  26.     }
  27.  
  28.     void score()
  29.     {
  30.         if (can_enter2)
  31.         {
  32.             scorerun += 1;
  33.             StringBuilder MyString = new StringBuilder(scorerun);
  34.             MyString.Append(scorerun);
  35.             text.text = MyString.ToString();
  36.         }
  37.     }
  38.  
  39.     public void Died()
  40.     {
  41.         if (scorerun > bestscore)
  42.         {
  43.             bestscore = scorerun;
  44.         }
  45.         blood.SetActive(true);
  46.         PlayerPrefs.SetInt("scorerun", scorerun);
  47.         PlayerPrefs.SetInt("bestscore", bestscore);
  48.         PlayerPrefs.SetFloat("dist", scorerun);
  49.         PlayerPrefs.Save();
  50.         can_enter = true;
  51.         can_enter2 = false;
  52.     }
  53.     private void Update()
  54.     {
  55.         if (can_enter)
  56.         {
  57.             StartCoroutine("Death");
  58.             diedtime += Time.deltaTime;
  59.             if (diedtime >= 2) SceneManager.LoadScene(0);
  60.         }
  61.         if (Input.GetKeyDown(KeyCode.F))
  62.         {
  63.             Debug.Log("123");
  64.             StartCoroutine("Hide");
  65.         }
  66.     }
  67.     IEnumerator Death()
  68.     {
  69.  
  70.         img = blood.GetComponent<Image>();
  71.         var tempCol = img.color;
  72.         float time = 5f;
  73.         for (float t = 0; t < time; t += Time.deltaTime)
  74.         {
  75.             tempCol.a = t / time;
  76.             img.color = tempCol;
  77.         }
  78.  
  79.         tempCol.a = 1f;
  80.         img.color = tempCol;
  81.         yield return null;
  82.     }
  83.     IEnumerator Hide()
  84.     {
  85.         for (float f = 1f; f >= 0; f -= 0.1f)
  86.         {
  87.            
  88.            
  89.             yield return null;
  90.         }
  91.        
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement