Beispiel #1
0
    public void UpdateKuni(string userId, int kuniId)
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("kuni");

        query.WhereEqualTo("userId", userId);
        query.WhereEqualTo("kuniId", kuniId);

        string naiseiTmp = "naisei" + kuniId.ToString();
        string jyosyuTmp = "jyosyu" + kuniId.ToString();

        string naisei = PlayerPrefs.GetString(naiseiTmp);
        string jyosyu = PlayerPrefs.GetString(jyosyuTmp);


        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e == null)
            {
                if (objList.Count == 0)   //never registered
                {
                    InsertKuni(userId, kuniId);
                }
                else    //Update
                {
                    objList[0]["kuniId"] = kuniId;
                    objList[0]["naisei"] = naisei;
                    objList[0]["jyosyu"] = jyosyu;
                    objList[0].SaveAsync();
                }
            }
        });
    }
    void DeleteLikeData(string user, string doodle)
    {
        //QueryTestを検索するクラスを作成
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("LikeRecord");

        //Scoreの値が7と一致するオブジェクト検索
        query.WhereEqualTo("user", user);
        query.WhereEqualTo("doodle", doodle);
        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e != null)
            {
                //検索失敗時の処理
            }
            else
            {
                //Scoreが7のオブジェクトを出力
                foreach (NCMBObject obj in objList)
                {
                    Debug.Log("delete objectId:" + obj.ObjectId);
                    obj.DeleteAsync((NCMBException deleteError) => {
                        if (deleteError != null)
                        {
                            //エラー処理
                        }
                        else
                        {
                            //成功時の処理
                        }
                    });
                }
            }
        });
    }
Beispiel #3
0
    //指定したユーザー名がランキング上に存在するかチェック(指定したモード)
    public void IsNameExistInRanking(string name, int gameModeId, Save_ranking_item save_Ranking_Item, CallbackBool callback)
    {
        isNameExist = false;

        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>(rankingClassName);

        query.WhereEqualTo("name", name);
        query.WhereEqualTo("gameModeId", gameModeId);
        query.WhereEqualTo("type", (int)save_Ranking_Item);
        query.CountAsync((int count, NCMBException e) =>
        { // 1つ上のコードで絞られたデータが何個あるかかぞえる
            if (e == null)
            {
                if (count == 0)
                { // 0個なら名前は登録されていない
                    isNameExist = false;
                }
                else
                { // 0個じゃなかったらすでに名前が登録されている
                    isNameExist = true;
                }
            }
            callback(isNameExist);
        });

        return;
    }
    void InitLike(int index)
    {
        if (likes.Count == images.Count)
        {
            this.likes [index].sprite = likeSprite;

            //QueryTestを検索するクラスを作成
            NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("LikeRecord");
            //Scoreの値が7と一致するオブジェクト検索
            query.WhereEqualTo("user", NCMBUser.CurrentUser.ObjectId);
            query.WhereEqualTo("doodle", imageData[index]["filename"].ToString());
            query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
                if (e != null)
                {
                    //検索失敗時の処理
                }
                else
                {
                    //Scoreが7のオブジェクトを出力
                    foreach (NCMBObject obj in objList)
                    {
                        this.likes[index].sprite = likeClickedSprite;
                    }
                }
            });
        }
    }
    void GetImageCount()
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("DoodleRecord");

        query.WhereEqualTo("date", DateTime.Now.Date);
        query.WhereEqualTo("type", pictureType);
        if (pictureType == "doodle")
        {
            query.WhereEqualTo("theme", Configuration.theme);
        }
        query.CountAsync((int count, NCMBException e) => {
            if (e != null)
            {
                //件数取得失敗時の処理
            }
            else
            {
                //件数を出力
                imageCount = count;
                if (imageCount == 0)
                {
                    noText.SetActive(true);
                }
            }
        });
    }
Beispiel #6
0
    void loadImages()
    {
        InitNowImageIndex();
        InitImages();

        //DoodleRecordを検索するクラスを作成
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("DoodleRecord");

        query.WhereEqualTo("date", DateTime.Now.Date);
        query.WhereEqualTo("type", "doodle");
        query.OrderByDescending("likes");
        //取得件数の指定
        query.Limit = maxCount;
        //取得開始位置の指定
        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e != null)
            {
                //検索失敗時の処理
            }
            else
            {
                foreach (NCMBObject obj in objList)
                {
                    Debug.Log("--------------------------------------------------------------");
                    NextImageIndex();
                    loadOneImageTo(obj["filename"].ToString(), nowImageIndex);
                }
            }
        });
    }
Beispiel #7
0
    //指定したレコードのランクを取得
    public void fetchRank(string name, int gameModeId, Save_ranking_item save_Ranking_Item, CallbackInt callback)
    {
        currentRank = 0;
        RankingRecord myRecord = null;
        // データスコアの「HighScore」から検索
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>(rankingClassName);

        query.WhereEqualTo("name", name);
        query.WhereEqualTo("gameModeId", gameModeId);
        query.WhereEqualTo("type", (int)save_Ranking_Item);
        query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
        {
            if (e == null && objList.Count > 0)
            {                                                                      //検索成功したら
                string _name    = System.Convert.ToString(objList[0]["name"]);     // 名前を取得
                float _distance = System.Convert.ToSingle(objList[0]["distance"]); // スコアを取得
                float _timeSpan = System.Convert.ToSingle(objList[0]["timeSpan"]);
                myRecord        = new RankingRecord(0, _name, _distance, _timeSpan, save_Ranking_Item);

                var query2 = new NCMBQuery <NCMBObject>(rankingClassName);
                query2.WhereEqualTo("gameModeId", gameModeId);
                query2.WhereEqualTo("type", (int)save_Ranking_Item);
                switch (save_Ranking_Item)
                {
                case Save_ranking_item.SAVE_RANKING_HIGH:
                    query2.WhereGreaterThanOrEqualTo("distance", myRecord.distance);
                    break;

                case Save_ranking_item.SAVE_RANKING_LOW:
                    query2.WhereLessThanOrEqualTo("distance", myRecord.distance);
                    break;

                default:
                    break;
                }

                query2.CountAsync((int count, NCMBException e2) =>
                {
                    if (e2 != null)
                    {
                        //件数取得失敗
                        callback(currentRank);
                    }
                    else
                    {
                        //件数取得成功
                        currentRank = count + 1; // 自分よりスコアが上の人がn人いたら自分はn+1位
                    }
                    callback(currentRank);
                });
            }
            else
            {
                callback(currentRank);
            }

            return;
        });
    }
Beispiel #8
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;
    }
        // サーバーからハイスコアを取得  -----------------
        public void fetch()
        {
            // データストアの「HighScore」クラスから、Nameをキーにして検索
              NCMBQuery<NCMBObject> query = new NCMBQuery<NCMBObject> ("HighScore");
              query.WhereEqualTo ("Name", name);
              query.FindAsync ((List<NCMBObject> objList ,NCMBException e) => {

              //検索成功したら
              if (e == null) {

            // ハイスコアが未登録だったら
            if( objList.Count == 0 )
              {
            NCMBObject obj = new NCMBObject("HighScore");
            obj["Name"]  = name;
            obj["Score"] = 0;
            obj.SaveAsync();
            score = 0;
              }

            // ハイスコアが登録済みだったら
            else {
              score = System.Convert.ToInt32( objList[0]["Score"] );
            }
              }
            });
        }
Beispiel #10
0
    public void GetRewardMaster(string userId)
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("reward");

        query.WhereEqualTo("userId", userId);
        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e == null)
            {
                foreach (NCMBObject obj in objList)
                {
                    objectIdList.Add(obj.ObjectId);
                    if (checkDataExist(obj, "title"))
                    {
                        itemTitleList.Add(System.Convert.ToString(obj["title"]));
                    }
                    if (checkDataExist(obj, "grp"))
                    {
                        itemGrpList.Add(System.Convert.ToString(obj["grp"]));
                    }
                    if (checkDataExist(obj, "rank"))
                    {
                        itemRankList.Add(System.Convert.ToString(obj["rank"]));
                    }
                    if (checkDataExist(obj, "qty"))
                    {
                        itemQtyList.Add(System.Convert.ToInt32(obj["qty"]));
                    }
                }
            }
        });
    }
Beispiel #11
0
    public void saveLevelRanking(string playerName, int score, int sankaku)
    {
        NCMBQuery <NCMBObject> query    = new NCMBQuery <NCMBObject>("LevelRanking"); // NCMB上のScoreRankingクラスを取得
        NCMBObject             cloudObj = new NCMBObject("LevelRanking");

        query.WhereEqualTo("playername", playerName); // プレイヤー名でデータを絞る
        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e == null)
            {     // データの検索が成功したら、
                if (objList.Count == 0)
                { // ハイスコアが未登録の場合
                    Debug.Log("新規登録");
                    cloudObj["playername"] = playerName;
                    cloudObj["level"]      = score;
                    cloudObj["sankaku"]    = sankaku;
                    cloudObj.SaveAsync(); // セーブ
                }
                else
                {                                                                 // ハイスコアが登録済みの場合
                    int cloudScore = System.Convert.ToInt32(objList[0]["level"]); // クラウド上のスコアを取得
                    Debug.Log("もうあるよ");
                    if (score > cloudScore)
                    {                                  // 今プレイしたスコアの方が高かったら、
                        Debug.Log("新記録!!");
                        objList[0]["level"]   = score; // それを新しいスコアとしてデータを更新
                        objList[0]["sankaku"] = sankaku;
                        objList[0].SaveAsync();        // セーブ
                    }
                }
            }
        });
    }
Beispiel #12
0
    public IEnumerator FileACLTest()
    {
        byte[]  data = System.Text.Encoding.UTF8.GetBytes("acl test");
        NCMBACL acl  = new NCMBACL();

        acl.PublicReadAccess = true;
        NCMBFile file = new NCMBFile("ACL.txt", data, acl);

        file.SaveAsync((NCMBException error) => {
            NCMBTestSettings.CallbackFlag = true;
        });

        yield return(NCMBTestSettings.AwaitAsync());

        NCMBTestSettings.CallbackFlag = false;

        NCMBQuery <NCMBFile> query = NCMBFile.GetQuery();

        query.WhereEqualTo("fileName", "ACL.txt");
        query.FindAsync((List <NCMBFile> objList, NCMBException error) => {
            Assert.Null(error);
            NCMBFile getFile = objList [0];
            Assert.True(getFile.ACL.PublicReadAccess);
            Assert.False(getFile.ACL.PublicWriteAccess);
            NCMBTestSettings.CallbackFlag = true;
        });

        yield return(NCMBTestSettings.AwaitAsync());

        Assert.True(NCMBTestSettings.CallbackFlag);
    }
Beispiel #13
0
    // Use this for initialization
    void Start()
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("ScoreRanking");

        query.WhereEqualTo("name", PlayerPrefs.GetString("KTbomb_user_name"));
        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e == null)
            {
                if (objList.Count != 0)
                {
                    foreach (NCMBObject obj in objList)
                    {
                        NCMBObject deleteClass = new NCMBObject("ScoreRanking");
                        deleteClass.ObjectId   = obj.ObjectId;
                        deleteClass.DeleteAsync();
                    }
                }
                NCMBObject rankingClass = new NCMBObject("ScoreRanking");
                // オブジェクトに値を設定
                rankingClass["name"]  = PlayerPrefs.GetString("KTbomb_user_name");
                rankingClass["score"] = PlayerPrefs.GetInt("KTbomb_high_score");
                // データストアへの登録
                rankingClass.SaveAsync((NCMBException error) => {
                    if (e == null)
                    {
                        fetchTopRankers();
                    }
                });
            }
        });
    }
    //アカウント情報を新たに生成する関数
    public void InstanceAccount()
    {
        //for (int i = 0; i < length; i++)
        //{
        //UserIDsを検索するクラスを作成
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("UserIDs");

        //IDの値が指定されたものと一致するオブジェクト検索
        query.WhereEqualTo("ID", AccountID[count]);
        query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
        {
            if (e != null)
            {
                //検索失敗時の処理
                Debug.Log("検索失敗です");
            }
            else
            {
                //IDが指定されたもののオブジェクトを出力
                foreach (NCMBObject obj in objList)
                {
                    AccountInstance[count].transform.GetChild(1).GetComponent <Text>().text = (string)obj["Name"];

                    count++;
                    if (count < length)
                    {
                        InstanceAccount();
                    }
                }
            }
        });
        //}
    }
Beispiel #15
0
        //---------------------------------------------------
        // SaveResultVictoryRecord
        //---------------------------------------------------
        public void SaveResultVictoryRecord(string name)
        {
            if (name != IGNORE_SAVE_SCORE_TEAM_NAME)
            {
                name = RESULT_RECORD_OTHER_TEAME_NAME;
            }

            NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("ResultRecord");

            query.WhereEqualTo("Name", name);
            query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
                if (e == null)
                {
                    if (objList.Count > 0)
                    {
                        int temp = Convert.ToInt32(objList[0]["VictoryNum"]);
                        objList[0]["VictoryNum"] = temp + 1;
                        objList[0].SaveAsync();
                    }
                    else
                    {
                        NCMBObject obj    = new NCMBObject("ResultRecord");
                        obj["Name"]       = name;
                        obj["VictoryNum"] = 1;
                        obj.SaveAsync();
                    }
                }
            });
        }
Beispiel #16
0
        /// <summary>
        /// NCMBQueryの新規作成
        /// </summary>
        /// <returns>NCMBQuery</returns>
        /// <param name="className">クラス名</param>
        protected NCMBQuery <NCMBObject> GetPlaneQuery(string className)
        {
            NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>(className);

            query.WhereEqualTo("isEnable", true);
            return(query);
        }
Beispiel #17
0
    public void FinisyEditNameButton()
    {
        errorText.SetActive(false);
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("DataBase");

        query.WhereEqualTo("id", id);
        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e == null)   // データの検索が成功したら、
            {
                objList[0]["name"] = inputField.text;
                objList[0].SaveAsync((NCMBException e2) => {
                    if (e2 == null)
                    {
                        GetRanking();
                    }
                });
                playerName    = inputField.text;
                nameText.text = playerName;
                PlayerPrefs.SetString("PlayerName", playerName);
                inputCanvas.enabled = false;
                AudioSourceManager.PlaySE(1);
            }
            else
            {
                errorText.SetActive(true);
                AudioSourceManager.PlaySE(4);
            }
        });
    }
Beispiel #18
0
    public void UpdateDataRecovery(string userId)
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("dataRecovery");

        query.WhereEqualTo("userId", userId);

        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e == null)
            {
                if (objList.Count == 0)   //never registered
                {
                    InsertDataRecovery(userId);
                }
                else    //Update
                {
                    foreach (NCMBObject obj in objList)
                    {
                        int count = 1;
                        if (checkDataExist(obj, "count"))
                        {
                            count = System.Convert.ToInt32(objList[0]["count"]) + 1;
                        }
                        Debug.Log(count);
                        objList[0]["count"] = count;
                        objList[0].SaveAsync();
                    }
                }
            }
        });
    }
Beispiel #19
0
    public void GetDataRecoveryCount(string userId)
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("dataRecovery");

        query.WhereEqualTo("userId", userId);
        query.CountAsync((int count, NCMBException e) => {
            if (e != null)
            {
                audioSources[4].Play();
                Message msg = new Message();
                msg.makeMessage(msg.getMessage(113));
                ResetValue();
            }
            else
            {
                //件数取得成功
                dataRecoveryCount = count;
                if (dataRecoveryCount != 0)
                {
                    audioSources[4].Play();
                    Message msg = new Message();
                    msg.makeMessage(msg.getMessage(149));
                    ResetValue();
                }
            }
        });
    }
Beispiel #20
0
    //名前変更確定ボタン
    public void CorrectButton()
    {
        //UserIDsを検索するクラスを作成
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("UserIDs");

        //IDの値がこのデータと一致するオブジェクト検索
        query.WhereEqualTo("ID", PlayerPrefs.GetString("IDCreateYet"));
        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e != null)
            {
                //検索失敗時の処理
                Debug.Log("検索失敗です");
            }
            else
            {
                //ユーザ名の変更をする
                foreach (NCMBObject obj in objList)
                {
                    //サーバ - 名前を変更
                    NameChangeMethod(obj);

                    //ゲーム - プレビューの表示を変更
                    NamePrev.text = NameInput.text;

                    //入力領域を空に
                    NameInput.text = "";

                    //名前変更パネルを非表示に
                    NameChangePanel.SetActive(false);
                }
            }
        });
    }
Beispiel #21
0
    public void SetScore()
    {
        nowLoadingCanvas.SetActive(true);
        AudioSourceManager.PlaySE(2);
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("DataBase");

        query.WhereEqualTo("id", id);
        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e == null)
            {
                // データベースを更新
                objList[0]["winCount"]  = newWinCount;
                objList[0]["loseCount"] = newLoseCount;
                objList[0].SaveAsync();
                PlayerPrefs.SetInt("WinCount", newWinCount);
                PlayerPrefs.SetInt("LoseCount", newLoseCount);
                nowLoadingCanvas.SetActive(false);
                finishLoadingCanvas.SetActive(true);
                AudioSourceManager.PlaySE(6);
            }
            else
            {
                // ネットワークに接続していない時
                nowLoadingCanvas.SetActive(false);
                failedLoadingCanvas.SetActive(true);
                AudioSourceManager.PlaySE(4);
            }
        });
    }
    public void FetchRanking(string userName, int score, string gameDifficulty)
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("ScoreRanking");

        query.WhereEqualTo("Name", userName);
        query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
        {
            if (e != null)//検索失敗時の処理
            {
                Debug.LogError(userName + "名前のユーザーは存在しません。新規登録かお名前の確認をお願いします。\n" + e.ErrorMessage);
            }
            else
            {
                if (objList.Count == 1)//ユーザー名が一つだけの時
                {
                    int cloudScore = System.Convert.ToInt32(objList[0]["Score"]);
                    if (cloudScore < score)
                    {
                        objList[0]["Score"] = score;
                        objList[0].SaveAsync();
                        PlayerStatus.Instance.HiScore = score;
                    }
                }
                else if (objList.Count <= 0)
                {
                    objList[0]["Name"]           = userName;
                    objList[0]["Score"]          = score;
                    objList[0]["GameDifficulty"] = gameDifficulty;
                    objList[0].SaveAsync();
                    PlayerStatus.Instance.HiScore = score;
                }
            }
        });
    }
Beispiel #23
0
    public void Read()
    {
        ButtonActivation(false);

        //QueryTestを検索するクラスを作成
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("TestClass");

        //Scoreの値が7と一致するオブジェクト検索
        query.WhereEqualTo("user_obj", NCMBUser.CurrentUser);
        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e != null)
            {
                //検索失敗時の処理
            }
            else
            {
                //Scoreが7のオブジェクトを出力
                foreach (NCMBObject obj in objList)
                {
                    Debug.Log(obj["message"]);
                    //Debug.Log("objectId:" + obj.ObjectId);
                }
                ButtonActivation(true);
            }
        });
    }
    public void GetScoreRankings(string gameDifficulty)
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("ScoreRanking");

        query.WhereEqualTo("GameDifficulty", gameDifficulty);
        query.OrderByDescending("Score");
        query.Limit = 5;

        query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
        {
            if (e != null)//検索失敗時の処理
            {
                Debug.Log("ランキングの情報がありません" + e.ErrorMessage);
            }
            else //成功時
            {
                if (objList.Count > 0)
                {
                    foreach (NCMBObject obj in objList)
                    {
                        string n = System.Convert.ToString(obj["Name"]);
                        int s    = System.Convert.ToInt32(obj["Score"]);
                        rankingList.Add(new ScoreRanking(n, s));
                    }
                }
                else
                {
                    return;
                }
            }
        });
    }
Beispiel #25
0
    //指定されたIDのアカウントを取得してくる関数
    public void GetAccount()
    {
        //UserIDsのクラスを検索
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("UserIDs");

        //検索条件を指定
        query.WhereEqualTo("ID", FamilyID.text);

        //IDの値が入力したものと一致するオブジェクト検索
        query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
        {
            if (e != null)
            {
                //検索失敗時の処理
            }
            else
            {
                //IDが入力したものの名前を出力 + パネル表示
                foreach (NCMBObject obj in objList)
                {
                    SerchCheckPanel.SetActive(true);
                    FamilyNameText.text  = (string)obj["Name"];
                    FamilyNameText2.text = (string)obj["Name"];
                    break;
                }
            }
        });
    }
Beispiel #26
0
    public void UpdateBusyo(string userId)
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("myBusyo");

        query.WhereEqualTo("userId", userId);

        string myBusyoString  = PlayerPrefs.GetString("myBusyo");
        string zukanBusyoHst  = PlayerPrefs.GetString("zukanBusyoHst");
        string gacyaDaimyoHst = PlayerPrefs.GetString("gacyaDaimyoHst");

        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e == null)
            {
                if (objList.Count == 0)   //never registered
                {
                    InsertBusyo(userId);
                }
                else    //Update
                {
                    objList[0]["myBusyo"]        = myBusyoString;
                    objList[0]["zukanBusyoHst"]  = zukanBusyoHst;
                    objList[0]["gacyaDaimyoHst"] = gacyaDaimyoHst;
                    objList[0].SaveAsync();
                }
            }
        });
    }
Beispiel #27
0
    public IEnumerator FileDeleteTest()
    {
        byte[]   data = System.Text.Encoding.UTF8.GetBytes("delete test");
        NCMBFile file = new NCMBFile("delete.txt", data);

        file.SaveAsync((NCMBException error) => {
            Assert.Null(error);
            NCMBTestSettings.CallbackFlag = true;
        });
        yield return(NCMBTestSettings.AwaitAsync());

        NCMBTestSettings.CallbackFlag = false;
        Assert.NotNull(file.CreateDate);

        file.DeleteAsync((NCMBException error) => {
            Assert.Null(error);
            NCMBTestSettings.CallbackFlag = true;
        });
        yield return(NCMBTestSettings.AwaitAsync());

        NCMBTestSettings.CallbackFlag = false;

        NCMBQuery <NCMBFile> query = NCMBFile.GetQuery();

        query.WhereEqualTo("fileName", "delete.txt");
        query.FindAsync((List <NCMBFile> objList, NCMBException error) => {
            Assert.Null(error);
            Assert.AreEqual(0, objList.Count);
            NCMBTestSettings.CallbackFlag = true;
        });
        yield return(NCMBTestSettings.AwaitAsync());

        Assert.True(NCMBTestSettings.CallbackFlag);
    }
Beispiel #28
0
    public void UpdateMap(string userId)
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("map");

        query.WhereEqualTo("userId", userId);

        string        seiryoku       = PlayerPrefs.GetString("seiryoku");
        string        openKuni       = PlayerPrefs.GetString("openKuni");
        string        clearedKuni    = PlayerPrefs.GetString("clearedKuni");
        string        keyHistory     = PlayerPrefs.GetString("keyHistory");
        List <string> keyHistoryList = new List <string>();

        char[] delimiterChars = { ',' };
        if (keyHistory != null && keyHistory != "")
        {
            if (keyHistory.Contains(","))
            {
                keyHistoryList = new List <string>(keyHistory.Split(delimiterChars));
            }
            else
            {
                keyHistoryList.Add(keyHistory);
            }
        }
        string gunzei = "";

        for (int n = 0; n < keyHistoryList.Count; n++)
        {
            string keyTemp  = keyHistoryList[n];
            string keyValue = PlayerPrefs.GetString(keyTemp);
            if (n == 0)
            {
                gunzei = keyValue;
            }
            else
            {
                gunzei = gunzei + "," + keyValue;
            }
        }


        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e == null)
            {
                if (objList.Count == 0)   //never registered
                {
                    InsertMap(userId);
                }
                else    //Update
                {
                    objList[0]["seiryoku"]    = seiryoku;
                    objList[0]["openKuni"]    = openKuni;
                    objList[0]["clearedKuni"] = clearedKuni;
                    objList[0]["keyHistory"]  = keyHistory;
                    objList[0]["gunzei"]      = gunzei;
                    objList[0].SaveAsync();
                }
            }
        });
    }
Beispiel #29
0
    // スコアセーブ
    void SaveScoreRanking(string playerName, int score)
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("ScoreRanking"); // NCMB上のScoreRankingクラスを取得

        query.WhereEqualTo("playername", playerName);                              // プレイヤー名でデータを絞る
        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e == null)
            {     // データの検索が成功したら、
                if (objList.Count == 0)
                { // スコアが未登録の場合
                    NCMBObject cloudObj    = new NCMBObject("ScoreRanking");
                    cloudObj["playername"] = playerName;
                    cloudObj["score"]      = score;
                    cloudObj.SaveAsync(); // セーブ
                }
                else
                {                                                                 // ハイスコアが登録済みの場合
                    int cloudScore = System.Convert.ToInt32(objList[0]["score"]); // クラウド上のスコアを取得
                    if (score > cloudScore)
                    {                                                             // 今プレイしたスコアの方が高かったら、
                        objList[0]["score"] = score;                              // それを新しいスコアとしてデータを更新
                        objList[0].SaveAsync();                                   // セーブ
                    }
                }
            }
        });
    }
Beispiel #30
0
        //IDを検索して取得
        void GetUserId()
        {
            num_id = PlayerPrefs.GetInt("UserId");

            //検索条件をローカルで持っていたユーザーIDにセット
            NCQ_.WhereEqualTo("UserId", num_id);
            //検索し、リスト化して処理実行
            NCQ_.FindAsync((List <NCMBObject> objList, NCMBException e) => {
                if (e != null)
                {
                    //検索失敗時の処理
                }
                else
                {
                    //検索成功時、見つかったObjを変数として保持
                    foreach (NCMBObject obj in objList)
                    {
                        //オブジェクトの新規作成をなかったことにして、代わりにサーバーからデータを取得
                        NCMB_.DeleteAsync((NCMBException g) => {
                            if (g == null)
                            {
                                NCMB_ = obj;
                                //取得したデータに置き換え
                                NCMB_.ObjectId = obj.ObjectId;
                                flg_accept     = true;
                            }
                        });
                    }
                }
            });
        }
Beispiel #31
0
    public void saveScoreRanking(string playerName, int score)
    {
        Debug.Log("saveScoreRanking");
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("Ranking"); // NCMB上のScoreRankingクラスを取得

        query.WhereEqualTo("playername", playerName);                          // プレイヤー名でデータを絞る//ここでqueryの設定
        query.FindAsync((List <NCMBObject> objList, NCMBException e) => {
            if (e == null)                                                     // データの検索が成功したら、
            {
                if (objList.Count == 0)                                        // ハイスコアが未登録の場合
                {
                    Debug.Log("cannot find your date");
                    NCMBObject cloudObj     = new NCMBObject("Ranking");
                    cloudObj ["playername"] = playerName;
                    cloudObj ["score"]      = score;
                    cloudObj.SaveAsync(); // セーブ
                }
                else                      // ハイスコアが登録済みの場合
                {
                    Debug.Log("find your date,update");
                    int cloudScore = System.Convert.ToInt32(objList[0]["score"]); // クラウド上のスコアを取得
                    if (score > cloudScore)                                       // 今プレイしたスコアの方が高かったら、
                    {
                        objList[0]["score"] = score;                              // それを新しいスコアとしてデータを更新
                        objList[0].SaveAsync();                                   // セーブ
                    }
                }
            }
            getScoreRanking();
        });
    }
 // サーバーからハイスコアを取得する
 public void fetch()
 {
     Debug.Log ("fetch name " + name);
     // データストアの「HighScore」から,Nameをキーにして検索する
     NCMBQuery<NCMBObject> query = new NCMBQuery<NCMBObject> ("HighScore");
     query.WhereEqualTo ("Name", name);
     query.FindAsync ((List<NCMBObject> objList ,NCMBException e) => {
         //検索が成功した場合
         if (e == null) {
             // ハイスコアが未登録だった場合
             if (objList.Count == 0) {
                 NCMBObject obj = new NCMBObject ("HighScore");
                 obj ["Name"] = name;
                 obj ["Score"] = 0;
                 obj.SaveAsync ();
                 //score = 0;
                 Debug.Log ("取得1");
             }
             // ハイスコアが登録済みだった場合
             else {
                 score = System.Convert.ToInt32 (objList [0] ["Score"]);
                 Debug.Log ("取得2");
             }
         }
     });
 }
Beispiel #33
0
 // サーバーにハイスコアを保持.
 public void save()
 {
     // データストアの「HighScore」クラスから、Nameをキーいして検索.
     NCMBQuery<NCMBObject> query = new NCMBQuery<NCMBObject>("HighScore");
     query.WhereEqualTo ("Name", name);
     query.FindAsync ((List<NCMBObject> objList, NCMBException e) => {
         // 検索に成功したら.
         if (e == null) {
             objList[0]["Score"] = score;
             objList[0].SaveAsync();
         }
     });
 }
Beispiel #34
0
 public void Login()
 {
     NCMBQuery<NCMBObject> query = new NCMBQuery<NCMBObject> ("TestClass");
     query.WhereEqualTo ("message", "Hello, Tarou!");
     query.FindAsync ((List<NCMBObject> objectList,NCMBException e) => {
         if (objectList.Count != 0) {
             NCMBObject obj = objectList [0];
             Debug.Log ("message : " + obj ["message"]);
         } else {
             NCMBObject testClass = new NCMBObject ("TestClass");
             testClass ["message"] = "Hello, NCMB!";
             testClass.SaveAsync ();
         }
     });
 }
Beispiel #35
0
    void OnGUI()
    {
        //getMessage from server
        NCMBQuery<NCMBObject> query = new NCMBQuery<NCMBObject> ("Message");
        query.WhereEqualTo ("placeid", "1");
        query.FindAsync ((List<NCMBObject> objectList,NCMBException e) => {
            if (objectList.Count != 0) {
                NCMBObject obj = objectList [0];
                string message = (string) obj["msg"];
                GUI.Label(new Rect(0,0,Screen.width,Screen.height), message);
                //Save log
                NCMBObject testClass = new NCMBObject ("ShowLog");
                testClass ["message"] = "Unitychan is showed";
                testClass.SaveAsync ();
            } else {

            }
        });
    }
Beispiel #36
0
    // Use this for initialization
    void Start()
    {
        NCMBQuery<NCMBObject> query = new NCMBQuery<NCMBObject>("TestClass");
        query.WhereEqualTo("message", "Hello, Tarou!");
        query.FindAsync((List<NCMBObject> objectList, NCMBException e) => {
            if (objectList.Count != 0)
            {
                NCMBObject obj = objectList[0];
                Debug.Log("message : " + obj["message"]);
            }
            else
            {
                NCMBObject testClass = new NCMBObject("TestClass");
                testClass["message"] = "Hello, NCMB!";
                testClass.SaveAsync();

                scoretext = Score.GetComponent<GUIText>();
                print("scoretext: " + scoretext);
                //scoretext.text = testClass["message"].ToString();
            }
        });
    }
Beispiel #37
0
    // サーバーからコメントをランダムに取得  -----------------
    public void fetchRandomly(int currentWave)
    {
        // データストアの「Comment」クラスから、Waveをキーにして検索
        NCMBQuery<NCMBObject> query = new NCMBQuery<NCMBObject> ("Comment");
        query.WhereEqualTo ("Wave", currentWave);
        query.FindAsync ((List<NCMBObject> commentList, NCMBException e) => {

            if (e != null) {
                //取得失敗時の処理
            } else {
                //取得成功時の処理
                if ( commentList.Count != 0 ) {
                    //取得したコメントの数を上限として、乱数を生成
                    System.Random random = new System.Random();
                    int i  = random.Next(commentList.Count);
                    //ランダムに選んだコメントを保持する
                    wave   = System.Convert.ToInt32 ( commentList[i]["Wave"]   );
                    text   = System.Convert.ToString( commentList[i]["Text"]   );
                    player = System.Convert.ToString( commentList[i]["Player"] );
                }
            }
        });
    }
Beispiel #38
0
		// ハイスコアを更新して保存 -------------------------
		public void updateScore()
		{
			#if False
			NCMBObject obj = new NCMBObject("HighScore");
			obj["Uuid"]  = uuid;
			obj["Name"]  = name;
			obj["Score"] = score;
			obj.SaveAsync();
			#else
			// データストアの「HighScore」クラスから、Uuidをキーにして検索
			NCMBQuery<NCMBObject> query = new NCMBQuery<NCMBObject> ("HighScore");
			query.WhereEqualTo ("Uuid", uuid);
			query.FindAsync ((List<NCMBObject> objList ,NCMBException e) => {
				
				//検索成功したら    
				if (e == null) {
					objList[0]["Score"] = score;
					objList[0]["Uuid"] = uuid;
					objList[0]["Name"] = name;
					objList[0].SaveAsync();
				}
			});
			#endif
		}
 // サーバーにハイスコアを保存する
 public void testSave()
 {
     Debug.Log ("testHighScore内スコア " + score + name);
     // データストアの「HighScore」クラスから,Nameをキーにして検索する
     NCMBQuery<NCMBObject> query = new NCMBQuery<NCMBObject> ("HighScore");
     query.WhereEqualTo ("Name", name);
     query.FindAsync ((List<NCMBObject> objList ,NCMBException e) => {
         //検索が成功した場合
         if (e == null) {
             objList [0] ["Score"] = score; // Score.scoreで誤魔化す?
             objList [0].SaveAsync ();
             Debug.Log ("testHighScore内スコア保存メソッド発動 " + score);
         }else{
             Debug.Log("NEETなう");
         }
     });
 }