Beispiel #1
0
        public void UpdataData()
        {
            SignTimesLabel.text  = string.Format(EB.Localizer.GetString("ID_WELFARE_SIGNIN_TIMES"), LTWelfareDataManager.Instance.SignInData.Num, EB.Time.LocalDaysInMonth);
            SignChanceLabel.text = string.Format(EB.Localizer.GetString("ID_WELFARE_SIGNIN_CHANCE"), (ResidueResigninTimes));
            int have_num = LTWelfareDataManager.Instance.SignInData.Num;
            int monthDay = EB.Time.LocalDaysInMonth;

            for (int i = 0; i < SignItemList.Count; i++)
            {
                if (i < have_num)
                {
                    SignItemList[i].UpdateReceiveState(eReceiveState.have);
                }
            }

            if (ResidueRealResigninDays > 1)
            {
                int index = have_num + Mathf.Min(ResidueRealResigninDays - 1, LTWelfareDataManager.Instance.SignInData.IsSigned ? 0 : 1);

                if (SignItemList.Count > index)
                {
                    SignItemList[index].UpdateReceiveState(eReceiveState.can, true);
                }
            }

            if (LTWelfareDataManager.Instance.GetIsHaveSigninAward())
            {
                LTWelfareSignInItem curItem = GetCurrent();

                if (curItem != null)
                {
                    curItem.UpdateReceiveState(eReceiveState.can);//这里设置可签到特效
                }
            }
        }
Beispiel #2
0
        private IEnumerator InitItems()
        {
            yield return(null);

            int have_num = LTWelfareDataManager.Instance.SignInData.Num;
            int monthDay = EB.Time.LocalDaysInMonth;

            SetPlaceHolder(monthDay);
            int   curNum      = LTWelfareDataManager.Instance.SignInData.Num;
            int   activeCount = (int)(m_ScrollView.GetComponent <UIPanel>().baseClipRegion.w / SignItemGrid.cellHeight);
            float value       = (float)(((curNum + SignItemGrid.maxPerLine - 1) / SignItemGrid.maxPerLine) - activeCount) / (float)(((monthDay + SignItemGrid.maxPerLine - 1) / SignItemGrid.maxPerLine) - activeCount);
            float scrollValue = curNum > activeCount ? value : 0f;

            m_ScrollView.UpdatePosition();
            m_ScrollView.UpdateScrollbars();
            m_ScrollView.verticalScrollBar.value = scrollValue;

            if (!m_HaveCreate)
            {
                for (int i = 0; i < SignItemList.Count; i++)
                {
                    GameObject.Destroy(SignItemList[i].mDMono.gameObject);
                }

                SignItemList.Clear();
                List <SigninAward> monthAwards = WelfareTemplateManager.Instance.GetTemplate(EB.Time.LocalMonth);

                for (int i = 0; i < monthDay; i++)
                {
                    if (SignItem == null)
                    {
                        break;
                    }

                    GameObject obj = GameObject.Instantiate(SignItem);
                    obj.SetActive(true);
                    obj.transform.SetParent(SignItemGrid.transform);
                    obj.transform.localScale    = Vector3.one;
                    obj.transform.localPosition = new Vector3(1000, 0, 0);
                    LTWelfareSignInItem Ctrl = obj.GetMonoILRComponent <LTWelfareSignInItem>();
                    Ctrl.InitData(monthAwards[i], i + 1);

                    if (i < have_num)
                    {
                        Ctrl.UpdateReceiveState(eReceiveState.have);
                    }
                    else if (i > have_num && i <= have_num + Mathf.Min(ResidueRealResigninDays - 1, LTWelfareDataManager.Instance.SignInData.IsSigned ? 0 : 1))
                    {
                        Ctrl.UpdateReceiveState(eReceiveState.can, true);
                    }

                    SignItemList.Add(Ctrl);

                    if ((i + 1) % SignItemGrid.maxPerLine == 0 || i == monthDay - 1)
                    {
                        SignItemGrid.Reposition();
                        yield return(new WaitForSeconds(0.2f));
                    }
                }
                m_HaveCreate = true;
                EB.Debug.Log("Create SignItem Finished!!!!!!!");
            }

            if (LTWelfareDataManager.Instance.GetIsHaveSigninAward() && SignItem != null)
            {
                LTWelfareSignInItem curItem = GetCurrent();
                if (curItem != null)
                {
                    curItem.UpdateReceiveState(eReceiveState.can);                 //这里设置可签到特效
                }
            }
        }