/// <summary> /// This function is used to setup the customizable game data once it receives JSON data /// from the game loop. A following Setup() function is called to complete non-JSON setup /// and start the game. /// </summary> /// <param name="json"></param> public void SetupFromString(string json) { Debug.Log(json); cg = JsonUtility.FromJson <DO_CountingGame>(json); // Setup game data itemMax = cg.itemMax; collectNum = cg.collectNum; collectItem = gameLoop.controller.GetWordById(cg.collectWordId); distractorItems = new List <string>(); foreach (int wordId in cg.wordIds) { if (wordId != cg.collectWordId) { distractorItems.Add(gameLoop.controller.GetWordById(wordId)); } } distractorItems.Shuffle(); // Setup extra features hints = cg.hints; countAudio = cg.countAudio; startAudio = cg.startAudio; defaultImg = cg.defaultImg; // Finish setup and start the game Setup(); }
/// <summary> /// This method takes the list of words from the current selected word list, /// creates a Counting Game data object from it and sends it off to the model /// via the controller. /// <seealso cref="CON_PlayList.AddOrEditEntry(string, int, object)"/> /// <seealso cref="MOD_PlayList.AddOrEditEntryData(int, int, string, string)"/> /// <seealso cref="DO_CountingGame"/> /// </summary> public void Save() { // Set the duration value to 1. int duration = 1; if (sceneName == countingScene) { // Create bools for the toggle options bool hints = optionsPanel.transform.Find("HintsToggle").gameObject.GetComponent <Toggle>().isOn; bool countAudio = optionsPanel.transform.Find("CountAudioToggle").gameObject.GetComponent <Toggle>().isOn; bool defaultImg = optionsPanel.transform.Find("DefaultImageToggle").gameObject.GetComponent <Toggle>().isOn; bool startAudio = false; // Create the collect and Item Max numbers int collectNum = Convert.ToInt32(collectNumField.text); int itemMax = Convert.ToInt32(itemMaxField.text); DO_CountingGame tempCounting = new DO_CountingGame(CreateWordIdList(), collectNum, itemMax, hints, countAudio, startAudio, defaultImg); if (controller.AddOrEditEntry(countingStr, duration, tempCounting)) { saveSuccessModal.SetActive(true); } else { saveErrorModal.SetActive(true); // TODO: Log an error } } }
private void AutoPlaylistCreateEntry(string gameType, int gameConfig, List <int> wordIDsList) { if (gameType == "scramble" && selectedGamesList.Contains("Word_Scramble")) { DO_WordScramble tempScramble = new DO_WordScramble(wordIDsList); controller.CreatingNew(); controller.AddOrEditEntry("Word Scramble", 1, tempScramble); } if (gameType == "flash" && selectedGamesList.Contains("Flash_Card")) { DO_FlashCard tempFlash = new DO_FlashCard(wordIDsList); controller.CreatingNew(); controller.AddOrEditEntry("Flash Card", 1, tempFlash); } if (gameType == "keyboard" && selectedGamesList.Contains("Keyboard_Game")) { if (gameConfig == 0) { DO_KeyboardGame tempKeyboard = new DO_KeyboardGame(wordIDsList, true, true, false, true, true); controller.CreatingNew(); controller.AddOrEditEntry("Keyboard Game", 1, tempKeyboard); } else if (gameConfig == 1) { DO_KeyboardGame tempKeyboardTwo = new DO_KeyboardGame(wordIDsList, true, true, false, true, false); controller.CreatingNew(); controller.AddOrEditEntry("Keyboard Game", 1, tempKeyboardTwo); } } if (gameType == "counting" && selectedGamesList.Contains("Couting_Game")) { DO_CountingGame countingGame = new DO_CountingGame(wordIDsList, 3, 10, true, true, true, false); controller.CreatingNew(); controller.AddOrEditEntry("Counting Game", wordIDsList.Count, countingGame); } if (gameType == "matching" && selectedGamesList.Contains("Matching_Game")) { DO_MatchingGame matchingGame = new DO_MatchingGame(wordIDsList, false, true); controller.CreatingNew(); controller.AddOrEditEntry("Matching Game", 1, matchingGame); } if (gameType == "memory" && selectedGamesList.Contains("Memory_Cards")) { DO_MemoryCards tempMemory = new DO_MemoryCards(wordIDsList, true, false, true); controller.CreatingNew(); controller.AddOrEditEntry("Memory Cards", 1, tempMemory); } }
public bool ValidateChild(DataService data) { switch (type_id) { case 0: DO_WordScramble scramble = JsonUtility.FromJson <DO_WordScramble>(json); return(scramble.ValidateData(data)); case 1: // TODO: FINISH THE CHECK //DO_Reward reward = DictionarySerializeUtil.JsonToRewardDictionary(json); //return reward.ValidateData(data); return(true); case 2: // TODO: FINISH THE CHECK DO_FlashCard flash = JsonUtility.FromJson <DO_FlashCard>(json); return(flash.ValidateData(data)); case 3: DO_CountingGame counting = JsonUtility.FromJson <DO_CountingGame>(json); return(counting.ValidateData(data)); case 4: DO_KeyboardGame keyboard = JsonUtility.FromJson <DO_KeyboardGame>(json); return(keyboard.ValidateData(data)); case 5: DO_MemoryCards memory = JsonUtility.FromJson <DO_MemoryCards>(json); return(memory.ValidateData(data)); case 6: DO_MatchingGame matching = JsonUtility.FromJson <DO_MatchingGame>(json); return(matching.ValidateData(data)); default: // TODO: throw and log an error Debug.Log("Error in DO_PlaylistObject"); return(false); } }
void Start() { sceneName = SceneManager.GetActiveScene().name; // Populate the add new scrollview MAS_PlayList tempMaster = (MAS_PlayList)COM_Director.GetMaster("MAS_PlayList"); controller = (CON_PlayList)tempMaster.GetController("CON_PlayList"); if (controller.CheckIfNewEntry()) { PopulateAvailableViewOnly(); } else if (sceneName == countingScene) { counting = JsonUtility.FromJson <DO_CountingGame>(controller.GetJsonByIndex(controller.GetActiveContextIndex())); ToggleAllToggles(); SetAllInputValues(); PopulateBothViews(); } }
/// <summary> /// Creates a hash set of word ids that are currently being used by one or more /// play lists. /// </summary> public void PopulateInUseSet() { // Check if the inUse Hash set is initialized yet if (inUseWordIds == null) { inUseWordIds = new HashSet <int>(); } else { inUseWordIds.Clear(); } foreach (var entry in dataService.GetPlayList()) { switch (entry.type_id) { case 0: DO_WordScramble scramble = JsonUtility.FromJson <DO_WordScramble>(entry.json); inUseWordIds.UnionWith(scramble.wordIdList); break; case 2: DO_FlashCard flash = JsonUtility.FromJson <DO_FlashCard>(entry.json); inUseWordIds.UnionWith(flash.wordIdList); break; case 3: DO_CountingGame counting = JsonUtility.FromJson <DO_CountingGame>(entry.json); inUseWordIds.UnionWith(counting.wordIds); break; case 4: DO_KeyboardGame keyboard = JsonUtility.FromJson <DO_KeyboardGame>(entry.json); inUseWordIds.UnionWith(keyboard.wordIdList); break; case 5: DO_MemoryCards memory = JsonUtility.FromJson <DO_MemoryCards>(entry.json); inUseWordIds.UnionWith(memory.wordIdList); break; case 6: DO_MatchingGame matching = JsonUtility.FromJson <DO_MatchingGame>(entry.json); inUseWordIds.UnionWith(matching.wordIdList); break; default: break; } /* * * case 6: * break; * case 7: * break; * case 8: * break; * case 9: * break; * case 10: * break; * case 11: * break; */ } }
public string CreateActivityListString(int index, int typeId) { StringBuilder builder = new StringBuilder(); int max; switch (typeId) { case 0: DO_WordScramble scramble = JsonUtility.FromJson <DO_WordScramble>(model.GetJsonData(index)); max = scramble.wordIdList.Count; for (int idx = 0; idx < max; idx++) { if (idx == (max - 1)) { builder.AppendFormat("{0}", TidyCase(model.wordDict[scramble.wordIdList[idx]])); } else { builder.AppendFormat("{0}{1}", (TidyCase(model.wordDict[scramble.wordIdList[idx]])), ", "); } } break; case 1: DO_ChooseReward reward = JsonUtility.FromJson <DO_ChooseReward>(model.GetJsonData(index)); max = reward.rewardIdsList.Count; break; case 2: DO_FlashCard flash = JsonUtility.FromJson <DO_FlashCard>(model.GetJsonData(index)); max = flash.wordIdList.Count; for (int idx = 0; idx < max; idx++) { if (idx == (max - 1)) { builder.AppendFormat("{0}", TidyCase(model.wordDict[flash.wordIdList[idx]])); } else { builder.AppendFormat("{0}{1}", (TidyCase(model.wordDict[flash.wordIdList[idx]])), ", "); } } break; case 3: DO_CountingGame counting = JsonUtility.FromJson <DO_CountingGame>(model.GetJsonData(index)); max = counting.wordIds.Count; for (int idx = 0; idx < max; idx++) { if (idx == (max - 1)) { builder.AppendFormat("{0}", TidyCase(model.wordDict[counting.wordIds[idx]])); } else { builder.AppendFormat("{0}{1}", (TidyCase(model.wordDict[counting.wordIds[idx]])), ", "); } } break; case 4: DO_KeyboardGame keyboard = JsonUtility.FromJson <DO_KeyboardGame>(model.GetJsonData(index)); max = keyboard.wordIdList.Count; for (int idx = 0; idx < max; idx++) { if (idx == (max - 1)) { builder.AppendFormat("{0}", TidyCase(model.wordDict[keyboard.wordIdList[idx]])); } else { builder.AppendFormat("{0}{1}", (TidyCase(model.wordDict[keyboard.wordIdList[idx]])), ", "); } } break; case 5: DO_MemoryCards memory = JsonUtility.FromJson <DO_MemoryCards>(model.GetJsonData(index)); max = memory.wordIdList.Count; for (int idx = 0; idx < max; idx++) { if (idx == (max - 1)) { builder.AppendFormat("{0}", TidyCase(model.wordDict[memory.wordIdList[idx]])); } else { builder.AppendFormat("{0}{1}", (TidyCase(model.wordDict[memory.wordIdList[idx]])), ", "); } } break; case 6: DO_MatchingGame matching = JsonUtility.FromJson <DO_MatchingGame>(model.GetJsonData(index)); max = matching.wordIdList.Count; for (int idx = 0; idx < max; idx++) { if (idx == (max - 1)) { builder.AppendFormat("{0}", TidyCase(model.wordDict[matching.wordIdList[idx]])); } else { builder.AppendFormat("{0}{1}", (TidyCase(model.wordDict[matching.wordIdList[idx]])), ", "); } } break; default: // TODO: log an error return(null); } return(builder.ToString()); //case 7: // break; //case 8: // break; //case 10: // break; //case 11: }