public override void OnEnterState() { base.OnEnterState(); Session session = GameManager.instance.ActiveSession; SessionParameters sessionParams = session.SessionParams; // Resize array m_DisplayedSyllables = new SyllableViewModel[sessionParams.SyllableSearchedAmount]; // Fill UI Elements from model ICryptoSyllable[] displayedSyllableList = session.GetLastInputSyllables(); Debug.Assert(displayedSyllableList.Length == m_DisplayedSyllables.Length, "WHY WOULD YOU DO THAT!?"); for (int i = 0; i < m_DisplayedSyllables.Length; ++i) { // get model data var displayedSyllable = displayedSyllableList[i]; // Update view model with model data var syllableViewModel = new SyllableViewModel(); syllableViewModel.SetFromSyllable(displayedSyllable); m_DisplayedSyllables[i] = syllableViewModel; } Debug.Log("OnDisplaySyllablesCountChanged"); OnDisplaySyllablesCountChanged?.Invoke(); }
private void ViewModel_OnDisplaySyllablesCountChanged() { var syllablesViewModelList = ViewModelConcrete.GetDisplayedSyllables(); for (int i = 0; i < m_SyllableList.Count; ++i) { SyllableView syllableView = m_SyllableList[i]; if (i < syllablesViewModelList.Length) { SyllableViewModel syllableViewModel = syllablesViewModelList[i]; syllableView.gameObject.SetActive(true); syllableView.Init(syllableViewModel); } else { syllableView.gameObject.SetActive(false); } } // todo: Change this abomination Invoke("FinishTimer", GameManager.instance.ActiveSession.LastWordDisplayTime); }
public override void OnEnterState() { base.OnEnterState(); m_InputIndex = 0; m_Session = GameManager.instance.ActiveSession; SessionParameters sessionParams = m_Session.SessionParams; var transmission = m_Session.TransmissionSetup.Transmissions[m_Session.ActiveRoundIndex]; // Resize array m_DisplayedSyllables = new SyllableViewModel[sessionParams.SyllableSearchedAmount]; m_InputSyllables = new SyllableViewModel[sessionParams.SyllableChoiceAmount]; m_InTableSyllables = new SyllableViewModel[sessionParams.SyllableChoiceAmount]; m_OutTableSyllables = new SyllableViewModel[sessionParams.SyllableChoiceAmount]; m_ShuffledInLanguageIndexes = new byte[sessionParams.SyllableChoiceAmount]; var tmpList = new List <byte>(sessionParams.SyllableChoiceAmount); for (byte i = 0; i < sessionParams.SyllableChoiceAmount; i++) { tmpList.Add(i); } for (int i = 0; i < sessionParams.SyllableChoiceAmount; i++) { var index = UnityEngine.Random.Range(0, tmpList.Count); m_ShuffledInLanguageIndexes[i] = tmpList[index]; tmpList.RemoveAt(index); } var inSyllables = transmission.InLanguage.GetSyllables(); var outSyllables = transmission.OutLanguage.GetSyllables(); for (int i = 0; i < sessionParams.SyllableChoiceAmount; i++) { m_InputSyllables[i] = new SyllableViewModel(); m_InTableSyllables[i] = new SyllableViewModel(); m_OutTableSyllables[i] = new SyllableViewModel(); } for (int i = 0; i < sessionParams.SyllableSearchedAmount; i++) { m_DisplayedSyllables[i] = new SyllableViewModel(); } OnSyllablesChanged?.Invoke(); for (int i = 0; i < sessionParams.SyllableChoiceAmount; i++) { m_InputSyllables[i].SetFromSyllable(outSyllables[transmission.Conversion[m_ShuffledInLanguageIndexes[i]]]); m_InTableSyllables[i].SetFromSyllable(inSyllables[m_ShuffledInLanguageIndexes[i]]); m_OutTableSyllables[i].SetFromSyllable(outSyllables[transmission.Conversion[m_ShuffledInLanguageIndexes[i]]]); } CanTransmit = false; }