/// <summary> /// This method takes the list of words from the current selected word list, /// creates a Memory Cards 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_MemoryCards"/> /// </summary> public void Save() { // Get the new duration value from the number of children in the current words list scroll view // Duration is set to 1 to fix a bug that would not allow progress past reward nor past end of playlist. int duration = 1; // Create bools for the toggle options bool wordText = optionsPanel.transform.Find("IncludeWordTextToggle").gameObject.GetComponent <Toggle>().isOn; bool alts = optionsPanel.transform.Find("AltImagesToggle").gameObject.GetComponent <Toggle>().isOn; bool wordSound = optionsPanel.transform.Find("WordSoundToggle").gameObject.GetComponent <Toggle>().isOn; DO_MemoryCards tempMemory = new DO_MemoryCards(CreateWordIdList(), wordText, alts, wordSound); Debug.Log("************ created tempMemory data object********"); if (controller.AddOrEditEntry(memoryStr, duration, tempMemory)) { saveSuccessModal.SetActive(true); } else { saveErrorModal.SetActive(true); } }
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 { memory = JsonUtility.FromJson <DO_MemoryCards>(controller.GetJsonByIndex(controller.GetActiveContextIndex())); ToggleAllToggles(); PopulateBothViews(); } }
public void SetupFromString(string json) { Debug.Log("Start SetupFromString"); Debug.Log(json); mc = JsonUtility.FromJson<DO_MemoryCards>(json); // Set up game data foreach (int id in mc.wordIdList) { words.Add(gameLoop.controller.GetWordById(id)); } //CreateButtons(); SetupCards(); //AddListeners(); AddGamePuzzles(); Shuffle(gamePuzzles); gameGuesses = gamePuzzles.Count / 2; // Set up extra features wordAudio = mc.wordAudio; includeText = mc.includeText; altImages = mc.altImages; Debug.Log("End setupFromString"); }
/// <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: }