void createEntity() { //printToConsole("Creating Entity..."); // Store all the information you want inside a dictionary Dictionary <string, object> movie = new Dictionary <string, object>(); movie ["name"] = name; movie["director"] = director; movie["duration"] = duration; movie["music"] = music; // Make the request to store the entity inside the desired collection GamedoniaData.Create("movies", movie, delegate(bool success, IDictionary data){ if (success) { //TODO Your success processing Application.LoadLevel("DataScene"); } else { //TODO Your success processing //printToConsole("Failed to create entity."); errorMsg = Gamedonia.getLastError().ToString(); Debug.Log(errorMsg); } }); }
public void AddMatch(Match match, bool addToServer = true, bool queueObject = false, bool sq = false) { if (addToServer) { GamedoniaData.Create("matches", getDictionaryMatch(match), delegate(bool success, IDictionary data){ if (success) { match.m_ID = data["_id"].ToString(); currentMatchID = match.m_ID; Save(); if (queueObject) { Debug.Log("create game queue object"); createGameQueueObject(); } } else { } }); } if (!matches.Contains(match)) { matches.Add(match); Save(); if (sq) { Loader.I.LoadScene("Category"); } } }
// *********************** GAMEDONIA SERVER FUNCTIONS******************************************* private void createGameQueueObject() { Dictionary <string, object> randomGame = new Dictionary <string, object>(); randomGame.Add("uid", PlayerManager.I.player.playerID); randomGame.Add("nickname", PlayerManager.I.player.profile.name); randomGame.Add("p_ID", PlayerManager.I.player.playerID); randomGame.Add("m_ID", currentMatchID); GamedoniaData.Create("randomqueue", randomGame); }
public void SubmitQuestion() { Loader.I.enableLoader(); string correctAnswer = ""; if (correctAnswerId.value == 0) { correctAnswer = "A"; } else if (correctAnswerId.value == 1) { correctAnswer = "B"; } else if (correctAnswerId.value == 2) { correctAnswer = "C"; } else if (correctAnswerId.value == 3) { correctAnswer = "D"; } Dictionary <string, object> question = new Dictionary <string, object>(); if (QuestionBackend.I.changeQuestion) { question["_id"] = QuestionBackend.I.currentQuestion.q_Id; } question["cId"] = (categoryId.value + 1); question["qT"] = QuestionTitleText.text; question["qA"] = AnswerAText.text; question["qB"] = AnswerBText.text; question["qC"] = AnswerCText.text; question["qD"] = AnswerDText.text; question["qCA"] = correctAnswer; question["sID"] = PlayerManager.I.player.playerID; question["qAp"] = 0; // Add 50 exp to the player if (!QuestionBackend.I.changeQuestion) { PlayerManager.I.player.playerXP = PlayerManager.I.player.playerXP += 50; } // Make the request to store the entity inside the desired collection if (!QuestionBackend.I.changeQuestion) { GamedoniaData.Create("questions", question, delegate(bool success, IDictionary data){ if (success) { Loader.I.LoadScene("QuestionAddedSuccess"); //TODO Your success processing } else { //TODO Your fail processing } }); } else { QuestionBackend.I.changeQuestion = false; QuestionBackend.I.currentQuestion = null; GamedoniaData.Update("questions", question, delegate(bool success, IDictionary data){ if (success) { Loader.I.LoadScene("MyQuestions"); } else { //TODO Your fail processing } }); } }