Exemple #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]); });
    }
Exemple #2
0
    void getCompeteBadges()
    {
        ClickBtn.Play();
        LearningPanel.SetActive(false);
        CompetePanel.SetActive(true);

        Text _badgeName;//獎章名稱

        _badgeBtn    = new Button[competeBadgeCount];
        _targetLevel = xmlprocess.getAchieveCompeteBadges(learningBadgeCount + 1, learningBadgeCount + competeBadgeCount);

        for (int i = 1; i <= competeBadgeCount; i++)
        {
            _badgeBtn[i - 1] = CompeteBadge.GetComponentsInChildren <Button>()[i - 1]; //存取學習區的所有獎章物件
            _badgeName       = _badgeBtn[i - 1].GetComponentsInChildren <Text>()[0];   //獎章名稱
            _badgeName.text  = badgeName[(learningBadgeCount - 1) + i];                //因為陣列0~learningBadgeCount-1存放值為學習區的Badge名稱,因此在此起始值為learningBadgeCount

            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")[5];
                _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")[4];
                _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")[3];
                _badgeBtn[i - 1].GetComponentsInChildren <Image>()[1].color = Color.white;

                break;
            }
        }
        _badgeBtn[0].onClick.AddListener(delegate() { showDescription(6, _targetLevel[0]); });
        _badgeBtn[1].onClick.AddListener(delegate() { showDescription(7, _targetLevel[1]); });
        _badgeBtn[2].onClick.AddListener(delegate() { showDescription(8, _targetLevel[2]); });
        _badgeBtn[3].onClick.AddListener(delegate() { showDescription(9, _targetLevel[3]); });
        _badgeBtn[4].onClick.AddListener(delegate() { showDescription(10, _targetLevel[4]); });
        _badgeBtn[5].onClick.AddListener(delegate() { showDescription(11, _targetLevel[5]); });
        _badgeBtn[6].onClick.AddListener(delegate() { showDescription(12, _targetLevel[6]); });
    }
Exemple #3
0
    void Start()
    {
        g_badgeDescription = GameObject.FindGameObjectsWithTag("badgeDescription");//抓取所有獎章描述的物件
        for (int i = 0; i < g_badgeDescription.Length; i++)
        {
            g_badgeDescription[i].gameObject.SetActive(false);//隱藏全部
        }
        LearningPanel.SetActive(true);
        CompetePanel.SetActive(false);
        ClickBtn = GetComponent <AudioSource>();

        StartCoroutine(getLearningBadges());//預設顯示學習區
        btn_learningBadge.onClick.AddListener(delegate() { StartCoroutine(getLearningBadges()); });
        btn_competeBadge.onClick.AddListener(getCompeteBadges);
        btn_close.onClick.AddListener(closeAchieveUI);

        for (int i = 0; i < s_LearningState.Length; i++)
        {
            LearningState.GetComponentsInChildren <Text>()[i].text = s_LearningState[i];
            CompeteState.GetComponentsInChildren <Text>()[i].text  = s_CompeteState[i];
        }
    }