private void Restart() { endingSlotsGrid = childPanel.Find("ToSolve"); startingSlotsGrid = childPanel.Find("Provided"); // Activate the Letter Collection and Slot script gameObject.GetComponent <KeyCollection>().enabled = true; // Grab the play list object for this game playObj = looper.GetCurrentPlay(); // De-serialize the keyboard json keyboard = JsonUtility.FromJson <DO_KeyboardGame>(playObj.json); if (words != null) { words.Clear(); } else { words = new List <string>(); } // Create the word List and populate it. PopulateWordList(); Debug.Log("KEYBOARD: WORDS list count is " + words.Count.ToString()); currentRound = 1; // Start first round GenerateRound(); gameComplete = false; }
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); } }
/// <summary> /// This method takes the list of words from the current selected word list, /// creates a Keyboard 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_KeyboardGame"/> /// </summary> public void Save() { // Create the word ids list for the playlist dataobject List <int> wordIdsToSave = new List <int>(); foreach (var pair in controller.GetIdToWordsDict()) { foreach (Transform child in currentWordsContent.transform) { if (child.name == pair.Value) { Debug.Log("found word in currentWordsContentList to add to wordsToSave list."); wordIdsToSave.Add(pair.Key); } } } Debug.Log("wordIdsToSave list count = " + wordIdsToSave.Count); // Get the new duration value from the number of children in the current words list scroll view int duration = currentWordsContent.transform.childCount; // Create bools for the toggle options bool letterName = optionsPanel.transform.Find("LetterNameToggle").gameObject.GetComponent <Toggle>().isOn; bool wordSound = optionsPanel.transform.Find("WordSoundToggle").gameObject.GetComponent <Toggle>().isOn; bool letterSound = optionsPanel.transform.Find("LetterSoundToggle").gameObject.GetComponent <Toggle>().isOn; bool keyboardColor = optionsPanel.transform.Find("KeyboardColorToggle").gameObject.GetComponent <Toggle>().isOn; bool provided = optionsPanel.transform.Find("ProvidedToggle").gameObject.GetComponent <Toggle>().isOn; // Create the playlist entry dataobject DO_KeyboardGame tempKeyboard = new DO_KeyboardGame(/* CreateWordIdList() */ wordIdsToSave, wordSound, letterName, letterSound, keyboardColor, provided); if (controller.AddOrEditEntry(keyboardStr, duration, tempKeyboard)) { saveSuccessModal.SetActive(true); } else { saveErrorModal.SetActive(true); // TODO: Log an error } }
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 == keyboardScene) { keyboard = JsonUtility.FromJson <DO_KeyboardGame>(controller.GetJsonByIndex(controller.GetActiveContextIndex())); ToggleAllToggles(); 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: }