Exemplo n.º 1
0
    /// <summary>
    /// 刷新总生命值
    /// </summary>
    void RefreshTotalLife()
    {
        for (int i = 0; i < togList.Count; i++)
        {
            AchievementTogUI togUI = togList[i].GetComponent <AchievementTogUI>();
            if (togUI != null && achieveTypeDic.ContainsKey(i + 1))
            {
                togUI.SetTogData(achieveTypeDic[i + 1] as AchieveTypeRef, i);
            }
        }
        int totalNum = 0;

        foreach (int data in AchieveNumDic.Values)
        {
            totalNum += data;
        }
        if (currNum != null)
        {
            currNum.text = (totalNum * 1000).ToString();
        }
        if (progressSlider != null)
        {
            progressSlider.value = (float)(totalNum * 1000) / 75000;
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 创建Toggle和Item
    /// </summary>
    void CreateTogAndItem()
    {
        int index = 0;

        HideAllToggle();
        foreach (AchieveTypeRef data in achieveTypeDic.Values)
        {
            GameObject go = null;
            if (togList.Count < achieveTypeDic.Count)
            {
                go = Instantiate(togGo) as GameObject;
                togList.Add(go.GetComponent <UIToggle>());
            }
            go = togList[index].gameObject;
            go.transform.parent        = togGo.transform.parent;
            go.transform.localPosition = new Vector3(-253 + index * 105, 2.5f, 0f);
            go.transform.localScale    = Vector3.one;
            AchievementTogUI achievementTogUI = go.GetComponent <AchievementTogUI>();
            if (achievementTogUI != null)
            {
                achievementTogUI.SetTogData(data, index);
            }
            //创建Item
            HideAllItem();
            if (itemGird != null)
            {
                itemGird.maxPerLine = data.numId.Count;
            }
            for (int i = 0; i < data.numId.Count; i++)
            {
                GameObject item = null;
                if (itemList.Count < data.numId.Count)
                {
                    item = Instantiate(itemGo) as GameObject;
                    itemList.Add(item);
                }
                item = itemList[i];
                item.transform.parent        = itemGo.transform.parent;
                item.transform.localPosition = Vector3.zero;
                item.transform.localScale    = Vector3.one;
                item.SetActive(true);
            }
            if (itemGird != null)
            {
                itemGird.repositionNow = true;
            }
            index++;
            go.SetActive(true);
        }
    }