Example #1
0
        private void SetExample(int index)
        {
            GrammarSection grammar = m_GrammarSet[m_SelectedCategory].Data[m_SelectedGrammar];

            // Set sentence
            m_ExampleUI.Sentence = grammar.SentencesExamples.GetSentence(index);
            m_ExampleUI.English  = grammar.SentencesExamples.GetEnglish(index);
            m_ExampleUI.Kanjis   = grammar.SentencesExamples.GetKanjis(index);
        }
Example #2
0
        private void SetGrammarByCategory()
        {
            // Set Grammar info
            GrammarSection grammar = m_GrammarSet[m_SelectedCategory].Data[m_SelectedGrammar];

            m_GrammarUI.Title = grammar.Title;

            if (grammar.Description != null)
            {
                string desc = "";

                for (int i = 0; i < grammar.Description.Count; i++)
                {
                    desc += "\n\n" + grammar.Description[i];
                }
                m_GrammarUI.Description = desc;
            }

            // Set number of grammar for this category
            if (m_GrammarSet[m_SelectedCategory].Data.Count > 1)
            {
                m_GrammarUI.NextBtn.Enable(true, m_EnableBtnColor);
            }
            else
            {
                m_GrammarUI.NextBtn.Enable(false, m_DisableBtnColor);
            }


            // Set examples
            if ((grammar.SentencesExamples != null) && (grammar.SentencesExamples.Sentence.Count > 0))
            {
                if (grammar.SentencesExamples.Sentence.Count > 1)
                {
                    m_ExampleUI.NextBtn.Enable(true, m_EnableBtnColor);
                }
                else
                {
                    m_ExampleUI.NextBtn.Enable(false, m_DisableBtnColor);
                }

                m_GrammarUI.ExampleBtn.Enable(true, m_EnableBtnColor);

                // Set sentence
                m_SelectedExample = 0;

                SetExample(m_SelectedExample);
            }
            else
            {
                m_GrammarUI.ExampleBtn.Enable(false, m_DisableBtnColor);
                m_ExampleUI.NextBtn.Enable(false, m_DisableBtnColor);
            }
        }
Example #3
0
        public override IEnumerator Initialize()
        {
            m_GrammarUI.Hide();
            m_ExampleUI.Hide();
            m_CategoriesUI.Hide();

            //m_GrammarSet = new List<GrammarData>();
            for (int i = 0; i < m_GrammarSet.Count; i++)
            {
                GrammarSection grammar = new GrammarSection();

                // string category = ((ECategory)i).ToString();
                string fileName = m_GrammarSet[i].FileName;
                string title    = m_GrammarSet[i].Title;
                string path     = m_DataPath + fileName;
                string json     = Utility.LoadJSONResource(path);

                if (!string.IsNullOrEmpty(json))
                {
                    try
                    {
                        m_GrammarSet[i]          = JsonMapper.ToObject <GrammarData>(json);
                        m_GrammarSet[i].FileName = fileName;
                        m_GrammarSet[i].Title    = title;
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("[GrammarControl.Init] Bad Format JSON File: " + path);
                    }
                }
                else
                {
                    Debug.Log("[GrammarControl.Init] JSON not found: " + path);
                }
            }

            m_SelectedGrammar = 0;

            yield break;
        }