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); } } } }
public bool IsDoubleClicked(LevelProgressionHandler.Levels levelId) { if (levelId != Level) { return(false); } return(_state == BtnState.LoadLevel); }
public void UnlockLevel(LevelProgressionHandler.Levels levelId) { var level = (int)levelId; if (level < NumLevels) { _levelCompletion[level].LevelUnlocked = true; } }
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; }
public void LoadBtn() { if (LevelId == 0) { return; } TextAsset levelTxt = (TextAsset)Resources.Load("LevelXML/" + LevelId); Level = LevelContainer.LoadFromText(levelTxt.text); ClearLevelObjects(); SetLevelObjects(); _loadedLevelNum = LevelId; }
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]; } }
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); } }
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; } }