예제 #1
0
    private void GetLevelButtons()
    {
        var lvlButtons = GameObject.Find("LevelButtons").GetComponent <RectTransform>();

        foreach (RectTransform lvlButton in lvlButtons)
        {
            LevelProgressionHandler.Levels levelId = lvlButton.GetComponent <LevelButton>().Level;
            int level = (int)levelId;
            if (level >= 1 && level <= GameData.Instance.Data.LevelData.NumLevels)
            {
                _btnScripts[level] = lvlButton.GetComponent <LevelButton>();

                if (GameData.Instance.Data.LevelData.IsUnlocked(level) || level == 1)
                {
                    _btnScripts[level].SetLevelState(GameData.Instance.Data.LevelData.IsCompleted(level)
                        ? LevelButton.LevelStates.Completed
                        : LevelButton.LevelStates.Enabled);
                }
                else
                {
                    _btnScripts[level].SetLevelState(LevelButton.LevelStates.Disabled);
                }
            }
        }
    }
예제 #2
0
 public bool IsDoubleClicked(LevelProgressionHandler.Levels levelId)
 {
     if (levelId != Level)
     {
         return(false);
     }
     return(_state == BtnState.LoadLevel);
 }
예제 #3
0
    public void UnlockLevel(LevelProgressionHandler.Levels levelId)
    {
        var level = (int)levelId;

        if (level < NumLevels)
        {
            _levelCompletion[level].LevelUnlocked = true;
        }
    }
예제 #4
0
    public void SetCompleted(LevelProgressionHandler.Levels levelId)
    {
        var level         = (int)levelId;
        var lvlCompletion = GameData.Instance.GetLevelCompletion();

        _levelCompletion[level].LevelCompleted |= lvlCompletion.LevelCompleted;
        _levelCompletion[level].SecretPath1    |= lvlCompletion.SecretPath1;
        _levelCompletion[level].SecretPath2    |= lvlCompletion.SecretPath2;
        _levelCompletion[level].Achievement1   |= lvlCompletion.Achievement1;
        _levelCompletion[level].Achievement2   |= lvlCompletion.Achievement2;
        _levelCompletion[level].Achievement3   |= lvlCompletion.Achievement3;
    }
예제 #5
0
    public void LoadBtn()
    {
        if (LevelId == 0)
        {
            return;
        }
        TextAsset levelTxt = (TextAsset)Resources.Load("LevelXML/" + LevelId);

        Level = LevelContainer.LoadFromText(levelTxt.text);
        ClearLevelObjects();
        SetLevelObjects();
        _loadedLevelNum = LevelId;
    }
예제 #6
0
    public void SetLevelText(LevelProgressionHandler.Levels levelId)
    {
        // Note: this must be called by the LevelScript once the level has been set in GameData
        var level = (int)levelId;

        if (level == -1)
        {
            _levelText.text = "Level: Endless";
        }
        else
        {
            _levelText.text = "Level: " + Toolbox.Instance.LevelNames[levelId];
        }
    }
예제 #7
0
    private IEnumerator LoadLevel(LevelProgressionHandler.Levels levelId)
    {
        GameData.Instance.Level = levelId;
        Toolbox.Instance.Debug  = false;
        AsyncOperation levelLoader;

        if (levelId.ToString().Contains("Boss"))
        {
            levelLoader = SceneManager.LoadSceneAsync("Boss");
        }
        else
        {
            levelLoader = SceneManager.LoadSceneAsync("Levels");
        }
        // TODO training

        LoadingOverlay.GetComponent <LoadScreen>().ShowLoadScreen();

        while (!levelLoader.isDone)
        {
            yield return(null);
        }
    }
예제 #8
0
 public void Click(LevelProgressionHandler.Levels levelId)
 {
     if (levelId == Level)
     {
         if (_state == BtnState.Unclicked)
         {
             _namePanel.GetComponent <Image>().enabled = true;
             _levelName.enabled = true;
             SetLevelImage();
             _state = BtnState.Clicked;
         }
         else if (_state == BtnState.Clicked)
         {
             _state = BtnState.LoadLevel;
         }
     }
     else
     {
         _levelName.enabled = false;
         _namePanel.GetComponent <Image>().enabled = false;
         SetLevelImage();
         _state = BtnState.Unclicked;
     }
 }