/* public GameObject Sstage2, Sstage3, Sstage4, Sstage5; * public GameObject Gstage2, Gstage3, Gstage4, Gstage5; * public GameObject Pstage2, Pstage3, Pstage4, Pstage5; * public GameObject Dstage2, Dstage3, Dstage4, Dstage5;*/ void Start() { string hh = PlayerPrefs.GetString("currentStage"); print("STAGELEVEL::::: " + hh + " :::::::"); int world = Int32.Parse(hh.Substring(0, 1)); int stage = Int32.Parse(hh.Substring(2, 1)); switch (stage) { case 2: Bstage2.SetActive(false); break; case 3: Bstage2.SetActive(false); Bstage3.SetActive(false); break; case 4: Bstage2.SetActive(false); Bstage3.SetActive(false); Bstage4.SetActive(false); break; case 5: Bstage2.SetActive(false); Bstage3.SetActive(false); Bstage4.SetActive(false); Bstage5.SetActive(false); break; } }
// This fuction will unlock and change sprite depending on the world and stage that they are currently in // For example if player is beyond world 1 all the stages will be unlock OR if player is in this stage but // yet to complete the remaining stage certain will not be unlocked // Start is called before the first frame update void Start() { hh = PlayerPrefs.GetString("originalState"); ll = PlayerPrefs.GetString("selectedWorld"); world = Int32.Parse(hh.Substring(0, 1)); stage = Int32.Parse(hh.Substring(2, 1)); sworld = Int32.Parse(ll.Substring(0, 1)); if (world > 1) { Bstage2.SetActive(false); Bstage3.SetActive(false); Bstage4.SetActive(false); Bstage5.SetActive(false); GameObject.Find("Stage 1").GetComponent <Image>().sprite = Complete; GameObject.Find("Stage 2").GetComponent <Image>().sprite = Complete; GameObject.Find("Stage 3").GetComponent <Image>().sprite = Complete; GameObject.Find("Stage 4").GetComponent <Image>().sprite = Complete; GameObject.Find("Stage 5").GetComponent <Image>().sprite = Complete; GameObject.Find("Stage 1").GetComponent <Button>().onClick.AddListener(() => ButtonClicked(1)); GameObject.Find("Stage 2").GetComponent <Button>().onClick.AddListener(() => ButtonClicked(2)); GameObject.Find("Stage 3").GetComponent <Button>().onClick.AddListener(() => ButtonClicked(3)); GameObject.Find("Stage 4").GetComponent <Button>().onClick.AddListener(() => ButtonClicked(4)); GameObject.Find("Stage 5").GetComponent <Button>().onClick.AddListener(() => ButtonClicked(5)); } else { switch (stage) { case 1: break; case 2: GameObject.Find("Stage 1").GetComponent <Image>().sprite = Complete; Bstage2.SetActive(false); break; case 3: GameObject.Find("Stage 1").GetComponent <Image>().sprite = Complete; GameObject.Find("Stage 2").GetComponent <Image>().sprite = Complete; Bstage2.SetActive(false); Bstage3.SetActive(false); break; case 4: GameObject.Find("Stage 1").GetComponent <Image>().sprite = Complete; GameObject.Find("Stage 2").GetComponent <Image>().sprite = Complete; GameObject.Find("Stage 3").GetComponent <Image>().sprite = Complete; Bstage2.SetActive(false); Bstage3.SetActive(false); Bstage4.SetActive(false); break; case 5: GameObject.Find("Stage 1").GetComponent <Image>().sprite = Complete; GameObject.Find("Stage 2").GetComponent <Image>().sprite = Complete; GameObject.Find("Stage 3").GetComponent <Image>().sprite = Complete; GameObject.Find("Stage 4").GetComponent <Image>().sprite = Complete; Bstage2.SetActive(false); Bstage3.SetActive(false); Bstage4.SetActive(false); Bstage5.SetActive(false); break; } GameObject.Find("Stage 1").GetComponent <Button>().onClick.AddListener(() => ButtonClicked(1)); GameObject.Find("Stage 2").GetComponent <Button>().onClick.AddListener(() => ButtonClicked(2)); GameObject.Find("Stage 3").GetComponent <Button>().onClick.AddListener(() => ButtonClicked(3)); GameObject.Find("Stage 4").GetComponent <Button>().onClick.AddListener(() => ButtonClicked(4)); GameObject.Find("Stage 5").GetComponent <Button>().onClick.AddListener(() => ButtonClicked(5)); } }