コード例 #1
0
    public void Activate(int collectedStars, int maxStars)
    {
        // gameObject.SetActive(false);
        deactivateOnVictory.SetActive(false);
        deactivateOnVictory2.SetActive(false);
        Time.timeScale = 0;
        for (int i = 0; i < maxStars; i++)
        {
            GameObject star = Instantiate(starPrefab);
            star.transform.SetParent(starPanel.transform);
            star.transform.localScale         = new Vector3(1f, 1f, 1f);
            star.GetComponent <Image>().color = i < collectedStars ? activeStarColor : inactiveStarColor;
        }
        gameObject.SetActive(true);
        GetComponent <AudioSource>().PlayOneShot(victoryTune);
        AudioController.ac.BackgroundVolume();
        StarController sc = StarController.sc;


        if (sc.GetLevelIndex(SceneData.sd.levelID) >= sc.starData.allStars.Count - 1) // you beat the game. somehow
        {
            //nextLevelButton.GetComponent<Image>().color = new Color(.3f, .3f, .3f, 1f);
            nextLevelButton.GetComponent <Button>().interactable = false;
            nextLevelButton.transform.GetChild(0).gameObject.SetActive(false);

            starPanel.SetActive(false);
            congratulatoryText.text = "Thanks for playing!";
        }
        else if (sc.starData.TotalStarsGotten() < sc.starData.allStars[sc.GetLevelIndex(SceneData.sd.levelID) + 1].starRequirement)
        {
            //nextLevelButton.GetComponent<Image>().color = new Color(.3f, .3f, .3f, 1f);
            nextLevelButton.GetComponent <Button>().interactable = false;
            nextLevelButton.transform.GetChild(0).gameObject.SetActive(false);
        }
        StartCoroutine(Entrance());
    }
コード例 #2
0
    public void NextLevel()
    {
        StarController sc = StarController.sc;

        AudioController.ac.ForegroundVolume();

        int levelIndex = sc.GetLevelIndex(SceneData.sd.levelID);

        levelIndex += 1;
        Debug.Log("Incremented level index : " + levelIndex.ToString());
        if (levelIndex >= sc.starData.allStars.Count || sc.starData.TotalStarsGotten() < sc.starData.allStars[levelIndex].starRequirement)
        {
            //BackToMenu();
            return;
        }
        SceneData.sd.levelID = sc.starData.allStars[levelIndex].levelId;
        sc.LoadStarData();
        Transition.t.FadeToScene(1);
    }
コード例 #3
0
    public void ReachGoal()
    {
        StarController sc = StarController.sc;

        if (sc != null)
        {
            sc.SaveStarData();
        }
        int curLvl = sc.GetLevelIndex(SceneData.sd.levelID);

        SceneData.sd.goToLevelSelect = true;
        audio.Stop();
        foreach (HeadToggle h in FindObjectsOfType(typeof(HeadToggle)))
        {
            h.GetComponent <AudioSource>().volume = 0;
        }
        VictoryOverlay.vo.Activate(sc.CollectedStarsInLevel(curLvl), sc.TotalStarsInLevel(curLvl));
        //VictoryOverlay.vo.Activate(1,4);
        //SceneManager.LoadScene (0);
    }