示例#1
0
    private void UpdateItemList(int index, bool resetOldIndex = false)
    {
        if (resetOldIndex)
        {
            this.oldIndex = -1;
        }
        if (this.oldIndex == index)
        {
            return;
        }
        int num = index;

        while (true)
        {
            if (this.m_taskData != null)
            {
                if (num >= this.m_taskData.Count)
                {
                    break;
                }
            }
            else if (num >= this.m_dailyData.Count)
            {
                break;
            }
            if (num == index + 6)
            {
                break;
            }
            if (num >= this.taskItemList.Count)
            {
                GameObject gameObject = NGUITools.AddChild(this.m_Panel.gameObject, this.taskItemPre);
                gameObject.name = num.ToString();
                TaskItem taskItem = gameObject.GetComponent <TaskItem>();
                this.taskItemList.Add(taskItem);
                gameObject.transform.localPosition = new Vector3(0f, (float)(-(float)num) * this.itemOffY, 0f);
                if (this.m_taskData != null)
                {
                    taskItem.InitData(this.m_taskData[num], null);
                }
                else
                {
                    taskItem.InitData(null, this.m_dailyData[num]);
                }
                UIEventListener.Get(taskItem.getRewardBtn.gameObject).onClick = new UIEventListener.VoidDelegate(this.OnClickGetReward);
            }
            else
            {
                TaskItem   taskItem   = this.taskItemList[num];
                GameObject gameObject = taskItem.gameObject;
                if (this.oldIndex == -1)
                {
                    if (this.m_taskData != null)
                    {
                        taskItem.InitData(this.m_taskData[num], null);
                    }
                    else
                    {
                        taskItem.InitData(null, this.m_dailyData[num]);
                    }
                }
                if (!taskItem.gameObject.activeSelf)
                {
                    taskItem.gameObject.SetActive(true);
                    gameObject.transform.localPosition = new Vector3(0f, (float)(-(float)num) * this.itemOffY, 0f);
                }
            }
            num++;
        }
        this.oldIndex = index;
    }