Beispiel #1
0
        /// <summary>
        /// Populates the data with a lot of records
        /// </summary>
        private void LoadData()
        {
            // if the data existed previously, loop through
            // and remove the selection change handlers before
            // clearing out the data.
            if (_data != null)
            {
                for (var i = 0; i < _data.Count; i++)
                {
                    _data[i].selectedChanged = null;
                }
            }

            // set up some simple data
            _data = new SmallList <Data>();
            for (var i = 0; i < 1000; i++)
            {
                _data.Add(new Data()
                {
                    someText = i.ToString()
                });
            }

            // tell the scroller to reload now that we have the data
            scroller.ReloadData();
        }
Beispiel #2
0
        void Start()
        {
            // set the scroller's cell view visbility changed delegate to a method in this controller
            scroller.cellViewVisibilityChanged = CellViewVisibilityChanged;
            scroller.cellViewWillRecycle       = CellViewWillRecycle;

            // set up some simple data
            _data = new SmallList <Data>();

            // set up a list of images with their dimensions
            for (var i = 0; i < imageURLList.Length; i++)
            {
                // add the image based on the image list text file
                _data.Add(new Data()
                {
                    imageUrl        = imageURLList[i],
                    imageDimensions = new Vector2(200f, 200f)
                });
            }

            // set the scroller's delegate to this controller
            scroller.Delegate = this;

            // tell the scroller to reload
            scroller.ReloadData();
        }
Beispiel #3
0
    public void Reload(bool val)
    {
        jsonMonsterFile = Resources.Load("monsters") as TextAsset;
        jsonMonsters    = JsonMapper.ToObject(jsonMonsterFile.text);

        if (_data != null)
        {
            for (var i = 0; i < _data.Count; i++)
            {
                _data[i].selectedChanged = null;
            }
        }

        _data = new SmallList <InventoryData2>();

        for (int i = 0; i < jsonMonsters["monsters"].Count; i += 2)
        {
            if (i + 1 < jsonMonsters["monsters"].Count)
            {
                _data.Add(new InventoryData2()
                {
                    id           = jsonMonsters["monsters"][i]["id"].ToString(),
                    monsterName  = jsonMonsters["monsters"][i]["image"].ToString(),
                    id2          = jsonMonsters["monsters"][i + 1]["id"].ToString(),
                    monsterName2 = jsonMonsters["monsters"][i + 1]["image"].ToString()
                });
            }
        }

        vScroller.ReloadData();
        if (listMonsterSelected.Count != 0 && val)
        {
            ReloadMonsterSelected();
        }
    }
Beispiel #4
0
    private void Reload()
    {
        jsonTeamFile = Resources.Load("teams") as TextAsset;
        jsonTeam     = JsonMapper.ToObject(jsonTeamFile.text);

        if (_data != null)
        {
            for (var i = 0; i < _data.Count; i++)
            {
                _data[i].selectedChanged = null;
            }
        }

        _data = new SmallList <TeamData>();

        for (int i = 0; i < jsonTeam["teams"].Count; i++)
        {
            _data.Add(new TeamData()
            {
                Selected     = System.Convert.ToBoolean(jsonTeam["teams"][i]["selected"].ToString()),
                Created      = System.Convert.ToBoolean(jsonTeam["teams"][i]["created"].ToString()),
                monsterName1 = jsonTeam["teams"][i]["monsters"][0]["name"].ToString(),
                monsterName2 = jsonTeam["teams"][i]["monsters"][1]["name"].ToString(),
                monsterName3 = jsonTeam["teams"][i]["monsters"][2]["name"].ToString(),
                monsterName4 = jsonTeam["teams"][i]["monsters"][3]["name"].ToString()
            });
        }

        vScroller.ReloadData();
    }
Beispiel #5
0
        /// <summary>
        /// Populates the data with a lot of records
        /// </summary>
        private void LoadData(int pageStartIndex)
        {
            // grab the last index of the data to jump to when we are finished
            var previousLastIndex = _data.Count;

            // calculate the last index of the new list
            var lastIndex = _data.Count + pageCount;

            // add data to the list
            for (var i = pageStartIndex; i < lastIndex; i++)
            {
                _data.Add(new Data()
                {
                    someText = "Cell Data Index " + i.ToString()
                });
            }

            // cache the scroller's position so that we can set it back after the reload
            var scrollPosition = scroller.ScrollPosition;

            // tell the scroller to reload now that we have the data.
            scroller.ReloadData();

            // set the scroller's position back to the cached position
            scroller.ScrollPosition = scrollPosition;

            // toggle off loading new so that we can load again at the bottom of the scroller
            _loadingNew = false;
        }
 public ExampleScrollerProperties(List <int> values)
 {
     this.values        = values;
     CellViewProperties = new SmallList <ICellViewProperties>();
     foreach (var value in values)
     {
         CellViewProperties.Add(new ExampleCellViewProperties(value));
     }
 }
        /// <summary>
        /// Populates the data with a lot of records
        /// </summary>
        private void LoadLargeData()
        {
            // set up some simple data
            _data = new SmallList<Data>();
            for (var i = 0; i < 1000; i++)
                _data.Add(new Data() { someText = "Cell Data Index " + i.ToString() });

            // tell the scroller to reload now that we have the data
            scroller.ReloadData();
        }
Beispiel #8
0
        /// <summary>
        /// Populates the data with a small set of records
        /// </summary>
        private void LoadSmallData()
        {
            // set up some simple data
            _data = new SmallList <Data>();

            _data.Add(new Data()
            {
                someText = "A"
            });
            _data.Add(new Data()
            {
                someText = "B"
            });
            _data.Add(new Data()
            {
                someText = "C"
            });

            // tell the scroller to reload now that we have the data
            scroller.ReloadData();
        }
Beispiel #9
0
        private void LoadData()
        {
            _data = new SmallList <DataPista>();

            foreach (Pista pista in enigma.Pistas)
            {
                if (pista.image != null)
                {
                    _data.Add(new DataPista()
                    {
                        headerText        = pista.PistaName,
                        descriptionText   = pista.TextRich,
                        imageOptional     = pista.image,
                        isExpanded        = false,
                        expandedSize      = pista.sizeText,
                        collapsedSize     = 60f,
                        tweenType         = Tween.TweenType.easeInOutSine,
                        tweenTimeExpand   = 0.5f,
                        tweenTimeCollapse = 0.5f
                    });
                }
                else
                {
                    _data.Add(new DataPista()
                    {
                        headerText        = pista.PistaName,
                        descriptionText   = pista.TextRich,
                        isExpanded        = false,
                        expandedSize      = pista.sizeText,
                        collapsedSize     = 60f,
                        tweenType         = Tween.TweenType.easeInOutSine,
                        tweenTimeExpand   = 0.5f,
                        tweenTimeCollapse = 0.5f
                    });
                }
            }

            scroller.ReloadData();
        }
    public void FillTriangle(ref Vertex v0, ref Vertex v1, ref Vertex v2)
    {
        if (!hasMask)
        {
            int vertexCount = VertexCount;

            AddVertex(ref v0);
            AddVertex(ref v1);
            AddVertex(ref v2);
            AddIndices(vertexCount, vertexCount + 1, vertexCount + 2);

            return;
        }

        var list = new SmallList <Vertex>();

        list.Add(ref v0);
        list.Add(ref v1);
        list.Add(ref v2);

        SutherlandHodgman(ref list);
        AddPolygon(ref list);
    }
Beispiel #11
0
        /// <summary>
        /// Populates the data with a lot of records
        /// </summary>
        private void LoadLargeData()
        {
            // set up some simple data
            _data = new SmallList <DataParticipant>();
            for (var i = 0; i < 1000; i++)
            {
                _data.Add(new DataParticipant()
                {
                    someText = "Arvind"
                });
            }

            // tell the scroller to reload now that we have the data
            scroller.ReloadData();
        }
Beispiel #12
0
        public void SetData(string condition, string stackTrace, LogType type)
        {
            if (logInfos.Count > 300)
            {
                logInfos.Clear();
            }

            logInfos.Add(new LogInfo
            {
                condition  = condition,
                stackTrace = stackTrace,
                type       = type,
                height     = -1
            });
            scroller.ReloadData(1);
        }
Beispiel #13
0
        /// <summary>
        /// Populates the data with a lot of records
        /// </summary>
        private void LoadData()
        {
            // set up some simple data
            _data = new SmallList <Data>();
            for (var i = 0; i < 31; i++)
            {
                _data.Add(new Data()
                {
                    someText   = i.ToString(),
                    isSelected = i == _selectedIndex
                });
            }

            // tell the scroller to reload now that we have the data
            scroller.ReloadData();
        }
Beispiel #14
0
        public void Reload(Sprite[] sprites)
        {
            // reset the data list
            _data.Clear();

            // at the sprites from the demo script to this scroller's data cells
            foreach (var slotSprite in sprites)
            {
                _data.Add(new SlotData()
                {
                    sprite = slotSprite
                });
            }

            // reload the scroller
            scroller.ReloadData();
        }
Beispiel #15
0
        /// <summary>
        /// Populates the data with a small set of records
        /// </summary>
        public void ParticipantsListReceived(List <string> participantsList)
        {
            _data = new SmallList <DataParticipant>();

            foreach (string participantName in participantsList)
            {
                _data.Add(new DataParticipant()
                {
                    someText = participantName
                });
            }

            scroller.ClearAll();

            // tell the scroller to reload now that we have the data
            scroller.ReloadData();
        }
        void Start()
        {
            // set the scroller's delegate to this controller
            scroller.Delegate = this;

            // set the scroller's cell view visbility changed delegate to a method in this controller
            scroller.cellViewVisibilityChanged = CellViewVisibilityChanged;

            // set up some simple data
            _data = new SmallList <Data>();

            // set up a list of images with their dimensions
            for (var i = 0; i <= 12; i++)
            {
                _data.Add(new Data()
                {
                    imageUrl = string.Format("http://echo17.com/support/enhancedscroller/{0}.jpg", i), imageDimensions = new Vector2(200f, 200f)
                });
            }

            // tell the scroller to reload now that we have the data
            scroller.ReloadData();
        }
Beispiel #17
0
        private void Resize()
        {
            Debug.Assert(IsFull);

            int initialCapacity = _options.InitialCapacity;

            if (IsEmpty)
            {
                _head     = new T[initialCapacity];
                _capacity = initialCapacity;
                return;
            }

            _tail.Add(_head);
            // We want to increase the block sizes geometrically, but not on the first resize.
            // This ensures we never waste more than 50% of the memory we've allocated.
            int nextCapacity = _capacity == initialCapacity
                ? initialCapacity
                : HeadCapacity * 2;

            _head      = new T[nextCapacity];
            _headCount = 0;
            _capacity += nextCapacity;
        }
    private SmallList <RankingData> _parseRankingJson(string jsonString)
    {
        // parse json
        var rankingData = new SmallList <RankingData>();
        var json        = Json.Deserialize(jsonString) as List <object>;

        string score;
        int    rank;
        int    lastRank  = 1;
        string lastScore = "";

        for (int i = 0; i < json.Count; ++i)
        {
            var row = json[i] as Dictionary <string, object>;
            // 順位計算
            score = row["score"].ToString();
            if (score == lastScore)
            {
                rank = lastRank;
            }
            else
            {
                rank     = i + 1;
                lastRank = i + 1;
            }
            lastScore = score;
            // リストに格納
            rankingData.Add(new RankingData()
            {
                rank  = rank,
                name  = row["name"].ToString(),
                score = float.Parse(score),
            });
        }
        return(rankingData);
    }
        /// <summary>
        /// Populates the data with a lot of records
        /// </summary>
        private void LoadData()
        {
            // create some data
            // note we are using different data class fields for the header, row, and footer rows. This works due to polymorphism.

            _data = new SmallList <Data>();

            _data.Add(new HeaderData()
            {
                category = "Platinum Players"
            });
            _data.Add(new RowData()
            {
                userName = "******", userAvatarSpritePath = resourcePath + "/avatar_male", userHighScore = 21323199
            });
            _data.Add(new RowData()
            {
                userName = "******", userAvatarSpritePath = resourcePath + "/avatar_female", userHighScore = 20793219
            });
            _data.Add(new RowData()
            {
                userName = "******", userAvatarSpritePath = resourcePath + "/avatar_female", userHighScore = 19932132
            });
            _data.Add(new FooterData());

            _data.Add(new HeaderData()
            {
                category = "Gold Players"
            });
            _data.Add(new RowData()
            {
                userName = "******", userAvatarSpritePath = resourcePath + "/avatar_male", userHighScore = 1002132
            });
            _data.Add(new RowData()
            {
                userName = "******", userAvatarSpritePath = resourcePath + "/avatar_female", userHighScore = 991234
            });
            _data.Add(new FooterData());

            _data.Add(new HeaderData()
            {
                category = "Silver Players"
            });
            _data.Add(new RowData()
            {
                userName = "******", userAvatarSpritePath = resourcePath + "/avatar_male", userHighScore = 905723
            });
            _data.Add(new RowData()
            {
                userName = "******", userAvatarSpritePath = resourcePath + "/avatar_male", userHighScore = 702318
            });
            _data.Add(new RowData()
            {
                userName = "******", userAvatarSpritePath = resourcePath + "/avatar_female", userHighScore = 697767
            });
            _data.Add(new RowData()
            {
                userName = "******", userAvatarSpritePath = resourcePath + "/avatar_male", userHighScore = 409393
            });
            _data.Add(new RowData()
            {
                userName = "******", userAvatarSpritePath = resourcePath + "/avatar_female", userHighScore = 104352
            });
            _data.Add(new RowData()
            {
                userName = "******", userAvatarSpritePath = resourcePath + "/avatar_male", userHighScore = 88321
            });
            _data.Add(new RowData()
            {
                userName = "******", userAvatarSpritePath = resourcePath + "/avatar_female", userHighScore = 20826
            });
            _data.Add(new RowData()
            {
                userName = "******", userAvatarSpritePath = resourcePath + "/avatar_female", userHighScore = 17389
            });
            _data.Add(new RowData()
            {
                userName = "******", userAvatarSpritePath = resourcePath + "/avatar_male", userHighScore = 2918
            });
            _data.Add(new FooterData());

            // tell the scroller to reload now that we have the data
            scroller.ReloadData();
        }
Beispiel #20
0
        /// <summary>
        /// This sets up the visible cells, adding and recycling as necessary
        /// </summary>
        private void _ResetVisibleCellViews()
        {
            int startIndex;
            int endIndex;

            // calculate the range of the visible cells
            _CalculateCurrentActiveCellRange(out startIndex, out endIndex);

            // go through each previous active cell and recycle it if it no longer falls in the range
            var i = 0;
            SmallList<int> remainingCellIndices = new SmallList<int>();
            while (i < _activeCellViews.Count)
            {
                if (_activeCellViews[i].cellIndex < startIndex || _activeCellViews[i].cellIndex > endIndex)
                {
                    _RecycleCell(_activeCellViews[i]);
                }
                else
                {
                    // this cell index falls in the new range, so we add its
                    // index to the reusable list
                    remainingCellIndices.Add(_activeCellViews[i].cellIndex);
                    i++;
                }
            }

            if (remainingCellIndices.Count == 0)
            {
                // there were no previous active cells remaining,
                // this list is either brand new, or we jumped to
                // an entirely different part of the list.
                // just add all the new cell views

                for (i = startIndex; i <= endIndex; i++)
                {
                    _AddCellView(i, ListPositionEnum.Last);
                }
            }
            else
            {
                // we are able to reuse some of the previous
                // cell views

                // first add the views that come before the
                // previous list, going backward so that the
                // new views get added to the front
                for (i = endIndex; i >= startIndex; i--)
                {
                    if (i < remainingCellIndices.First())
                    {
                        _AddCellView(i, ListPositionEnum.First);
                    }
                }

                // next add teh views that come after the
                // previous list, going forward and adding
                // at the end of the list
                for (i = startIndex; i <= endIndex; i++)
                {
                    if (i > remainingCellIndices.Last())
                    {
                        _AddCellView(i, ListPositionEnum.Last);
                    }
                }
            }

            // update the start and end indices
            _activeCellViewsStartIndex = startIndex;
            _activeCellViewsEndIndex = endIndex;

            // adjust the padding elements to offset the cell views correctly
            _SetPadders();
        }
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="curveItems"></param>
        public void Init(CurveScrollerItemData[] curveItems)
        {
            if (isInit)
            {
                return;
            }
            if (tweenPath.path.wpLengths.Length <= 1)
            {
                Debug.LogError("tween Path 没有点位信息");
                return;
            }

            isInit = true;
            //获取path总长度
            float pathLength = tweenPath.tween.PathLength();

            //获取每个点的长度 第一个点为0 排除
            float[] needwplengths = new float[tweenPath.path.wpLengths.Length - 1];
            for (int i = 0; i < tweenPath.path.wpLengths.Length; i++)
            {
                //第一个永远是0 不需要
                if (i == 0)
                {
                    continue;
                }
                needwplengths[i - 1] = tweenPath.path.wpLengths[i];
            }

            //添加数据
            //数据过少 就循环添加
            if (curveItems.Length < needwplengths.Length)
            {
                int arrayIndex = 0;
                //多添加一个
                for (int i = 0; i <= needwplengths.Length; i++)
                {
                    listData.Add(curveItems[arrayIndex]);
                    arrayIndex++;
                    if (arrayIndex > curveItems.Length - 1)
                    {
                        arrayIndex = 0;
                    }
                }
            }
            else
            {
                for (int i = 0; i < curveItems.Length; i++)
                {
                    listData.Add(curveItems[i]);
                }
            }

            //计算比例
            basePercentages = new float[needwplengths.Length];
            float tempPercentage = 0;

            for (int i = 0; i < needwplengths.Length; i++)
            {
                tempPercentage    += needwplengths[i] / pathLength;
                basePercentages[i] = tempPercentage;
            }

            for (int i = 0; i < basePercentages.Length; i++)
            {
                //克隆对象
                CurveScrollerItemView cutveItem = Instantiate(curveItemPrefab.gameObject).GetComponent <CurveScrollerItemView>();
                cutveItem.transform.transform.SetParent(this.transform);
                //cutveItem.transform.localScale = Vector3.one;

                CurveScrollerItemData curveItemData = listData.RemoveStart();
                curveItemData.Percentage = basePercentages[i];
                cutveItem.SetData(curveItemData);
                SetTransPosForTweenPerc(cutveItem.transform, basePercentages[i]);

                //添加到列表
                listTransPerc.Add(new TransPercentageStruct(cutveItem, curveItemData));
            }
            listTransPerc.Capacity = listTransPerc.Count;
        }
Beispiel #22
0
    /// <summary>
    /// Sutherland-Hodgman algorithmでクリップする。
    /// </summary>
    /// <param name="list">三角形か凸な四角形</param>
    void SutherlandHodgman(ref SmallList <Vertex> list)
    {
        var    list2 = new SmallList <Vertex>();
        Vertex vertex, prev, temporary;

        list.Get(list.Count - 1, out prev);
        for (int i = 0; i < list.Count; ++i)
        {
            list.Get(i, out vertex);

            if (vertex.Position.x >= mask.x)
            {
                if (prev.Position.x < mask.x)
                {
                    var t = (mask.x - vertex.Position.x) / (prev.Position.x - vertex.Position.x);
                    Vertex.Lerp(ref vertex, ref prev, t, out temporary);
                    list2.Add(ref temporary);
                }

                list2.Add(ref vertex);
            }
            else if (prev.Position.x >= mask.x)
            {
                var t = (mask.x - vertex.Position.x) / (prev.Position.x - vertex.Position.x);
                Vertex.Lerp(ref vertex, ref prev, t, out temporary);
                list2.Add(ref temporary);
            }

            prev = vertex;
        }

        list.Clear();

        if (list2.Count <= 2)
        {
            return;
        }

        list2.Get(list2.Count - 1, out prev);
        for (int i = 0; i < list2.Count; ++i)
        {
            list2.Get(i, out vertex);

            if (vertex.Position.y >= mask.y)
            {
                if (prev.Position.y < mask.y)
                {
                    var t = (mask.y - vertex.Position.y) / (prev.Position.y - vertex.Position.y);
                    Vertex.Lerp(ref vertex, ref prev, t, out temporary);
                    list.Add(ref temporary);
                }

                list.Add(ref vertex);
            }
            else if (prev.Position.y >= mask.y)
            {
                var t = (mask.y - vertex.Position.y) / (prev.Position.y - vertex.Position.y);
                Vertex.Lerp(ref vertex, ref prev, t, out temporary);
                list.Add(ref temporary);
            }

            prev = vertex;
        }

        if (list.Count <= 2)
        {
            return;
        }

        list2.Clear();
        list.Get(list.Count - 1, out prev);
        for (int i = 0; i < list.Count; ++i)
        {
            list.Get(i, out vertex);

            if (vertex.Position.x <= mask.z)
            {
                if (prev.Position.x > mask.z)
                {
                    var t = (mask.z - vertex.Position.x) / (prev.Position.x - vertex.Position.x);
                    Vertex.Lerp(ref vertex, ref prev, t, out temporary);
                    list2.Add(ref temporary);
                }

                list2.Add(ref vertex);
            }
            else if (prev.Position.x <= mask.z)
            {
                var t = (mask.z - vertex.Position.x) / (prev.Position.x - vertex.Position.x);
                Vertex.Lerp(ref vertex, ref prev, t, out temporary);
                list2.Add(ref temporary);
            }

            prev = vertex;
        }

        list.Clear();

        if (list2.Count <= 2)
        {
            return;
        }

        list2.Get(list2.Count - 1, out prev);
        for (int i = 0; i < list2.Count; ++i)
        {
            list2.Get(i, out vertex);

            if (vertex.Position.y <= mask.w)
            {
                if (prev.Position.y > mask.w)
                {
                    var t = (mask.w - vertex.Position.y) / (prev.Position.y - vertex.Position.y);
                    Vertex.Lerp(ref vertex, ref prev, t, out temporary);
                    list.Add(ref temporary);
                }

                list.Add(ref vertex);
            }
            else if (prev.Position.y <= mask.w)
            {
                var t = (mask.w - vertex.Position.y) / (prev.Position.y - vertex.Position.y);
                Vertex.Lerp(ref vertex, ref prev, t, out temporary);
                list.Add(ref temporary);
            }

            prev = vertex;
        }
    }