private void Spawn(LevelData lvlData) { LevelButtonComponent lvlBtnComponent = Instantiate(lvlBtnPrefab, parent); lvlBtnComponent.SetConfig(lvlData); lvlBtnComponent.OnLevelButtonClicked += HandleOnLevelButtonClicked; }
public void OnClickButtonLevel(LevelButtonComponent levelButtonComponent) { this.currentlySelectedProblem = levelButtonComponent.representedProblem; this.currentLevel = int.Parse(levelButtonComponent.text.text); this.UpdateInfoPanel(); Player.selectedProblem = this.currentlySelectedProblem; this.isAGameRunning = false; this.startGameButtonText.text = "Start new"; this.levelChoicePanel.SetActive(false); this.actionChoicePanel.SetActive(true); }
private void GenerateLevelsInLevelPanel(Problem selectedProblem) { for (int i = 0; i < this.levelButtonContainer.transform.childCount; i++) { Destroy(this.levelButtonContainer.transform.GetChild(i).gameObject); } foreach (var level in Player.playerProgressData[selectedProblem].levels) { if (level.Value) { GameObject newLevelButton = (GameObject)Instantiate(this.levelButtonPrefab, Vector3.zero, new Quaternion(0, 0, 0, 0)); newLevelButton.transform.SetParent(this.levelButtonContainer.transform); LevelButtonComponent newProblemButtonComponent = newLevelButton.GetComponent <LevelButtonComponent>(); newProblemButtonComponent.text.text = level.Key.ToString(); newProblemButtonComponent.representedProblem = selectedProblem; } } }