/// <summary> /// @brief サーバーからハイスコアを取得 /// </summary> public void SarverFetch() { // データストアの「HighScore」クラスから、Nameをキーにして検索 NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("HighScore"); query.WhereEqualTo("Name", PlayerName); query.FindAsync((List <NCMBObject> objList, NCMBException e) => { //検索成功したら if (e == null) { // ハイスコアが未登録だったら if (objList.Count == 0) { NCMBObject obj = new NCMBObject("HighScore"); obj["Name"] = PlayerName; obj["Score"] = 10; obj.SaveAsync(); GameScore = 10; } // ハイスコアが登録済みだったら else { GameScore = System.Convert.ToDouble(objList[0]["Score"]); } } }); }
private void updateExistedInstallation(NCMBInstallation installation, string path) { //デバイストークンを更新 NCMBQuery <NCMBInstallation> query = NCMBInstallation.GetQuery(); //ObjectId検索 installation.GetDeviceToken((token, error) => { query.WhereEqualTo("deviceToken", token); query.FindAsync((List <NCMBInstallation> objList, NCMBException findError) => { if (findError != null) { OnRegistration(findError.ErrorMessage); } else if (objList.Count != 0) { installation.ObjectId = objList [0].ObjectId; installation.SaveAsync((NCMBException installationUpdateError) => { if (installationUpdateError != null) { OnRegistration(installationUpdateError.ErrorMessage); } else { OnRegistration(""); } }); } }); }); }
// サーバーにハイスコアを保存 ------------------------- 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(); } }); }
// サーバーにRateを保存 ------------------------- public void save() { // データストアの「HighScore」クラスから、Nameをキーにして検索 NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("ExpertData"); query.WhereEqualTo("Name", name); query.FindAsync((List <NCMBObject> objList, NCMBException e) => { //検索成功したら if (e == null) { objList[0]["Rating"] = rate; objList[0].SaveAsync(); isSaved = true; } }); }
/// <summary> /// @brief サーバーにハイスコアを保存 /// </summary> /// <param name="score">変数の説明</param> public void ServerSave(double score) { // データストアの「HighScore」クラスから、Nameをキーにして検索 NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("HighScore"); query.WhereEqualTo("Name", PlayerName); query.FindAsync((List <NCMBObject> objList, NCMBException e) => { //Debug.Log("tHighScore.score : " + score); //検索成功したら if (e == null) { //Debug.Log("tHighScore Save"); objList[0]["Score"] = score; objList[0].SaveAsync(); } }); }
// サーバーからrankの前後2件を取得 --------------- public void fetchNeighbors() { neighbors = new List <NCMB.HighScore>(); isCorrect = true; errorCode = null; // スキップする数を決める(ただし自分が1位か2位のときは調整する) int numSkip = currentRank - 3; if (numSkip < 0) { numSkip = 0; } // データストアの「HighScore」クラスから検索 NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("HighScore"); query.OrderByDescending("Score"); query.Skip = numSkip; query.Limit = HighScore.RANKING_MAX; query.FindAsync((List <NCMBObject> objList, NCMBException e) => { if (e != null) { //検索失敗時の処理 errorCode = e.ErrorCode; } else { //検索成功時の処理 List <NCMB.HighScore> list = new List <NCMB.HighScore>(); // 取得したレコードをHighScoreクラスとして保存 foreach (NCMBObject obj in objList) { int score = System.Convert.ToInt32(obj["Score"]); int stage = System.Convert.ToInt32(obj["Stage"]); string name = System.Convert.ToString(obj["Name"]); list.Add(new HighScore(score, stage, name)); } neighbors = list; } }); }
// サーバーからハイスコアを取得 ----------------- public void fetch() { isCorrect = true; errorCode = null; // データストアの「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["Stage"] = 0; obj.SaveAsync(); } // ハイスコアが登録済みだったら else { score = System.Convert.ToInt32(objList[0]["Score"]); stage = System.Convert.ToInt32(objList[0]["Stage"]); } isCorrectFinish = true; errorCode = null; } else { errorCode = e.ErrorCode; } }); }
// 思考の保存 public void save() { NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("ExpertData"); query.WhereEqualTo("Name", Name); query.FindAsync((List <NCMBObject> objList, NCMBException e) => { // 検索成功したら if (e == null) { isSearch = true; // 未登録だったら if (objList.Count == 0) { NCMBObject obj = new NCMBObject("ExpertData"); obj["Name"] = Name; obj["Rating"] = 1500; int type_count = (MyConnects.connectLists).Count; List <int[]> tmp_list = new List <int[]>(); for (int i = 0; i < type_count; i++) { int countConect = (MyConnects.connectLists[i]).Count; if (countConect == 0) { tmp_list.Add(new int[6] { 0, 0, 0, 0, 0, 0 }); } else { int[] tmp = new int[6 * countConect]; int idx = 0; // Debug.Log("countConect = "+countConect); foreach (int[] connect in MyConnects.connectLists[i]) { tmp[idx] = connect[0]; tmp[idx + 1] = connect[1]; tmp[idx + 2] = connect[2]; tmp[idx + 3] = connect[3]; tmp[idx + 4] = connect[4]; tmp[idx + 5] = connect[5]; idx = idx + 6; } tmp_list.Add(tmp); } } obj["Connect"] = tmp_list; obj.SaveAsync(); isNewSaved = true; } else { int type_count = (MyConnects.connectLists).Count; List <int[]> tmp_list = new List <int[]>(); for (int i = 0; i < type_count; i++) { int countConect = MyConnects.connectLists[i].Count; int[] tmp = new int[6 * countConect]; int idx = 0; // Debug.Log("countConect = "+countConect); foreach (int[] connect in MyConnects.connectLists[i]) { tmp[idx] = connect[0]; tmp[idx + 1] = connect[1]; tmp[idx + 2] = connect[2]; tmp[idx + 3] = connect[3]; tmp[idx + 4] = connect[4]; tmp[idx + 5] = connect[5]; idx = idx + 6; } /* * for(int i= 0; i<tmp.Length; i++){ * // Debug.Log(tmp[i]); * }*/ // Debug.Log("objList = "+objList.Count); tmp_list.Add(tmp); } objList[0]["Connect"] = tmp_list; objList[0].SaveAsync(); isSaved = true; isNoData = false; } // saver_alert.text = "サーバ連携 成功"; /* * if(User.Level == 5){ * User.LevelUP(); * }*/ } else { isSaved = false; isNoData = true; // saver_alert.text = "サーバ連携 失敗"; } //Invoke("SaverAlertOFF", 2); }); }
// サーバーから指定のAIを取得 public void fetch(string _name) { if (_name == "") { _name = Name; } // データストアの「HighScore」クラスから、Nameをキーにして検索 NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject> ("ExpertData"); query.WhereEqualTo("Name", _name); query.FindAsync((List <NCMBObject> objList, NCMBException e) => { //検索成功したら if (e == null) { // 対戦相手のデータがが未登録だったら if (objList.Count == 0) { isNoData = true; // Debug.Log("取得失敗"); } // 対戦相手のデータが登録済みだったら else { int idx = 0; int s_id; int s_state; int s_position; int flag; int e_id; int e_state; foreach (NCMBObject obj in objList) { int type_count = ((ArrayList)obj["Connect"]).Count; // 情報を消す Enemys.connectLists.Clear(); Enemys.name = _name; for (int i = 0; i < type_count; i++) { int count = ((ArrayList)((ArrayList)obj["Connect"])[i]).Count; List <int[]> tmp_connectLists = new List <int[]>(); var tmp_data = (ArrayList)(((ArrayList)obj["Connect"])[i]); for (int j = 0; j < count; j = j + 6) { s_id = (int)System.Convert.ToInt32(tmp_data[j]); s_state = (int)System.Convert.ToInt32(tmp_data[j + 1]); s_position = (int)System.Convert.ToInt32(tmp_data[j + 2]); flag = (int)System.Convert.ToInt32(tmp_data[j + 3]); e_id = (int)System.Convert.ToInt32(tmp_data[j + 4]); e_state = (int)System.Convert.ToInt32(tmp_data[j + 5]); tmp_connectLists.Add(new int[6] { s_id, s_state, s_position, flag, e_id, e_state }); } // 追加 Enemys.connectLists.Add(tmp_connectLists); } int ai_count = Enemys.connectLists.Count; for (int i = ai_count; i < NodeArrow.ai_type; i++) { Enemys.connectLists.Add(Enemys.connectLists[ai_count - 1]); } } // Debug.Log("取得成功"); isFetched = true; } } }); }