示例#1
0
    void FillList()
    {
        foreach (var level in LevelList)
        {
            GameObject     newbutton      = Instantiate(button) as GameObject;
            LevelButtonNew levelButtonNew = newbutton.GetComponent <LevelButtonNew>();
            levelButtonNew.LevelText.text = level.LevelText;

            if (PlayerPrefs.GetInt("Level" + levelButtonNew.LevelText.text) == 1)
            {
                level.Unlocked       = 1;
                level.IsInteractable = true;
            }

            if (level.Unlocked == 0)
            {
                levelButtonNew.Locked.SetActive(true);
            }

            else
            {
                levelButtonNew.Locked.SetActive(false);
            }

            levelButtonNew.unlocked = level.Unlocked;
            levelButtonNew.GetComponent <Button>().interactable = level.IsInteractable;
            levelButtonNew.GetComponent <Button>().onClick.AddListener(() => loadLevels("Level" + levelButtonNew.LevelText.text));

            if (PlayerPrefs.GetInt("Level" + levelButtonNew.LevelText.text + "_points") > (15 + (int.Parse(levelButtonNew.LevelText.text) * 200f)))
            {
                levelButtonNew.Star1.SetActive(true);
                levelButtonNew.Star2.SetActive(false);
                levelButtonNew.Star3.SetActive(false);
            }
            if (PlayerPrefs.GetInt("Level" + levelButtonNew.LevelText.text + "_points") > (1000 + (int.Parse(levelButtonNew.LevelText.text) * 200f)))
            {
                levelButtonNew.Star1.SetActive(false);
                levelButtonNew.Star2.SetActive(true);
                levelButtonNew.Star3.SetActive(false);
            }

            if (PlayerPrefs.GetInt("Level" + levelButtonNew.LevelText.text + "_points") > (2000 + (int.Parse(levelButtonNew.LevelText.text) * 200f)))
            {
                levelButtonNew.Star1.SetActive(false);
                levelButtonNew.Star2.SetActive(false);
                levelButtonNew.Star3.SetActive(true);
            }

            newbutton.transform.SetParent(Spacer, false);
        }

        SaveAll();
    }
示例#2
0
    void FillList()
    {
        foreach (var level in LevelList)
        {
            //instantiate level buttons

            GameObject     newButton    = Instantiate(button) as GameObject;
            LevelButtonNew buttonScript = newButton.GetComponent <LevelButtonNew>();
            buttonScript.buttonText.text = level.levelText;
            if (PlayerPrefs.GetInt("Level Complete") >= level.unlocked)
            {
                level.isInteractable = true;
            }


            //If Level complete is high enough, button will be interactable

            buttonScript.unlock = level.unlocked;
            buttonScript.GetComponent <Button> ().interactable = level.isInteractable;
            buttonScript.GetComponent <Button>().onClick.AddListener(() =>
                                                                     SceneManager.LoadScene("Level" + level.levelText));

            //Stars earned on each level will be yellow

            if (PlayerPrefs.GetInt("Level" + level.levelText + "stars") >= 1)
            {
                buttonScript.star1.SetActive(true);
            }
            if (PlayerPrefs.GetInt("Level" + level.levelText + "stars") >= 2)
            {
                buttonScript.star2.SetActive(true);
            }
            if (PlayerPrefs.GetInt("Level" + level.levelText + "stars") >= 3)
            {
                buttonScript.star3.SetActive(true);
            }

            newButton.transform.SetParent(spacer, false);
        }
        SaveAll();
    }
示例#3
0
    void FillList()
    {
        foreach (var level in LevelList)
        {
            GameObject     newButton = Instantiate(levelButton) as GameObject;
            LevelButtonNew button    = newButton.GetComponent <LevelButtonNew>();
            button.LevelText.text = level.LevelText;

            // If the the level is unlocked then load it
            if (PlayerPrefs.GetInt("level" + button.LevelText.text) == 1)
            {
                level.UnLocked       = 1;
                level.isInteractable = true;
            }

            button.unlocked = level.UnLocked;
            button.GetComponent <Button>().interactable = level.isInteractable;
            button.GetComponent <Button>().onClick.AddListener(() => loadLevels("level" + button.LevelText.text));
            newButton.transform.SetParent(Spacer, false);
        }
        SaveAll();
    }
示例#4
0
    void FillList()
    {
        foreach (var level in LevelList)        // This sets the information in the level buttons that are generated, is lined to LevelButtonNew script
        {
            GameObject     newbutton = Instantiate(levelButton) as GameObject;
            LevelButtonNew button    = newbutton.GetComponent <LevelButtonNew> ();
            button.LevelText.text = level.LevelText;

            if (PlayerPrefs.GetInt("Level" + button.LevelText.text) == 1)             //this if statement unlocked the first level when a player opens the game for the first time
            {
                level.UnLocked       = 1;
                level.IsInteractable = true;
            }

            button.unlocked = level.UnLocked;
            button.GetComponent <Button> ().interactable = level.IsInteractable;
            button.GetComponent <Button> ().onClick.AddListener(() => loadLevels("Level" + button.LevelText.text));               //loads a level based on the name that the scene has been saved as

            if (PlayerPrefs.GetInt("Level" + button.LevelText.text + "_score") > 0)
            {
                button.star1.SetActive(true);
            }

            if (PlayerPrefs.GetInt("Level" + button.LevelText.text + "_score") > 5000)
            {
                button.star2.SetActive(true);
            }

            if (PlayerPrefs.GetInt("Level" + button.LevelText.text + "_score") > 9999)
            {
                button.star3.SetActive(true);
            }

            newbutton.transform.SetParent(Spacer, false);
        }

        SaveAll();
    }
    void FillList()
    {
        foreach (var level in LevelList)
        {
            GameObject     newbutton = Instantiate(levelButton) as GameObject;
            LevelButtonNew button    = newbutton.GetComponent <LevelButtonNew>();
            button.LevelText.text = level.LevelText;
            //Level1, Level2, Level3, Level4,

            if (PlayerPrefs.GetInt("Level" + button.LevelText.text) == 1)
            {
                level.UnLocked       = 1;
                level.IsInteractable = true;
            }

            button.unlocked = level.UnLocked;
            button.GetComponent <Button>().interactable = level.IsInteractable;
            button.GetComponent <Button>().onClick.AddListener(() => loadLevels("Level" + button.LevelText.text));

            if (PlayerPrefs.GetInt("Level" + button.LevelText.text + "_score") > 0)
            {
                button.Star1.SetActive(true);
            }
            if (PlayerPrefs.GetInt("Level" + button.LevelText.text + "_score") >= 30)
            {
                button.Star2.SetActive(true);
            }
            if (PlayerPrefs.GetInt("Level" + button.LevelText.text + "_score") >= 50)
            {
                button.Star3.SetActive(true);
            }


            newbutton.transform.SetParent(Spacer);
        }
        SaveAll();
    }