zimethsuki

UnlockCars.cs

Jun 14th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.32 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3.  
  4. public class UnlockCars : MonoBehaviour
  5. {
  6.     private GameObject GameMaster;
  7.     private float currentHighScore;
  8.  
  9.     // ****** Bikin references untuk Button2 nya ******
  10.     public Button Button0;
  11.     public Button Button1;
  12.     public Button Button2;
  13.     public Button Button3;
  14.     public Button Button4;
  15.     public Button Button5;
  16.     public Button Button6;
  17.  
  18.     public Text TextAgarTerbuka;
  19.  
  20.     // Use this for initialization
  21.     private void Start()
  22.     {
  23.         // ***** Bikin Referesi ke Game Master *****
  24.         // ambil currentHighScore yg terekam di GameMaster.highscore;
  25.         GameMaster = GameObject.Find("GameMaster");
  26.         currentHighScore = GameMaster.GetComponent<GameMaster>().highScore;
  27.         CarUnlock();
  28.     }
  29.  
  30.     public void CarUnlock()
  31.     {
  32.         // ***** kalau currentHighScore nya dibawah 20, set active button 0 saja. dan kasih kata2 score to unlock 30 *****
  33.         if (currentHighScore < 20)
  34.         {
  35.             Button0.gameObject.SetActive(true);
  36.             TextAgarTerbuka.text = "Score To Unlock: 30";
  37.  
  38.         }  // ***** kalau currentHighScore nya dibawah atau sama dengan 30 , set active button0 sama button1. dan kasih kata2 score to unlock 40 *****
  39.         else if (currentHighScore <= 30)
  40.         {
  41.             Button0.gameObject.SetActive(true);
  42.             Button1.gameObject.SetActive(true);
  43.             TextAgarTerbuka.text = "Score To Unlock: 40";
  44.  
  45.         }
  46.         // ***** dan seterusnya *****
  47.         else if (currentHighScore <= 40)
  48.         {
  49.             Button0.gameObject.SetActive(true);
  50.             Button1.gameObject.SetActive(true);
  51.             Button2.gameObject.SetActive(true);
  52.             TextAgarTerbuka.text = "Score To Unlock: 50";
  53.  
  54.         }
  55.         else if (currentHighScore <= 50)
  56.         {
  57.             Button0.gameObject.SetActive(true);
  58.             Button1.gameObject.SetActive(true);
  59.             Button2.gameObject.SetActive(true);
  60.             Button3.gameObject.SetActive(true);
  61.             TextAgarTerbuka.text = "Score To Unlock: 60";
  62.  
  63.  
  64.         }
  65.         else if(currentHighScore <= 60)
  66.         {
  67.             Button0.gameObject.SetActive(true);
  68.             Button1.gameObject.SetActive(true);
  69.             Button2.gameObject.SetActive(true);
  70.             Button3.gameObject.SetActive(true);
  71.             Button4.gameObject.SetActive(true);
  72.             TextAgarTerbuka.text = "Score To Unlock: 70";
  73.  
  74.         }
  75.         else if (currentHighScore <= 70)
  76.         {
  77.             Button0.gameObject.SetActive(true);
  78.             Button1.gameObject.SetActive(true);
  79.             Button2.gameObject.SetActive(true);
  80.             Button3.gameObject.SetActive(true);
  81.             Button4.gameObject.SetActive(true);
  82.             Button5.gameObject.SetActive(true);
  83.             TextAgarTerbuka.text = "Score To Unlock: 80";
  84.  
  85.         }
  86.         else if (currentHighScore <= 80)
  87.         {
  88.             Button0.gameObject.SetActive(true);
  89.             Button1.gameObject.SetActive(true);
  90.             Button2.gameObject.SetActive(true);
  91.             Button3.gameObject.SetActive(true);
  92.             Button4.gameObject.SetActive(true);
  93.             Button5.gameObject.SetActive(true);
  94.             Button6.gameObject.SetActive(true);
  95.             TextAgarTerbuka.text = "Score To Unlock: 90";
  96.  
  97.         }
  98.  
  99.     }
  100.  
  101. }
Add Comment
Please, Sign In to add comment