예제 #1
0
    // ランキングを取得
    private void GetRanking()
    {
        // すでにある場合、一旦全部削除
        for (int r = 0; r < rankerBoard.transform.childCount; r++)
        {
            Destroy(rankerBoard.transform.GetChild(r).gameObject);
        }
        // 検索
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("Ranking");

        query.OrderByAscending("Time");
        query.Limit = 10;
        query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
        {
            if (e != null)
            {
                //検索失敗時
                helper.Telop("ランキング更新にエラーが発生しました。m(_ _)m");
            }
            else
            {
                //検索成功時
                // ランカーを表示していく
                int c = 1;
                foreach (NCMBObject obj in objList)
                {
                    float s              = (float)System.Convert.ToDouble(obj["Time"]);
                    string n             = System.Convert.ToString(obj["Name"]);
                    GameObject go_ranker = Instantiate(ranker_prefab, rankerBoard.transform);
                    go_ranker.GetComponent <Ranker>().SetRanker(c, n, s);
                    c++;
                }
            }
        });
    }
예제 #2
0
    // サーバーからトップ5を取得 ---------------
    public void fetchTopRankers()
    {
        // データストアの「Time」クラスから検索
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("Time");

        query.OrderByAscending("time");
        query.Limit = 5;

        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e != null)
            {
                //検索失敗時の処理
            }
            else
            {
                //検索成功時の処理
                List <NCMB.Rankers> list = new List <NCMB.Rankers>();
                // 取得したレコードをtimeクラスとして保存
                foreach (NCMBObject obj in objList)
                {
                    string t = System.Convert.ToString(obj["time"]);
                    list.Add(new Rankers(t));
                }
                topRankers = list;
            }
        });
    }
예제 #3
0
    //RankingViewを作る関数
    public void MakeRankingView()
    {
        //==========TopRankのViewを作成==========

        // データストアの「HighScore」クラスから検索
        NCMBQuery <NCMBObject> queryTopRank = new NCMBQuery <NCMBObject>("OnlineRanking");

        queryTopRank.OrderByAscending("BestTime");
        queryTopRank.Limit = 5;
        queryTopRank.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e != null)//エラーあった時
            {
                //検索失敗時の処理
            }
            else//うまく行ったとき
            {
                for (int i = 0; i < objList.Count; i++)//objListの要素数と同じだけfor回す
                {
                    //順次ランキング表示!
                    userNameText[i].text = System.Convert.ToString(objList[i]["UserName"]);
                    bestTimeText[i].text = System.Convert.ToString(objList[i]["BestTime"]);
                }
            }
        });
    }
예제 #4
0
    public IEnumerator SetHighRankingTextFromClearResult()
    {
        NCMBQuery <NCMBObject> query  = new NCMBQuery <NCMBObject>(SceneManager.GetActiveScene().name);
        List <NCMBObject>      result = null;
        NCMBException          error  = null;

        query.OrderByAscending("ClearTime"); //昇順
        query.Limit = 10;

        query.FindAsync((List <NCMBObject> _result, NCMBException _error) =>
        {
            result = _result;
            error  = _error;
        });

        //resultもしくはerrorが入るまで待機
        yield return(new WaitWhile(() => result == null && error == null));

        //後続処理
        if (error == null)
        {
            this.SetHighRankingTextFromClearResult(result);
        }
        else
        {
            Debug.Log(error);
        }
    }
예제 #5
0
    /// <summary>
    /// @brief サーバーからトップ5を取得 ---------------
    /// </summary>
    public void FetchTopRankers()
    {
        // データストアの「HighScore」クラスから検索
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("HighScore");

        query.OrderByAscending("Score");
        query.Limit = 5;
        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e != null)
            {
                //検索失敗時の処理
            }
            else
            {
                //検索成功時の処理
                List <NCMB.HighScore> list = new List <NCMB.HighScore>();
                // 取得したレコードをHighScoreクラスとして保存
                foreach (NCMBObject obj in objList)
                {
                    double s = System.Convert.ToDouble(obj["Score"]);
                    string n = System.Convert.ToString(obj["Name"]);
                    list.Add(new HighScore(s, n));
                }
                topRankers = list;
            }
        });
    }
예제 #6
0
    public IEnumerator SetHighRankingTexts(int missionIndex)
    {
        NCMBQuery <NCMBObject> query  = new NCMBQuery <NCMBObject>("Mission" + (missionIndex + 1).ToString());
        List <NCMBObject>      result = null;
        NCMBException          error  = null;

        if (missionIndex != 3)
        {
            query.OrderByAscending("ClearTime");                    //昇順
        }
        else
        {
            query.OrderByDescending("ClearTime");  //降順
        }
        query.Limit = 10;

        query.FindAsync((List <NCMBObject> _result, NCMBException _error) =>
        {
            result = _result;
            error  = _error;
        });

        //resultもしくはerrorが入るまで待機
        yield return(new WaitWhile(() => result == null && error == null));

        //後続処理
        if (error == null)
        {
            this.SetHighRankingTexts(result, missionIndex);
        }
    }
예제 #7
0
    // ランキングをサーバーから取得し適用
    public void GetRanking()
    {
        Loading();
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("Ranking");

        query.OrderByAscending("Time");
        query.Limit = 30;
        query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
        {
            if (e != null)
            {
                ShowToast("エラーが発生しました。");
            }
            else
            {
                // ランカーの内容を適用していく
                Transform rankerParent = GameObject.Find("UI/Ranking/Panel/LeaderBoard/Viewport/Content").transform;
                int r = 0;
                foreach (NCMBObject obj in objList)
                {
                    r++;
                    float s           = (float)System.Convert.ToDouble(obj["Time"]);
                    string n          = System.Convert.ToString(obj["Name"]);
                    GameObject ranker = Instantiate(rankerPrefab, rankerParent);
                    ranker.transform.GetChild(0).GetComponent <Text> ().text = r.ToString();
                    ranker.transform.GetChild(1).GetComponent <Text> ().text = n;
                    ranker.transform.GetChild(2).GetComponent <Text> ().text = s.ToString();
                }
            }
            LoadEnd();
        });
    }
예제 #8
0
    public IEnumerator SetHighRankingTextFromFailedResult()
    {
        NCMBQuery <NCMBObject> query  = new NCMBQuery <NCMBObject>(SceneManager.GetActiveScene().name);
        List <NCMBObject>      result = null;
        NCMBException          error  = null;

        if (TimeManager.Instance.CountTimeType == E_CountTimeType.CountUp)
        {
            query.OrderByAscending("ClearTime");                                                                //昇順
        }
        else
        {
            query.OrderByDescending("ClearTime");  //降順
        }
        query.Limit = 10;

        query.FindAsync((List <NCMBObject> _result, NCMBException _error) =>
        {
            result = _result;
            error  = _error;
        });

        //resultもしくはerrorが入るまで待機
        yield return(new WaitWhile(() => result == null && error == null));

        //後続処理
        if (error == null)
        {
            this.SetHighRankingTextFromFailedResult(result);
        }
    }
예제 #9
0
    //指定したレコードの前後のレコード取得
    public void getRankingNeighbors(string name, int gameModeId, Save_ranking_item save_Ranking_Item, CallbackRecordsList callback)
    {
        fetchRank(name, gameModeId, save_Ranking_Item, (int currentRank) =>
        {
            int numSkip = currentRank - 3;
            if (numSkip < 0)
            {
                numSkip = 0;
            }

            List <RankingRecord> rankingRecords = new List <RankingRecord>();
            NCMBQuery <NCMBObject> query        = new NCMBQuery <NCMBObject>(rankingClassName);
            query.WhereEqualTo("gameModeId", gameModeId);
            query.WhereEqualTo("type", (int)save_Ranking_Item);
            query.Skip  = numSkip;
            query.Limit = 5;
            switch (save_Ranking_Item)
            {
            case Save_ranking_item.SAVE_RANKING_HIGH:
                query.OrderByDescending("distance");
                query.AddAscendingOrder("timeSpan");
                break;

            case Save_ranking_item.SAVE_RANKING_LOW:
                query.OrderByAscending("distance");
                query.AddAscendingOrder("timeSpan");
                break;

            default:
                break;
            }
            query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
            {
                if (e == null)
                { //検索成功したら
                    for (int i = 0; i < objList.Count; i++)
                    {
                        string _name                = System.Convert.ToString(objList[i]["name"]);     // 名前を取得
                        float _distance             = System.Convert.ToSingle(objList[i]["distance"]); // スコアを取得
                        float _timeSpan             = System.Convert.ToSingle(objList[i]["timeSpan"]);
                        RankingRecord rankingRecord = new RankingRecord(numSkip + i + 1, _name, _distance, _timeSpan, save_Ranking_Item);
                        rankingRecords.Add(rankingRecord);
                    }
                    callback(rankingRecords);
                }
                else
                {
                    callback(rankingRecords);
                }
            });
        });
        return;
    }
예제 #10
0
        /// <summary>
        /// クエリ設定の反映を行う
        /// </summary>
        /// <returns>設定を反映したNCMBQueryのインスタンス</returns>
        /// <param name="query">設定を追加したいNCMBQueryのインスタンス</param>
        protected virtual NCMBQuery <NCMBObject> QuerySetting(NCMBQuery <NCMBObject> query)
        {
            switch (Sort)
            {
            case NCMBUTSortType.Ascending:
                query.OrderByAscending(SortField);
                break;

            case NCMBUTSortType.Descending:
                query.OrderByDescending(SortField);
                break;
            }

            query.Limit = Limit;
            query.Skip  = Skip;

            return(query);
        }
예제 #11
0
    /// <summary>
    /// @brief サーバーからrankの前後2件を取得 ---------------
    /// </summary>
    public void FetchNeighbors()
    {
        neighbors = new List <NCMB.HighScore>();

        // スキップする数を決める(ただし自分が1位か2位のときは調整する)
        int numSkip = currentRank - 3;

        if (numSkip < 0)
        {
            numSkip = 0;
        }

        // データストアの「HighScore」クラスから検索
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("HighScore");

        query.OrderByAscending("Score");
        query.Skip  = numSkip;
        query.Limit = 5;
        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e != null)
            {
                //検索失敗時の処理
            }
            else
            {
                //検索成功時の処理
                List <NCMB.HighScore> list = new List <NCMB.HighScore>();
                // 取得したレコードをHighScoreクラスとして保存
                foreach (NCMBObject obj in objList)
                {
                    double s = System.Convert.ToDouble(obj["Score"]);
                    string n = System.Convert.ToString(obj["Name"]);
                    list.Add(new HighScore(s, n));
                }
                neighbors = list;
            }
        });
    }
예제 #12
0
    // サーバーからトップ5を取得 ---------------
    public void fetchTopRankers()
    {
        // データストアの「Time」クラスから検索
        NCMBQuery<NCMBObject> query = new NCMBQuery<NCMBObject> ("Time");
        query.OrderByAscending ("time");
        query.Limit = 5;

        query.FindAsync ((List<NCMBObject> objList ,NCMBException e) => {

            if (e != null) {
                //検索失敗時の処理
            } else {
                //検索成功時の処理
                List<NCMB.Rankers> list = new List<NCMB.Rankers>();
                // 取得したレコードをtimeクラスとして保存
                foreach (NCMBObject obj in objList) {
                    string    t = System.Convert.ToString(obj["time"]);
                    list.Add( new Rankers(t) );
                }
                topRankers = list;
            }
        });
    }
예제 #13
0
    void Start()
    {
        RankingText = GetComponent <Text>();
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("Result");

        query.WhereEqualTo("stageId", StageId);
        query.OrderByAscending("time");
        query.Limit = 5;
        query.FindAsync((List <NCMBObject> objList, NCMBException err) =>
        {
            if (err == null)
            {
                RankingText.text = "";
                for (int i = 0; i < Mathf.Min(objList.Count, 5); i++)
                {
                    RankingText.text += "#" + (i + 1) + ": " + objList[i]["uName"] + "   " + ConvertTimeToString(objList[i]["time"].ToString()) + "\n";
                }
            }
            else
            {
                Debug.Log("ERROR!ネットワーク接続に問題が発生しました。");
            }
        });
    }
    /// <summary>
    /// サーバーからクリアタイムトップ5を取得
    /// </summary>
    public void FindClearTimeRankTop5()
    {
        // 検索条件がNULLならreturn
        if (clearStageName == null)
        {
            return;
        }

        // ランクリストを非表示にしてローディングを表示する
        loadingText.gameObject.SetActive(true);
        searchErrorText.gameObject.SetActive(false);
        for (int i = 0; i < DISP_RANK; i++)
        {
            TextMeshProUGUI rankText = GameObject.Find(RANK_ROW + (i + 1)).GetComponent <TextMeshProUGUI>();
            TextMeshProUGUI nameText = GameObject.Find(NAME_ROW + (i + 1)).GetComponent <TextMeshProUGUI>();
            TextMeshProUGUI timeText = GameObject.Find(TIME_ROW + (i + 1)).GetComponent <TextMeshProUGUI>();
            rankText.color = new Color(0f, 0f, 0f, 0f);
            nameText.color = new Color(0f, 0f, 0f, 0f);
            timeText.color = new Color(0f, 0f, 0f, 0f);
        }

        // クリアタイム降順でステージ名を条件に取得
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>(GameUtil.Const.NCMB_HIGHTIME_TABLE);

        query.WhereEqualTo(GameUtil.Const.NCMB_HIGHTIME_COL_STAGE, clearStageName);
        query.OrderByAscending(GameUtil.Const.NCMB_HIGHTIME_COL_TIME);
        query.Limit = DISP_RANK;
        query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
        {
            if (e != null)
            {
                // 取得失敗した場合
                Debug.Log("取得に失敗しました。ErrorCode : " + (string)e.ErrorMessage);
                // 取得失敗メッセージを表示する
                loadingText.gameObject.SetActive(false);
                searchErrorText.gameObject.SetActive(true);
            }
            else
            {
                // 取得成功した場合
                // リスト初期化
                dispHighRankList = new List <HighTime>();
                // 取得したレコードをHighScoreクラスとして保存
                foreach (NCMBObject obj in objList)
                {
                    string name = System.Convert.ToString(obj[GameUtil.Const.NCMB_HIGHTIME_COL_NAME]);
                    double time = System.Convert.ToDouble(obj[GameUtil.Const.NCMB_HIGHTIME_COL_TIME]);

                    dispHighRankList.Add(new HighTime(name, time));
                }

                // ランキングTOP5を更新
                loadingText.gameObject.SetActive(false);
                for (int i = 0; i < DISP_RANK; i++)
                {
                    TextMeshProUGUI rankText = GameObject.Find(RANK_ROW + (i + 1)).GetComponent <TextMeshProUGUI>();
                    TextMeshProUGUI nameText = GameObject.Find(NAME_ROW + (i + 1)).GetComponent <TextMeshProUGUI>();
                    TextMeshProUGUI timeText = GameObject.Find(TIME_ROW + (i + 1)).GetComponent <TextMeshProUGUI>();
                    rankText.color           = new Color(0f, 0f, 0f, 255f);
                    nameText.color           = new Color(0f, 0f, 0f, 255f);
                    timeText.color           = new Color(0f, 0f, 0f, 255f);
                    if (dispHighRankList != null && dispHighRankList.Count > i)
                    {
                        string name = dispHighRankList[i].name;
                        string time = dispHighRankList[i].time.ToString("n2");
                        // プレイヤー名を5文字以下にする
                        if (name.Length >= 5)
                        {
                            name = name.Substring(0, 5);
                        }
                        nameText.text = name;
                        timeText.text = time + " 秒";
                    }
                    else
                    {
                        nameText.text = "-";
                        timeText.text = "--.-- 秒";
                    }
                }
            }
        });
    }
예제 #15
0
    /* int a;
     * int b;
     * int c;
     * int[] aa;
     * int[] bb;
     *
     * int[] cc;
     */

    // Use this for initialization
    void Start()
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("Cheer");

        query.WhereNotEqualTo("Obj1", "");
        query.OrderByAscending("Suc1");
        query.FindAsync((List <NCMBObject> objectlist, NCMBException e) =>
        {
            foreach (NCMBObject obj in objectlist)
            {
                var item = GameObject.Instantiate(prefab) as RectTransform;
                item.SetParent(transform, false);
                var t         = item.transform.Find("Title");
                var title     = t.GetComponent <Text>();
                title.text    = (string)obj["Obj1"];
                var n         = item.transform.Find("Name");
                var name      = n.GetComponent <Text>();
                name.text     = (string)obj["Name"];
                var button    = item.transform.Find("Button").gameObject;
                var info      = button.GetComponent <Info>();
                info.sendname = (string)obj["Name"];


                // button.GetComponent<Info>().sendname =(string)obj["Name"];
                info.obj    = (string)obj["Obj1"];
                info.objnum = 1;
                info.forfor = (long)obj["For1"];


                info.suc  = (long)obj["Suc1"];
                info.fall = (long)obj["Fall1"];
                print(obj["Water1"].GetType());
                info.water = (long)obj["Water1"];
            }
        }
                        );

        /*
         *  NCMBQuery<NCMBObject> obj1 = query.WhereNotEqualTo("Suc1", "");
         *  NCMBQuery<NCMBObject> obj2 = query.WhereNotEqualTo("Suc2", "");
         *  NCMBQuery<NCMBObject> obj3 = query.WhereNotEqualTo("Suc3", "");
         *  obj1.OrderByAscending("Suc1");
         *  obj2.OrderByAscending("Suc2");
         *  obj3.OrderByAscending("Suc3");
         *
         *
         *  obj1.FindAsync((List<NCMBObject> objectlist, NCMBException e) =>
         *  {
         *      a = objectlist.Count;
         *      aa = new int[a];
         *      int aaa = 0;
         *    foreach(NCMBObject obj in objectlist)
         *      {
         *          aa[aaa] =(int)obj["Suc1"];
         *          aaa++;
         *      }
         *
         *
         *  });
         *  obj2.FindAsync((List<NCMBObject> objectlist, NCMBException e) =>
         *  {
         *      b = objectlist.Count;
         *      bb = new int[b];
         *      int bbb = 0;
         *      foreach (NCMBObject obj in objectlist)
         *      {
         *          aa[aaa] = (int)obj["Suc1"];
         *          aaa++;
         *      }
         *
         *
         *  });
         */
    }