Beispiel #1
0
    void SetData(int dayIndex)
    {
        mCurDay = dayIndex;
        SevenDaysRewardVO vo = mProxy.GetSevenDaysRewardByDay(mCurDay);
        bool signforprogress = false;

        if (vo == null)
        {
            signforprogress = true;
            vo = new SevenDaysRewardVO();
            vo.dayTargetProgress = -1;
            vo.dayIndex          = dayIndex;
            List <Tab_SevenDaysReward> items = SevenDaysRewardProxy.GetTabSevenDaysRewardByDay(dayIndex);
            int count = items.Count;
            for (int i = 0; i < count; ++i)
            {
                if (i == 0)
                {
                    vo.dayTarget = items[0];
                }
                else
                {
                    vo.data[i - 1] = items[i];
                }
            }
        }
        if (vo.dayTargetProgress == -1)
        {
            lblProgress.gameObject.SetActive(false);
            sldProgress.value = signforprogress ? 0f : (float)vo.dayTarget.OpCount / vo.dayTarget.OpCount;
        }
        else
        {
            lblProgress.text = vo.dayTargetProgress + "/" + vo.dayTarget.OpCount;
            lblProgress.gameObject.SetActive(true);
            sldProgress.value = (float)vo.dayTargetProgress / vo.dayTarget.OpCount;
        }
        btnClaim.isEnabled = (vo.dayTargetProgress >= vo.dayTarget.OpCount);
        SetRewards(vo.dayTarget);

        Utils.CleanGrid(missionGrid.gameObject);
        missionGrid.GetComponent <UITopGrid>().Recenter(true);
        for (int i = 0; i < vo.data.Length; i++)
        {
            if (vo.data[i] == null)
            {
                break;
            }
            string goName = string.Empty;
            if (vo.curProgress[i] == -1)
            {
                // the names of completed ones begin with 'c'
                goName = "c" + i.ToString();
            }
            else if (vo.curProgress[i] >= vo.data[i].OpCount)
            {
                // the names of unclaimed ones begin with 'a'
                goName = "a" + i.ToString();
            }
            else
            {
                // the names of uncompleted ones begin with 'b'
                goName = "b" + i.ToString();
            }
            GameObject go = Utils.BindObjToParent(sevenDaysMissionItemTemplate, missionGrid.gameObject, goName);
            if (go)
            {
                go.GetComponent <SevenDaysMissionItem>().SetData(vo.data[i], vo.curProgress[i]);
            }
        }
        UIGrid grid = missionGrid.GetComponent <UIGrid>();

        grid.sorted = true;
        grid.Reposition();
    }
Beispiel #2
0
    public void SetData(GC_SYNCALLCARNIVALGOAL data)
    {
        int dayIndex    = 0;
        int rewardIndex = 0;

        for (int i = 0; i < data.GoalflagsCount; i++)
        {
            dayIndex    = i / 21;
            rewardIndex = i - dayIndex * 21;
            SevenDaysRewardVO vo = null;
            if (dayIndex >= rewardDataList.Count)
            {
                vo          = new SevenDaysRewardVO();
                vo.dayIndex = dayIndex;
                List <Tab_SevenDaysReward> dataList = GetTabSevenDaysRewardByDay(vo.dayIndex);
                for (int j = 0; j < dataList.Count; j++)
                {
                    if (j == 0)
                    {
                        vo.dayTarget = dataList[j];
                    }
                    else
                    {
                        vo.data[j - 1] = dataList[j];
                    }
                }
                rewardDataList.Add(vo);
            }
            else
            {
                vo = rewardDataList[dayIndex];
            }
            // rewardIndex == 0 代表是每日目标
            if (rewardIndex == 0)
            {
                if (data.GoalflagsList[i] == -1)
                {
                    // claimed day reward
                    vo.dayTargetProgress = -1;
                }
                else
                {
                    // need to calculate
                    vo.dayTargetProgress = 0;
                }
            }
            else
            {
                // rewardIndex > 0 代表是每个任务
                if (vo.data[rewardIndex - 1] != null)
                {
                    vo.curProgress[rewardIndex - 1] = data.GoalflagsList[i];
                    if (vo.curProgress[rewardIndex - 1] == -1 && vo.dayTargetProgress != -1)
                    {
                        vo.dayTargetProgress += 1;
                    }
                }
            }
        }
        if (reqCallback != null)
        {
            reqCallback();
            reqCallback = null;
        }
    }