Ejemplo n.º 1
0
    public void Refresh(LevelDifficulty level_difficulty)
    {
        var datas       = GameControl.Instance.game_data.GetLevelDatas(level_difficulty);
        int child_count = this._level_parent.transform.childCount;

        if (child_count < datas.Count)
        {
            for (int i = 0; i < datas.Count - child_count; i++)
            {
                UILevelItem item = UILevelItem.Create(this._level_parent);
                this.level_items.Add(item);
            }
        }

        for (int i = 0; i < this.level_items.Count; i++)
        {
            this.level_items[i].gameObject.SetActive(false);
        }
        int index = 0;

        foreach (var item in datas)
        {
            this.level_items[index].Init(item.Value);
            this.level_items[index].gameObject.SetActive(true);
            index++;
        }
    }
    public TableViewCell tableCellAtIndex(UIGridView table, TableViewCell cell, int idx)
    {
        UILevelTableViewCell itemCell      = cell as UILevelTableViewCell;
        UILevelItem          m_UILevelItem = null;

        if (itemCell == null)
        {
            itemCell              = new UILevelTableViewCell();
            m_UILevelItem         = UILevelItem.Create();
            itemCell._UILevelItem = m_UILevelItem;
            FlushItem(m_UILevelItem, idx);
            EventTriggerClick.Get(m_UILevelItem.gameObject).onClick = (o) =>
            {
                SelectItem(table, m_UILevelItem, itemCell.Idx);
            };
        }
        else
        {
            m_UILevelItem = itemCell._UILevelItem;
            FlushItem(m_UILevelItem, idx);
        }
        return(itemCell);
    }