Exemplo n.º 1
0
    public IEnumerator getLearningBadges()
    {
        ClickBtn.Play();
        yield return(new WaitForSeconds(0.1f));

        LearningPanel.SetActive(true);
        CompetePanel.SetActive(false);

        Text _badgeName;//獎章名稱

        _badgeBtn    = new Button[learningBadgeCount];
        _targetLevel = xmlprocess.getAchieveLearningBadges(learningBadgeCount);

        for (int i = 1; i <= learningBadgeCount; i++)
        {
            _badgeBtn[i - 1] = LearningBadge.GetComponentsInChildren <Button>()[i - 1]; //存取學習區的所有獎章物件
            _badgeName       = _badgeBtn[i - 1].GetComponentsInChildren <Text>()[0];    //獎章名稱
            _badgeName.text  = badgeName[i - 1];                                        //因為陣列索引直起始為0,故要減1

            switch (_targetLevel[i - 1] - 1)                                            //當前階段
            {
            case 0:
                _badgeBtn[i - 1].image.sprite = _badgeBtn[i - 1].image.sprite = Resources.Load <Sprite>("Image/Main/null");
                break;

            case 1:
                _badgeBtn[i - 1].image.sprite = _badgeBtn[i - 1].image.sprite = Resources.LoadAll <Sprite>("Image/Main/bg")[2];
                _badgeBtn[i - 1].GetComponentsInChildren <Image>()[1].color = Color.white;
                break;

            case 2:
                _badgeBtn[i - 1].image.sprite = _badgeBtn[i - 1].image.sprite = Resources.LoadAll <Sprite>("Image/Main/bg")[1];
                _badgeBtn[i - 1].GetComponentsInChildren <Image>()[1].color = Color.white;

                break;

            case 3:
                _badgeBtn[i - 1].image.sprite = _badgeBtn[i - 1].image.sprite = Resources.LoadAll <Sprite>("Image/Main/bg")[0];
                _badgeBtn[i - 1].GetComponentsInChildren <Image>()[1].color = Color.white;

                break;
            }
        }

        _badgeBtn[0].onClick.AddListener(delegate() { showDescription(1, _targetLevel[0]); });
        _badgeBtn[1].onClick.AddListener(delegate() { showDescription(2, _targetLevel[1]); });
        _badgeBtn[2].onClick.AddListener(delegate() { showDescription(3, _targetLevel[2]); });
        _badgeBtn[3].onClick.AddListener(delegate() { showDescription(4, _targetLevel[3]); });
        _badgeBtn[4].onClick.AddListener(delegate() { showDescription(5, _targetLevel[4]); });
    }