コード例 #1
0
ファイル: RandomUI.cs プロジェクト: rich-engine/RichEngine
    public void setMarkVisible(bool isVisible, int num)
    {
        int index = -1;

        foreach (var randomType in RandomFactory.GetRandomFuncList())
        {
            index++;
            if (index >= mItemCount || num == index)
            {
                continue;
            }
            items[index].GetComponent <RandomItemUI>().setMarkVisible(false);
        }
    }
コード例 #2
0
ファイル: RandomUI.cs プロジェクト: rich-engine/RichEngine
    public string returnKey(int index)
    {
        string key    = "";
        int    _index = -1;

        foreach (var randomType in RandomFactory.GetRandomFuncList())
        {
            _index++;
            if (index == _index)
            {
                key = randomType;
            }
        }
        return(key);
    }
コード例 #3
0
ファイル: RandomUI.cs プロジェクト: rich-engine/RichEngine
    void Update()
    {
        if (mCount < RandomFactory.GetRandomFuncList().Count)
        {
            //根据item数量改变滚动区域的大小
            transform.GetComponent <RectTransform>().sizeDelta = new Vector2(200 * RichEngine.Instance.m_setting.m_LottryTypes.Count, 0);

            int index = -1;
            foreach (var randomType in RandomFactory.GetRandomFuncList())
            {
                index++;
                if (index >= mItemCount)
                {
                    break;
                }

                items[index].SetActive(true);
                items[index].GetComponent <RandomItemUI>().SetItemData(index, randomType, m_richDataEntry.m_RandAlgothm, this);
            }
            mCount = RandomFactory.GetRandomFuncList().Count;
        }

        if (RandomFactory.GetRandomFuncList().Count > mItemCount)
        {
            if (items[0].transform.position.x >= 100)                           //从左向右滑
            {
                int index = items[0].GetComponent <RandomItemUI>().m_index - 1; //首先判断是否为第一个元素,是的话就表示显示完了,不需要换位置了
                if (index < 0)
                {
                    return;
                }

                Vector3 pos = items[0].transform.localPosition;                            //获得还没有移动位置之前第一个元素的位置

                items.Insert(0, items[9]);                                                 //将最后的元素移动到最前面

                items[0].transform.localPosition = new Vector3(pos.x - 200, pos.y, pos.z); //重新设置移动位置之后第一个元素的位置

                items.RemoveAt(items.Count - 1);                                           //将之前最后元素删除

                items[0].GetComponent <RandomItemUI>().SetItemData(index, returnKey(index), m_richDataEntry.m_RandAlgothm, this);
            }
            if (items[0].transform.position.x <= -100)                                       //从右向左滑
            {
                int index = items[items.Count - 1].GetComponent <TitleItemUI>().m_index + 1; //首先判断是否为最后,是的话就表示显示完了,不需要换位置了
                if (index >= RandomFactory.GetRandomFuncList().Count)
                {
                    return;
                }


                Vector3 pos = items[items.Count - 1].transform.localPosition;                            //获得还没有移动位置之前最后一个元素的位置

                items.Add(items[0]);                                                                     //将最前的元素移动到最后面

                items[items.Count - 1].transform.localPosition = new Vector3(pos.x + 200, pos.y, pos.z); //重新设置移动位置之后最后一个元素的位置

                items.RemoveAt(0);                                                                       //将之前最前面的元素删除;

                items[items.Count - 1].GetComponent <RandomItemUI>().SetItemData(index, returnKey(index), m_richDataEntry.m_RandAlgothm, this);
            }
        }
    }