Ejemplo n.º 1
0
 private void DeselectCurrentItem()
 {
     if (selected != null) // Is there a selected item currently?
     {
         selected.GetComponent <Image>().sprite = outlineUnselectedSprite;
         selected = null;
     }
 }
Ejemplo n.º 2
0
    IEnumerator pickDefault()
    {
        yield return(null);

        EventSystem.current.SetSelectedGameObject(null);
        yield return(null);

        EventSystem.current.SetSelectedGameObject(defaultItem.gameObject);
        yield return(null);

        defaultItem.GetComponent <Button>().Select();
    }
Ejemplo n.º 3
0
    public void SelectItem(LevelSelectItem item)
    {
        if (item != selected)
        {
            DeselectCurrentItem();

            // Update selected item
            selected = item;
            selected.GetComponent <Image>().sprite = outlineSelectedSprite;

            // Update overview board
            overviewName.text = item.levelName;

            // Update best time
            int time = PlayerPrefs.GetInt("best-time-level" + item.levelIndex, -1);
            if (time != -1)
            {
                string minutes = (time / 60).ToString();
                string seconds = (time % 60).ToString("00");
                overviewTime.text = string.Format("{0}:{1}", minutes, seconds); // Update timer count.
            }
            else
            {
                overviewTime.text = "--";
            }

            // Update high score
            int score = PlayerPrefs.GetInt("high-score-level" + item.levelIndex, -1);
            if (score != -1)
            {
                overviewScore.text = score.ToString();
            }
            else
            {
                overviewScore.text = "--";
            }

            overview.SetActive(true);

            // Play selection sound
            asource.Play();
        }
    }