Ejemplo n.º 1
0
    private void Awake()
    {
        //Disable music
        if (Sound.instance != null)
        {
            Sound.instance.GetComponent <AudioSource>().enabled = false;
        }

        currentLevel = PlayerPrefsPersister.GetCurrentLevel();

        levelTimmings = RatingsManager.levelTimmings;
        if (levelTimmings == null || levelTimmings.Count == 0)
        {
            RatingsManager.FillLevels();
        }
        currentLevelTimmings = levelTimmings.Where(l => l.LevelId == currentLevel).FirstOrDefault();

        //add level prefab
        GameObject levelPrefab = Instantiate(levels[currentLevel]);

        levelPrefab.transform.SetParent(levelContainer);
        timerText.enabled = false;

        //if this is the last level -> hide "Next" button;
        if (currentLevel == levels.Count - 1)
        {
            NextBtn.GetComponent <Button>().interactable = false;
        }
    }
Ejemplo n.º 2
0
 //Checks if we need to unblock the next level(only if there ara more levels available && if we are playing the last level unblocked)
 void CheckUnblockLevel()
 {
     if (currentLevel <= PlayerPrefsPersister.GetLevelReached() && currentLevel < levels.Count - 1)
     {
         PlayerPrefsPersister.SetLevelReached(currentLevel + 1);
     }
 }
Ejemplo n.º 3
0
 public void Next()
 {
     //If we load the next level, we need to set timeScale to 1. It's value doesn't reset on loadScene
     SetTimeScale(1);
     PlayerPrefsPersister.SetCurrentLevel(currentLevel + 1);
     SceneManager.LoadScene("LevelScene");
 }
Ejemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        motoEffect = GetComponent <AudioSource>();
        UpdateAudioMotoStatus(PlayerPrefsPersister.GetAudioMotoStatus());

        rigidBody = GetComponent <Rigidbody2D>();
        #region ORIGINAL
        //wheelRadius = rigidBody.GetComponent<CircleCollider2D>().radius * 1.1f;
        #endregion
        #region JOINTS
        wheelRadius = backWheel.GetComponent <CircleCollider2D>().radius * 1.1f;
        #endregion
    }
Ejemplo n.º 5
0
    private void Awake()
    {
        levelTimmings = RatingsManager.levelTimmings;
        if (levelTimmings == null || levelTimmings.Count == 0)
        {
            RatingsManager.FillLevels();
        }
        levelTimmings.OrderBy(l => l.LevelId);
        levelReached = PlayerPrefsPersister.GetLevelReached();

        //if(!Sound.instance.GetComponent<AudioSource>().enabled && PlayerPrefsPersister.GetAudioStatus())
        //{
        //    Sound.instance.GetComponent<AudioSource>().enabled = true;
        //}
    }
Ejemplo n.º 6
0
    public void ToggleSound()
    {
        bool isOn = PlayerPrefsPersister.GetAudioStatus();

        if (!isOn)
        {
            isOn = true;
            PlayerPrefsPersister.SetAudioStatus(isOn.ToString());
        }
        else
        {
            isOn = false;
            PlayerPrefsPersister.SetAudioStatus(isOn.ToString());
        }
        UpdateAudioStatus(isOn);
    }
Ejemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     player.eliminated += Restart;
     player.levelEnd   += End;
     player.enabled     = false;
     mainText           = startButton.GetComponentInChildren <Text>();
     bestTime           = PlayerPrefsPersister.GetLevelBestTime(currentLevel);
     if (bestTime > 0)
     {
         recordText.text = "Best time: " + bestTime.ToString("##.##") + " s";
     }
     else
     {
         recordText.enabled = false;
     }
     //DEBUGGING
     //StartGame();
 }
Ejemplo n.º 8
0
    void End()
    {
        SetTimeScale(0);
        finalTime = (Time.time - initialTime);
        if (finalTime < bestTime || bestTime == 0)
        {
            PlayerPrefsPersister.SetRecord(currentLevel, finalTime);
            bestTime = finalTime;
        }

        //set level stars
        RatingsManager.SetLevelStars(currentLevelTimmings.Timmings, stars, finalTime, starTexts);
        finishMenuTime.text   = finalTime.ToString("##.##") + "s";
        finishMenuRecord.text = bestTime.ToString("##.##") + "s";

        CheckUnblockLevel();

        audioWin.enabled = true;
        audioWin.Play();
        finishMenu.SetActive(true);
    }
Ejemplo n.º 9
0
    void SetLevelButton(GameObject levelButton, bool isUnblocked, RatingsManager.LevelTimmings level = null)
    {
        levelButton.transform.SetParent(levelsPanel);

        //Setting position && anchors
        RectTransform levelButtonRect = levelButton.GetComponent <RectTransform>();

        levelButtonRect.localPosition = new Vector3(0, 0, 0);

        levelButtonRect.anchorMax = new Vector2(offsetXmax, offsetYmax);
        levelButtonRect.anchorMin = new Vector2(offsetXmin, offsetYmin);

        levelButtonRect.offsetMax = new Vector2(0, 0);
        levelButtonRect.offsetMin = new Vector2(0, 0);

        levelButtonRect.localScale = new Vector3(1, 1, 1);

        x          += 170;
        offsetXmax += offsetXincrement;
        offsetXmin += offsetXincrement;

        if (isUnblocked)
        {
            FillListener(levelButton.GetComponentInChildren <Button>(), level.LevelId);
            levelButton.GetComponentInChildren <Text>().text = (level.LevelId + 1).ToString();

            levelBestTime = PlayerPrefsPersister.GetLevelBestTime(level.LevelId);
            stars         = levelButton.GetComponentsInChildren <Image>().Where(s => s.tag == "Star").ToArray();

            //if 'levelBestTime' != 0(to check if at least has been completed 1 time) set the amount of stars the user has got
            if (levelBestTime != 0)
            {
                RatingsManager.SetLevelStars(level.Timmings, stars, levelBestTime);
            }
        }
        else
        {
            levelButton.GetComponent <Button>().interactable = false;
        }
    }
Ejemplo n.º 10
0
 // Use this for initialization
 void Start()
 {
     UpdateAudioStatus(PlayerPrefsPersister.GetAudioStatus());
 }
Ejemplo n.º 11
0
 public void LoadLevel(int level)
 {
     PlayerPrefsPersister.SetCurrentLevel(level);
     SceneManager.LoadScene("LevelScene");
 }