Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- public class UnlockCars : MonoBehaviour
- {
- private GameObject GameMaster;
- private float currentHighScore;
- // ****** Bikin references untuk Button2 nya ******
- public Button Button0;
- public Button Button1;
- public Button Button2;
- public Button Button3;
- public Button Button4;
- public Button Button5;
- public Button Button6;
- public Text TextAgarTerbuka;
- // Use this for initialization
- private void Start()
- {
- // ***** Bikin Referesi ke Game Master *****
- // ambil currentHighScore yg terekam di GameMaster.highscore;
- GameMaster = GameObject.Find("GameMaster");
- currentHighScore = GameMaster.GetComponent<GameMaster>().highScore;
- CarUnlock();
- }
- public void CarUnlock()
- {
- // ***** kalau currentHighScore nya dibawah 20, set active button 0 saja. dan kasih kata2 score to unlock 30 *****
- if (currentHighScore < 20)
- {
- Button0.gameObject.SetActive(true);
- TextAgarTerbuka.text = "Score To Unlock: 30";
- } // ***** kalau currentHighScore nya dibawah atau sama dengan 30 , set active button0 sama button1. dan kasih kata2 score to unlock 40 *****
- else if (currentHighScore <= 30)
- {
- Button0.gameObject.SetActive(true);
- Button1.gameObject.SetActive(true);
- TextAgarTerbuka.text = "Score To Unlock: 40";
- }
- // ***** dan seterusnya *****
- else if (currentHighScore <= 40)
- {
- Button0.gameObject.SetActive(true);
- Button1.gameObject.SetActive(true);
- Button2.gameObject.SetActive(true);
- TextAgarTerbuka.text = "Score To Unlock: 50";
- }
- else if (currentHighScore <= 50)
- {
- Button0.gameObject.SetActive(true);
- Button1.gameObject.SetActive(true);
- Button2.gameObject.SetActive(true);
- Button3.gameObject.SetActive(true);
- TextAgarTerbuka.text = "Score To Unlock: 60";
- }
- else if(currentHighScore <= 60)
- {
- Button0.gameObject.SetActive(true);
- Button1.gameObject.SetActive(true);
- Button2.gameObject.SetActive(true);
- Button3.gameObject.SetActive(true);
- Button4.gameObject.SetActive(true);
- TextAgarTerbuka.text = "Score To Unlock: 70";
- }
- else if (currentHighScore <= 70)
- {
- Button0.gameObject.SetActive(true);
- Button1.gameObject.SetActive(true);
- Button2.gameObject.SetActive(true);
- Button3.gameObject.SetActive(true);
- Button4.gameObject.SetActive(true);
- Button5.gameObject.SetActive(true);
- TextAgarTerbuka.text = "Score To Unlock: 80";
- }
- else if (currentHighScore <= 80)
- {
- Button0.gameObject.SetActive(true);
- Button1.gameObject.SetActive(true);
- Button2.gameObject.SetActive(true);
- Button3.gameObject.SetActive(true);
- Button4.gameObject.SetActive(true);
- Button5.gameObject.SetActive(true);
- Button6.gameObject.SetActive(true);
- TextAgarTerbuka.text = "Score To Unlock: 90";
- }
- }
- }
Add Comment
Please, Sign In to add comment