Beispiel #1
0
    /// <summary>
    /// NCMBからTOP100情報を取得
    /// </summary>
    private void FetchTopData4Ncmb()
    {
        // データスコアの「HighScore」から検索
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("HighScore");

        // Scoreフィールドの降順でデータを取得
        query.OrderByDescending("score");

        // 検索件数を100件に設定
        query.Limit = 100;

        // データストアでの検索を行う
        query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
        {
            if (e != null)
            {
                // 検索失敗時の処理
                ToastManager.Show("データの取得に失敗しました");
            }
            else
            {
                // 検索成功時の処理
                foreach (RankCell cell in cellList)
                {
                    Destroy(cell.gameObject);
                }
                cellList.Clear();

                for (int i = 0; i < objList.Count; i++)
                {
                    string name = Convert.ToString(objList[i]["name"]);
                    int score   = Convert.ToInt32(objList[i]["score"]);

                    RankCell cell = Instantiate(tempCell, listParentRt);
                    cell.Init(i + 1, name, score);
                    cellList.Add(cell);
                }

                //var items = Enumerable.Range(0, 20)
                //    .Select(i => new ItemData($"Cell {i}"))
                //    .ToArray();

                //scrollView.UpdateData(items);
                //scrollView.SelectCell(0);
            }
        });

        // リスト表示
        listAnimator.Play(showHash, 0, 0.0f);
    }
Beispiel #2
0
    public void LoadRankList()
    {
        Dictionary <int, JSONObject> mapRankList = null;
        float fUnit          = 0.0f;
        float fStartYpos     = 0.0f;
        float fContentHeight = 0.0f;

        fUnit          = 50.0f;
        fStartYpos     = -20.0f;
        fContentHeight = 50.0f;
        mapRankList    = RankSingleton.GetInstance().GetRankerList(m_eCurrentTab);

        Debug.Log("RankListLength : " + mapRankList.Count.ToString());

        foreach (KeyValuePair <int, JSONObject> item in mapRankList)
        {
            int           nUserRank     = 0;
            RankCell      rankCell      = null;
            GameObject    objRankCell   = null;
            JSONObject    objUserInfo   = null;
            RectTransform rectTransform = null;

            nUserRank     = item.Key;
            objUserInfo   = item.Value;
            objRankCell   = RankCellPool.GetInstance().EnableObject();
            rankCell      = objRankCell.GetComponent <RankCell>();
            rectTransform = objRankCell.GetComponent <RectTransform>();

            rankCell.SetData(objUserInfo);
            objRankCell.transform.SetParent(transform);

            rectTransform.localPosition = new Vector2(0.0f, fStartYpos);
            rectTransform.offsetMin     = new Vector2(20.0f, fStartYpos);
            rectTransform.offsetMax     = new Vector2(-20.0f, fStartYpos);

            rectTransform.SetDefaultScale();
            rectTransform.SetHeight(40.0f);

            fStartYpos     -= fUnit;
            fContentHeight += fUnit;
        }

        GetComponent <RectTransform>().SetHeight(fContentHeight);
    }
Beispiel #3
0
    /// <summary>
    /// アツマールからランク情報を取得
    /// </summary>
    private void FetchRank4Atsumaru()
    {
#if OJU_ATSUMARU
        myRankText.SetText("---");
        myHighScoreText.gameObject.SetActive(false);
        myScoreText.SetText("0");

        // 更新成功時の処理
        gc.am.GetScoreboardData(highScoreBoardId, (data, isError2) =>
        {
            if (isError2)
            {
                // 取得失敗時の処理
                ToastManager.Show("データ取得に失敗しました");

                // リスト表示
                listAnimator.Play(showHash, 0, 0.0f);
            }
            else
            {
                // 取得成功時の処理
                // ユーザー名取得
                if (data.myRecord.Available)
                {
                    if (data.myRecord.rank <= gc.rankBorder)
                    {
                        myRankText.SetText(data.myRecord.rank.ToString());
                    }
                    else
                    {
                        myRankText.SetText(string.Format("{0}+", gc.rankBorder.ToString()));
                    }
                    myHighScoreText.gameObject.SetActive(data.myRecord.isNewRecord);
                    myScoreText.SetText(data.myRecord.score.ToString());
                }

                // リストリセット
                foreach (RankCell cell in cellList)
                {
                    Destroy(cell.gameObject);
                }
                cellList.Clear();

                // ランク取得
                for (int count = 0; count < data.ranking.Length; count++)
                {
                    RpgAtsumaruRanking rankData = data.ranking[count];

                    int curRank    = count + 1;
                    string curName = string.Format("{0}", rankData.userName);
                    int curScore   = (int)rankData.score;

                    RankCell cell = Instantiate(tempCell, listParentRt);
                    cell.Init(curRank, curName, curScore);
                    cellList.Add(cell);
                }

                // リスト表示
                listAnimator.Play(showHash, 0, 0.0f);
            }
        });
#endif
    }