Beispiel #1
0
    public void OnclikSelecteLevel(int i)
    {
        currentId = i - 1;

        nameLeveltextEnd.text = string.Format(nameLeveltextTrad.text, currentWorld.ToString(), (currentId + 1).ToString());

        LevelMenu[]  currentList = levelObjMonde1;
        StarPoints[] currenPoint = StarPointsMonde1;
        switch (currentWorld)
        {
        case 2:
            currentList = levelObjMonde2;
            currenPoint = StarPointsMonde2;
            break;

        case 3:
            currentList = levelObjMonde3;
            currenPoint = StarPointsMonde3;
            break;
        }

        if (currentLevel != null)
        {
            if (currentLevel.cubes.Count > 0)
            {
                currentLevel.gameObject.SetActive(false);
            }
        }

        if (currentList.Length > currentId)
        {
            currentLevel = currentList[currentId];
            if (currentLevel != null)
            {
                // info level
                nbcouptextEnd.text    = string.Format(nbcouptextTrad.text, currenPoint[currentId].nbblock);
                nbEnnemietextEnd.text = string.Format(nbEnnemietextTrad.text, currenPoint[currentId].nbenemie);

                // spawn level
                currentLevel.gameObject.SetActive(true);
                currentLevel.LoadLevel();

                if (true)
                {
                    if (stars[0] != null)
                    {
                        stars[0].SetActive(true);
                    }
                    if (stars[1] != null)
                    {
                        stars[1].SetActive(true);
                    }
                    if (stars[2] != null)
                    {
                        stars[2].SetActive(true);
                    }
                }
                /////////////////////////////////////////////////////////////////
                int[] currentListi = new int[0];


                StarPoints[] tmpPointsi = new StarPoints[0];

                switch (currentWorld)
                {
                case 1:
                    currentListi = starsMonde1;
                    tmpPointsi   = StarPointsMonde1;
                    break;

                case 2:
                    currentListi = starsMonde2;
                    tmpPointsi   = StarPointsMonde2;
                    break;

                case 3:
                    currentListi = starsMonde3;
                    tmpPointsi   = StarPointsMonde3;
                    break;
                }

                if (stars[0] != null)
                {
                    stars[0].SetActive(false);
                }
                if (stars[1] != null)
                {
                    stars[1].SetActive(false);
                }
                if (stars[2] != null)
                {
                    stars[2].SetActive(false);
                }

                i = i - 1;
                //Debug.Log(currentListi[i] +" , " + tmpPointsi[i].minPoints2Star + " , " + tmpPointsi[i].minPoints3Star);

                if (currentListi[i] >= 0)
                {
                    if (stars[0] != null)
                    {
                        stars[0].SetActive(true);
                    }

                    if (currentListi[i] <= tmpPointsi[i].minPoints2Star)
                    {
                        if (stars[1] != null)
                        {
                            stars[1].SetActive(true);
                        }

                        if (currentListi[i] <= tmpPointsi[i].minPoints3Star)
                        {
                            if (stars[2] != null)
                            {
                                stars[2].SetActive(true);
                            }
                        }
                    }
                }

                /////////////////////////////////////////////////////////////////
            }
        }
    }