Ejemplo n.º 1
0
 private void GetLevelBtnSprite()
 {
     foreach (GameObject fooObj in GameObject.FindGameObjectsWithTag("LevelBtn"))
     {
         LevelBtn.Add(fooObj);
     }
     foreach (GameObject fooObj in GameObject.FindGameObjectsWithTag("LevelLockBtn"))
     {
         LevelLockBtn.Add(fooObj);
     }
 }
Ejemplo n.º 2
0
    public void CheckLevelUnLock()
    {
        switch (PlayerPrefs.GetInt("currentMode"))
        {
        case 1:

            UnlockLevelNum = PlayerPrefs.GetInt("CarLevelUnlocked");

            if (PlayerPrefs.GetInt("Unlocked_All_Cars_Levels") == 1)
            {
                UnlockLevelNum = 29;
                PlayerPrefs.SetInt("CarLevelUnlocked", 29);
                Level_IAP.SetActive(false);
            }
            else
            {
                Level_IAP.SetActive(true);
            }
            break;

        case 2:
            UnlockLevelNum = PlayerPrefs.GetInt("ConeLevelUnlocked");
            if (PlayerPrefs.GetInt("Unlocked_All_Cones_Levels") == 1)
            {
                UnlockLevelNum = 29;
                PlayerPrefs.SetInt("ConeLevelUnlocked", 29);
                Level_IAP.SetActive(false);
            }
            else
            {
                Level_IAP.SetActive(true);
            }
            break;

        case 3:
            UnlockLevelNum = PlayerPrefs.GetInt("BlockLevelUnlocked");
            if (PlayerPrefs.GetInt("Unlocked_All_Blocks_Levels") == 1)
            {
                UnlockLevelNum = 29;
                PlayerPrefs.SetInt("BlockLevelUnlocked", 29);
                Level_IAP.SetActive(false);
            }
            else
            {
                Level_IAP.SetActive(true);
            }
            break;
        }

        foreach (GameObject Lock in LevelLockBtn)
        {
            if (UnlockLevelNum >= LevelLockBtn.IndexOf(Lock))
            {
                LevelBtn[LevelLockBtn.IndexOf(Lock)].gameObject.GetComponent <Button>().enabled = false;
                Lock.gameObject.GetComponent <Button>().interactable = true;
                LevelBtn[LevelLockBtn.IndexOf(Lock)].GetComponent <Image>().sprite = LevelUnlock;
                LevelBtn[LevelLockBtn.IndexOf(Lock)].GetComponent <Image>().color  = Color.white;
                LevelLockBtn[LevelLockBtn.IndexOf(Lock)].transform.GetChild(2).GetComponent <Text>().color = Color.white;
            }
            else
            {
                LevelBtn[LevelLockBtn.IndexOf(Lock)].gameObject.GetComponent <Button>().enabled = true;
                Lock.gameObject.GetComponent <Button>().interactable = false;
                LevelBtn[LevelLockBtn.IndexOf(Lock)].GetComponent <Image>().sprite = LevelLock;
                LevelBtn[LevelLockBtn.IndexOf(Lock)].GetComponent <Image>().color  = Color.white;
                LevelLockBtn[LevelLockBtn.IndexOf(Lock)].transform.GetChild(2).GetComponent <Text>().color = Color.black;
            }
            LevelLockBtn[LevelLockBtn.IndexOf(Lock)].transform.GetChild(0).gameObject.SetActive(false);
        }
        LevelBtn[UnlockLevelNum].GetComponent <Image>().sprite = CurrentUnlockLevel;
        LevelBtn[UnlockLevelNum].GetComponent <Image>().color  = Color.green;
        LevelLockBtn[UnlockLevelNum].transform.GetChild(0).gameObject.SetActive(true);
        LevelLockBtn[UnlockLevelNum].transform.GetChild(2).GetComponent <Text>().color = Color.black;
        ModeLevelFill();
        CheckModeUnlock();//if purchase all level if user back

        levelReward();
    }