Beispiel #1
0
    public void InitStageSelectionView(StageSeriesData stageSeriesData)
    {
        stageSelectionView.gameObject.SetActive(true);
        foreach (GameObject o in stageIcons)
        {
            o.SetActive(false);
        }
        UnityEngine.Assertions.Assert.IsTrue(gm.IsSeriesUnlocked(stageSeriesData.seriesName));
        int numStagesUnlocked = gm.NumStagesUnlocked(stageSeriesData.seriesName);
        int iconIndex         = 0;                                                              // Used to track the number of icons in the scene, and add more if needed

        for (int i = 0; i < numStagesUnlocked; i++)
        {
            GameObject o;
            if (iconIndex >= stageIcons.Count)
            {
                // Instantiate and initialize a new stage icon prefab
                o = Instantiate(stageIconPrefab);
                stageIcons.Add(o);
                StageIcon icon = o.GetComponent <StageIcon>();
                //icon.highlightMenu.GetComponent<Button>().onClick.AddListener(() => DeselectStageIcon());
            }
            else
            {
                o = stageIcons[iconIndex];
            }
            o.transform.SetParent(stageIconFolder, false);
            o.SetActive(true);

            StageData stageData = stageSeriesData.stages[i];
            StageIcon stageIcon = o.GetComponent <StageIcon>();
            stageIcon.seriesIndex = stageSeriesData.index;
            stageIcon.stageIndex  = i;
            stageIcon.onClicked   = SelectStageIcon;
            stageIcon.Init(stageData);
            iconIndex++;
        }
    }
 public void Init(StageSeriesData data)
 {
     this.data   = data;
     icon.sprite = data.icon;
 }