Exemple #1
0
    void UpdateStat()
    {
        //미리 생성되어 있는 능력치들 hide
        for (int i = 0; i < statSlots.Count; i++)
        {
            statSlots[i].gameObject.SetActive(false);
        }

        List <StatType> keys = heroData.stats.paramDic.Keys.ToList();

        //능력치 슬롯들 생성
        for (int i = 0; i < heroData.stats.paramDic.Count; i++)
        {
            var stat = heroData.stats.GetParam(keys[i]);
            if (stat.baseData == null || stat.baseData.hideInUI)
            {
                continue;
            }

            if (stat.value == 0)
            {
                continue;
            }

            AddStatSlot(stat);
        }

        //index 별로 정렬. 매번 해줘야 하나..
        statSlots = statSlots.OrderBy(x => x.index).ToList();
        for (int i = 0; i < statSlots.Count; i++)
        {
            UIStatSlot s = statSlots[i];
            s.transform.SetSiblingIndex(s.index);
        }
    }
Exemple #2
0
    void AddStatSlot(Stat stat)
    {
        //비활성 슬롯 검색
        UIStatSlot slot = statSlots.Find(x => !x.gameObject.activeSelf);

        //없으면 새로 만듬
        if (slot == null)
        {
            GameObject go = Instantiate(statSlotPrefab, rtContentStat);
            slot = go.GetComponent <UIStatSlot>();
            statSlots.Add(slot);
        }

        slot.Init(stat);
        slot.gameObject.SetActive(true);
    }