Пример #1
0
        public void SetUI(DataTransfer data)
        {
            m_LevelList = new List <Transform>();
            int maxPassLevel = data.GetData <int>(ConstDefine.MaxPassLevel);
            int maxLevel     = data.GetData <int>(ConstDefine.MaxLevel);

            for (int i = 0; i < maxLevel; i++)
            {
                //item
                GameObject go = ResourcesMrg.Instance.Load(ResourcesMrg.ResourceType.UIWindowChild, "GameLevelItem", isCache: true);
                go.transform.SetParent(m_Grid);
                DataTransfer d = new DataTransfer();
                d.SetData(ConstDefine.GameLevelItem_Level, i + 1);
                if (i + 1 <= maxPassLevel)
                {
                    d.SetData(ConstDefine.GameLevelItem_IsLock, false);
                }
                else
                {
                    d.SetData(ConstDefine.GameLevelItem_IsLock, true);
                }
                UIGameLevelItemView itemView = go.GetComponent <UIGameLevelItemView>();
                itemView.OnClickBtn     = OnClickGameLevelItemBtn;
                go.transform.localScale = Vector3.one;
                itemView.SetUI(d);
                m_LevelList.Add(go.transform);


                m_LastLevel = go.transform;
            }

            StartCoroutine("CreateLine", maxLevel);
        }
        private IEnumerator SetUIIE(DataTransfer data)
        {
            m_LevelViewList   = new List <UIGameLevelItemView>();
            m_TweenList       = new List <Tween>();
            m_GridLayoutGroup = m_Grid.GetComponent <GridLayoutGroup>();
            //float weightScale = (Screen.width * (852f / Screen.height)) / 1136f;
            float heightScale = (Screen.height / (float)Screen.width) * 1136f / 852f;

            m_GridLayoutGroup.cellSize *= heightScale;
            m_BtnLeft.sizeDelta        *= heightScale;
            m_BtnRight.sizeDelta       *= heightScale;
            //m_BtnLeft.anchoredPosition3D *= heightScale;
            //m_BtnRight.anchoredPosition3D *= heightScale;
            for (int i = 0; i < m_Count; i++)
            {
                GameObject go = ResourcesMrg.Instance.Load(ResourcesMrg.ResourceType.UIWindowChild, "GameLevelItem", isCache: true);
                go.transform.SetParent(m_Grid);
                go.transform.localScale = Vector3.zero;
                UIGameLevelItemView view = go.GetComponent <UIGameLevelItemView>();
                view.OnClickBtn += OnClickGameLevelItemBtn;
                m_LevelViewList.Add(view);
            }
            m_MaxPassLevel = data.GetData <int>(ConstDefine.MaxPassLevel);
            m_MaxLevel     = data.GetData <int>(ConstDefine.MaxLevel);
            yield return(null);

            bool isRun = true;

            m_Index = 1;
            while (isRun)
            {
                int index = m_Index;
                index += m_Count;
                if (index <= m_MaxPassLevel)
                {
                    m_Index += m_Count;
                }
                else
                {
                    m_Index += m_Count;
                    isRun    = false;
                }
            }
            Refresh(true);
        }