// Goal到着が検知されたとき void OnGoal() { goal = true; NCMBObject timeClass = new NCMBObject("Time"); timeClass["time"] = lapTime; timeClass.SaveAsync(); }
public void SaveScore(int score, bool isGoal, int star, float time, int playNum) { string objectId = PlayerPrefs.GetString(cPrefsObjectId, ""); bool isFirstTime = (objectId == ""); NCMBObject ranking = new NCMBObject(cClassName); if (!isFirstTime) { ranking.ObjectId = objectId; } ranking [cScoreKey] = score; ranking [cIsGoalKey] = isGoal; ranking [cStarKey] = star; ranking [cTimeKey] = time; ranking [cPlayNumKey] = playNum; ranking.SaveAsync((NCMBException e) => { if (e != null) { Debug.Log("Save Failed"); PlayerPrefs.SetInt("LastSaveSucceeded", 0); } else { Debug.Log("Save Succeeded"); Debug.Log(ranking.ObjectId); PlayerPrefs.SetString(cPrefsObjectId, ranking.ObjectId); PlayerPrefs.SetInt("LastSaveSucceeded", 1); FetchRanking(); } }); }
public void InsertBusyoStatus(string userId, string busyoId) { NCMBObject busyoStatusClass = new NCMBObject("myBusyoStatus"); string tempHei = "hei" + busyoId; string tempSenpou = "senpou" + busyoId; string tempSaku = "saku" + busyoId; string tempKahou = "kahou" + busyoId; string tempExp = "exp" + busyoId; string hei = PlayerPrefs.GetString(tempHei); int senpou = PlayerPrefs.GetInt(tempSenpou); int saku = PlayerPrefs.GetInt(tempSaku); string kahou = PlayerPrefs.GetString(tempKahou); int lv = PlayerPrefs.GetInt(busyoId); int exp = PlayerPrefs.GetInt(tempExp); busyoStatusClass["userId"] = userId; busyoStatusClass["busyoId"] = busyoId; busyoStatusClass["hei"] = hei; busyoStatusClass["senpou"] = senpou; busyoStatusClass["saku"] = saku; busyoStatusClass["kahou"] = kahou; busyoStatusClass["lv"] = lv; busyoStatusClass["exp"] = exp; busyoStatusClass.SaveAsync(); }
// 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(); } }); } }); }
/// <summary> /// メッセージを送信する /// </summary> /// <param name="obj">メッセージの送信相手</param> /// <param name="message">メッセージ内容</param> /// <param name="callback">コールバック関数</param> public void SendMessage(NCMBUser obj, string message, ErrorCallBack callback) { if (!GetIsLogIn) { callback(new NCMBException(NCMBUTErrorMessage.NOT_LOGIN_ERROR)); return; } if (message == "") { callback(new NCMBException(NCMBUTErrorMessage.EMPTY_MESSAGE)); return; } NCMBObject messageObj = GetClassObject(NCMBUTMessagesDefaultSettings.MESSAGE_CLASS); messageObj.Add(NCMBUTMessagesDefaultSettings.MessagesDefaultFields.message.ToString(), message); messageObj.Add(NCMBUTMessagesDefaultSettings.MessagesDefaultFields.from.ToString(), NCMBUser.CurrentUser); messageObj.Add(NCMBUTMessagesDefaultSettings.MessagesDefaultFields.to.ToString(), obj); messageObj.SaveAsync((NCMBException error) => { ClearValues(); callback(error); 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"]); } } }); }
/// <summary> /// スコア登録(NCMB) /// </summary> private void RegisterData4Ncmb() { string name = string.Empty; foreach (MaterialDropdown dropdown in nameDropdowns) { name += dropdown.buttonTextContent.text; } int score = gc.score; NCMBObject obj = new NCMBObject("HighScore"); obj["name"] = name; obj["score"] = score; obj.SaveAsync((NCMBException e) => { if (e != null) { // 登録失敗時の処理 ToastManager.Show("スコア登録に失敗しました"); } else { // 登録成功時の処理 ToastManager.Show("スコアを登録しました"); // リスト非表示 listAnimator.Play(defaultHash); FetchTopData4Ncmb(); } }); }
public void SendHighScore(int sendScore) { Debug.Log("hoge"); // nirty上の表の名前をインスタンス時のかっこの中に入れる NCMBObject obj = new NCMBObject("OnlineRanking"); // もともとObjectIdを持っていたらObjectIdをセットする if (PlayerPrefs.HasKey("ObjectId")) { obj.ObjectId = PlayerPrefs.GetString("ObjectId"); } // データカラムを追加する obj.Add("UserName", PlayerPrefs.GetString("name")); obj.Add("HighScore", sendScore); obj.SaveAsync((NCMBException e) => { if (e != null) { //エラー処理 Debug.Log("score data failed"); } else { //成功時の処理 Debug.Log("score data sent successfully"); PlayerPrefs.SetString("ObjectId", obj.ObjectId); } }); }
public void SaveObject(NCMBObject obj) { if (_created) { Debug.LogWarning("you can only one object save"); return; } if (_actNow) { Debug.LogWarning("now saving action:you cant additional save"); return; } _actNow = true; obj.SaveAsync((NCMBException e) => { if (e != null) { } else { _created = true; _objectID = obj.ObjectId; var json = GetJson_connectState(obj); _myNCMBState = JsonConverter.FromJson <NCMBStateData>(json).myNCMBstate; _serverNCMBState = _myNCMBState; Debug.Log("save end"); } }); }
void Start() { if (instance == null) { instance = this; } DontDestroyOnLoad(this); volumeClass = new NCMBObject("VolumeClass"); NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("VolumeClass"); query.FindAsync((List <NCMBObject> objList, NCMBException e) => { if (e == null) { if (objList.Count != 0) { volumeClass.ObjectId = objList[0].ObjectId; } } else { print("Error:" + e); } volumeClass["s"] = 0; volumeClass["a"] = 0; volumeClass.SaveAsync(); }); }
/// <summary> /// 非同期処理でオブジェクトの保存を行います。<br/> /// SaveAsync()を実行してから編集などをしていなく、保存をする必要が無い場合は通信を行いません。<br/> /// オブジェクトIDが登録されていない新規オブジェクトなら登録を行います。<br/> /// オブジェクトIDが登録されている既存オブジェクトなら更新を行います。<br/> /// </summary> /// <returns>もとのオブジェクト</returns> public static IObservable <NCMBObject> SaveAsyncAsStream(this NCMBObject origin) { return(Observable.Create <NCMBObject>(observer => { var gate = new object(); var isDisposed = false; origin.SaveAsync(error => { lock (gate) { if (isDisposed) { return; } if (error == null) { observer.OnNext(origin); observer.OnCompleted(); } else { observer.OnError(error); } } }); return Disposable.Create(() => { lock (gate) { isDisposed = true; } }); })); }
/// <summary> /// ユーザーデータの初期値をサーバーに保存する /// </summary> private void CreateDataToServer() { AppManager.Instance.user.m_id = System.Convert.ToInt32(m_NCMB_server ["LastUserId"]); AppManager.Instance.user.m_id += 1; //ユーザーデータ m_NCMB_server ["LastUserId"] = AppManager.Instance.user.m_id; m_NCMB_ ["UserId"] = AppManager.Instance.user.m_id; //初期化 Dictionary <string, object> dic = new Dictionary <string, object>(); ArrayList list = new ArrayList(); list.Add(0); dic["GoalTime"] = list; m_NCMB_ ["data_Stage1"] = dic; dic = new Dictionary <string, object>(); list = new ArrayList(); list.Add(0); dic["GoalTime"] = list; m_NCMB_ ["data_Stage2"] = dic; //現状をセーブ Save(); m_NCMB_server.SaveAsync((NCMBException h) => { if (h != null) { //再接続用モーダルを表示 UIManager.Instance.PopupNetworkErrorModal(() => { this.Start(); }); } }); }
//データ保存 public void SaveScore() { string score = text_Score.text; string name = text_inputField.text; int scoreInt = int.Parse(score); if (name.Length == 0) { text_caution.text = "1文字以上は入力してください"; } else if (name.Length >= 21) { text_caution.text = "21文字以下で入力してください"; } else { NCMBObject obj = new NCMBObject("Helloween"); obj["Name"] = name; obj ["Score"] = scoreInt; obj.SaveAsync(); gameObject.SetActive(false); inputFiled.SetActive(false); Invoke("DelayMethod", 2.0f); } }
public void DemoNCMBConnect() { NCMBObject ncmbObj = new NCMBObject("TestClass"); if (inputField.text != null) { ncmbObj["name"] = inputField.text; } else { ncmbObj["name"] = "Test"; } ncmbObj["message"] = "Hello NCMB !!!"; ncmbObj.SaveAsync((NCMBException e) => { if (e != null) { result.text += "保存に失敗しました。\n ErrorCode : " + (string)e.ErrorMessage + "\n"; Debug.Log("保存に失敗: " + e.ErrorMessage); } else { Name.text = ncmbObj["name"].ToString(); result.text += "保存に成功しました。\n objectId : " + (string)ncmbObj.ObjectId + "\n"; Debug.Log("保存に成功"); } }); }
//新規ユーザー登録 public void SaveNewUser(string name, CallbackBool callback) { isNameExist = false; NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>(usersClassName); query.WhereEqualTo("name", name); // 古い名前でデータを絞る query.FindAsync((List <NCMBObject> objList, NCMBException e) => { if (e == null) { //検索成功したら if (objList.Count > 0) { // 1個以上あれば isNameExist = true; } else { NCMBObject obj = new NCMBObject(usersClassName); obj["name"] = name; // 新しい名前にする obj.SaveAsync((NCMBException e2) => { if (e2 == null) { GameMaster.gameMaster.Save(); } }); } } callback(isNameExist); }); return; }
public void OnStartButtonClicked() { state = State.TOSTANDBY; animator.Play(ttl2StbHash); // プレイカウント加算 playCount++; #if OJU_ATSUMARU // イベントトリガー am.OnEventRaised("Start"); #else // ObjectIdをもとにデータ取得を行う NCMBObject obj = new NCMBObject("Count"); obj.ObjectId = startCountObjId; obj.FetchAsync((NCMBException e) => { if (e != null) { // 取得失敗時の処理 } else { // 取得成功時の処理 // スタートカウント加算 obj.Increment("count"); obj.SaveAsync(); } }); #endif }
public void SendData() { // クラスのNCMBObjectを作成 NCMBObject obj = new NCMBObject("HighScore"); // オブジェクトに値を設定 if (PlayerPrefs.HasKey("objectId")) { obj.ObjectId = PlayerPrefs.GetString("objectId"); } obj ["name"] = name; obj ["score"] = score; obj.SaveAsync((NCMBException e) => { if (e != null) { //エラー処理 } else { //成功時の処理 PlayerPrefs.SetString("objectId", obj.ObjectId); } }); }
// mobile backendに接続------------------------ public void save( string name, int score ) { NCMBObject obj = new NCMBObject ("Score"); obj ["name"] = name;//オブジェクトに名前とスコアを設定 obj ["score"] = score; obj.SaveAsync ();//この処理でサーバーに書き込む }
/// <summary> /// NCMBObjectの保存を行う /// </summary> /// <param name="targetObj">保存を行うNCMBObject</param> /// <param name="callback">コールバック関数</param> private void saveRecord(NCMBObject obj, ErrorCallBack callback) { obj.SaveAsync((NCMBException error) => { ClearValues(); callback(error); }); }
public void SavePlayerData() { string name = PlayerPrefs.GetString("name"); int score = PlayerPrefs.GetInt("score"); NCMBObject obj = new NCMBObject("HighScore"); if (PlayerPrefs.HasKey("objectId")) { obj.ObjectId = PlayerPrefs.GetString("objectId"); } obj.Add("name", name); obj.Add("score", score); obj.SaveAsync((NCMBException e) => { if (e != null) { Debug.Log("保存失敗、通信環境を確認してください"); } else { Debug.Log("保存成功!"); if (PlayerPrefs.HasKey("objectId") == false) { PlayerPrefs.SetString("objectId", obj.ObjectId); } } }); }
public void SaveGraveInfo(string userName, string deathMessage, GraveInfo.CurseType curseType, Vector3 position) { //ユーザー名が空の場合"Unknown"に// userName = string.IsNullOrEmpty(userName) ? "Unknown" : userName; //プレイヤーが死んだ位置を加工// position = new Vector3(position.x, 0f, position.z); double[] positionDoubleArray = Utility.Vector3toDoubleArray(position); //データストアにGraveクラスを定義// NCMBObject ncmbObject = new NCMBObject("Grave"); //Message・UserName・Position・CurseTypeをKeyに、それぞれValueを設定// ncmbObject.Add("Message", deathMessage); ncmbObject.Add("UserName", userName); ncmbObject.Add("Position", positionDoubleArray); ncmbObject.Add("CurseType", (int)curseType); //非同期でデータを保存する// ncmbObject.SaveAsync((NCMBException e) => { if (e != null) { //エラー処理 } else { Main.Instance.OnInGame(); } }); }
// サーバーからハイスコアを取得 ----------------- 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"] ); } } }); }
public void OkButton() { errorText.SetActive(false); NCMBObject database = new NCMBObject("DataBase"); string id = Guid.NewGuid().ToString(); database["id"] = id; database["name"] = inputField.text; database["winCount"] = 0; database["loseCount"] = 0; database.SaveAsync((NCMBException e) => { if (e == null) { PlayerPrefs.SetString("ID", id); PlayerPrefs.SetString("PlayerName", inputField.text); PlayerPrefs.SetInt("WinCount", 0); PlayerPrefs.SetInt("LoseCount", 0); PlayerPrefs.SetInt("FirstOpen", 1); Invoke("toTitle", 0.25f); AudioSourceManager.PlaySE(1); } else { errorText.SetActive(true); AudioSourceManager.PlaySE(4); } }); GameObject.Find("OkButton").GetComponent <Animation>().Play(); }
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(); }); }
//--------------------------------------------------- // 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(); } } }); }
public void ACLObject() { //NCMBACLオブジェクトを作成 NCMBACL acl = new NCMBACL(); //読み込み権限を全開放 acl.PublicReadAccess = true; //書き込み権限を全開放 acl.PublicWriteAccess = true; NCMBObject obj = new NCMBObject("TestClass"); obj.Add("Name", "Unity"); obj.Add("message", "ACL"); obj.ACL = acl; obj.SaveAsync((NCMBException e) => { if (e != null) { //エラー処理 Debug.LogError(e); } else { //成功時の処理 lastedObjectID = obj.ObjectId; Debug.Log("Save object with ACL success " + lastedObjectID); } }); }
// スコアセーブ 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(); // セーブ } } } }); }
public void UpdateObject() { if (lastedObjectID != null) { NCMBObject obj2 = new NCMBObject("TestClass"); obj2.ObjectId = lastedObjectID; obj2.FetchAsync((NCMBException e) => { if (e != null) { //エラー処理 Debug.LogError(e); } else { obj2["message"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); obj2.SaveAsync((NCMBException e2) => { if (e2 != null) { //エラー処理 Debug.LogError(e2); } else { //成功時の処理 lastedObjectID = obj2.ObjectId; Debug.Log("Update object success " + lastedObjectID); } }); } }); } }
/// <summary> /// スコアの保存. /// </summary> void HighScoreSetter(string playerName, int score) { NCMBObject obj = new NCMBObject ("HighScore"); obj ["Name"] = playerName; obj ["Score"] = score; obj.SaveAsync (); }
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(); // セーブ } } } }); }
public void InsertPvP(string userId, string PvPName) { int pvpHeiryoku = PlayerPrefs.GetInt("pvpHeiryoku"); if (pvpHeiryoku == 0) { pvpHeiryoku = PlayerPrefs.GetInt("jinkeiHeiryoku"); } int kuniLv = PlayerPrefs.GetInt("kuniLv"); int jinkei = PlayerPrefs.GetInt("jinkei"); string soudaisyoTmp = "soudaisyo" + jinkei.ToString(); int soudaisyo = PlayerPrefs.GetInt(soudaisyoTmp); NCMBObject pvpClass = new NCMBObject("pvp"); pvpClass["userId"] = userId; pvpClass["userName"] = PvPName; pvpClass["kuniLv"] = kuniLv; pvpClass["jinkeiHeiryoku"] = pvpHeiryoku; pvpClass["atkNo"] = 0; pvpClass["atkWinNo"] = 0; pvpClass["dfcNo"] = 0; pvpClass["dfcWinNo"] = 0; pvpClass["totalWinNo"] = 0; pvpClass["soudaisyo"] = soudaisyo; pvpClass.SaveAsync(); }
// サーバーからハイスコアを取得する 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"); } } }); }
// Use this for initialization void Start() { //425まで実施ずみ int fromRank = 426; int toRank = 430; List <string> grpList = new List <string> { "busyo", "kaho", "syokaijyo", "money" }; List <int> qtyList = new List <int> { 1, 2, 1, 30000 }; List <string> rankList = new List <string> { "B", "B", "B", "C" }; for (int i = fromRank; i < toRank + 1; i++) { for (int j = 0; j < 4; j++) { NCMBObject query = new NCMBObject("reward"); query["title"] = "合戦場報酬" + i + "位"; query["grp"] = grpList[j]; query["qty"] = qtyList[j]; query["rank"] = rankList[j]; query.SaveAsync(); } } }
public IEnumerator UpdateObject() { // テストデータ作成 NCMBUser anonymousUser = new NCMBUser(); Dictionary <string, object> param = new Dictionary <string, object>(); Dictionary <string, object> anonymousParam = new Dictionary <string, object>() { { "id", "anonymousId" } }; param.Add("anonymous", anonymousParam); anonymousUser.AuthData = param; anonymousUser.SignUpAsync((NCMBException e) => { Assert.Null(e); Assert.NotNull(NCMBUser.CurrentUser); Assert.IsTrue(NCMBUser.CurrentUser.IsLinkWith("anonymous")); NCMBObject obj = new NCMBObject("TestClass"); obj.ObjectId = "dummyObjectId"; obj.Add("key", "newValue"); obj.SaveAsync((NCMBException ex) => { Assert.Null(ex); NCMBTestSettings.CallbackFlag = true; }); }); yield return(NCMBTestSettings.AwaitAsync()); Assert.NotNull(NCMBUser.CurrentUser); Assert.IsTrue(NCMBUser.CurrentUser.IsLinkWith("anonymous")); }
void IDSet() { NCMBObject onlineRanking = new NCMBObject("OnlineRanking"); onlineRanking["UserName"] = nameinput.text; onlineRanking["Score"] = 0; onlineRanking["Item1"] = 0; onlineRanking["Item2"] = 0; onlineRanking["Item3"] = 0; onlineRanking.SaveAsync((NCMBException e) => { if (e != null) { Debug.Log("Miss"); connecttext.text = "接続に失敗しました"; connectmessage = true; connectmessagetimer = 0; } else { Debug.Log("ObjectID=" + onlineRanking.ObjectId); PlayerPrefs.SetString("ID", onlineRanking.ObjectId); howtoclosebutton.SetActive(false); howtoplaypanel.SetActive(true); connecttext.text = ""; namepanel.SetActive(false); PlayerPrefs.SetString("Name", nameinput.text); } }); }
// サーバーにコメントを保存 ------------------------- public void save() { // Commentクラスのオブジェクトをつくる NCMBObject obj = new NCMBObject ("Comment"); // フィールドを設定して保存 obj["Wave"] = wave; obj["Text"] = text; obj["Player"] = player; obj.SaveAsync (); }
// mobile backendに接続------------------------ public void save( string name, int score ) { NCMBObject obj = new NCMBObject ("Score"); obj.Add ("name", name);//オブジェクトに名前とスコアを設定 obj.Add ("score", score); obj.SaveAsync ((NCMBException e) => { if (e != null) { //エラー処理 } else { //成功時の処理 } });//この処理でサーバーに書き込む }
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 (); } }); }
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 { } }); }
// 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(); } }); }
// ハイスコアを更新して保存 ------------------------- 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 }