Example #1
0
    private void CreateCategoryList()
    {
        int count = Enum.GetValues(typeof(TutorialType)).Length;

        categoryButtons = new Button[count - 1];
        for (int i = 0; i < count; i++)
        {
            TutorialType type = categoriesOrder[i];
            if (type == TutorialType.NONE)
            {
                continue;
            }

            Button button = Instantiate(categoryButton, categoryList);
            button.onClick.AddListener(() => ShowCategory(type));

            //button.transform.GetChild(0).GetComponent<Text>().text = TypeToString(type);
            LocalizeStringEvent localized = button.GetComponent <LocalizeStringEvent>();
            localized.StringReference = TypeToString(type);
            localized.RefreshString();

            categoryButtons[i - 1] = button;
        }
        categoryButton.gameObject.SetActive(false);
    }
    private void answerDisplay()
    {
        transform.GetChild(0).gameObject.SetActive(true);

        Question q = QuizManager.Singleton.CurrentQuestion;

        for (int i = 0; i < _localizedAnswersList.Count; i++)
        {
            LocalizeStringEvent temp = _localizedAnswersList[i];
            int randomIndex          = UnityEngine.Random.Range(i, _localizedAnswersList.Count);
            _localizedAnswersList[i]           = _localizedAnswersList[randomIndex];
            _localizedAnswersList[randomIndex] = temp;
        }

        bool isLocalPlayer = TTPlayer.LocalPlayer.GetComponent <VasilPlayer>().HasCurrentTurn;

        for (int i = 0; i < _localizedAnswersList.Count; i++)
        {
            _localizedAnswersList[i].transform.parent.GetComponent <Button>().interactable = isLocalPlayer;

            _localizedAnswersList[i].transform.parent.parent.Find("Correct").gameObject.SetActive(false);
            _localizedAnswersList[i].transform.parent.parent.Find("Wrong").gameObject.SetActive(false);
            if (i == _localizedAnswersList.Count - 1)
            {
                _localizedAnswersList[i].StringReference = q.LocalizedCorrectAnswer;
            }
            else
            {
                _localizedAnswersList[i].StringReference = q.LocalizedWrongAnswersArray[i];
            }
        }
    }
Example #3
0
    private void AddParagraph(LocalizedString s)
    {
        LocalizeStringEvent paragraph = Instantiate(paragraphPrefab, contentRect);

        paragraph.gameObject.SetActive(true);
        paragraph.StringReference = s;
        paragraph.RefreshString();
    }
Example #4
0
    private void AddTitle(LocalizedString s)
    {
        LocalizeStringEvent title = Instantiate(titlePrefab, contentRect);

        title.gameObject.SetActive(true);
        title.StringReference = s;
        title.RefreshString();
    }
        private void Awake()
        {
#if OBSOLETE
            Debug.LogError($"{gameObject.name} is still using {nameof(LevelEditorInspectorField)} and it will be stripped on build. Remove it.");
#endif

#if ALE_LOCALIZATION
            localStringComp = GetComponentInChildren <LocalizeStringEvent>();
#endif

            OnAwake();
        }
 private void Start()
 {
     for (int i = 0; i < transform.GetChild(0).childCount; i++)
     {
         //Get the localized string event from the text
         LocalizeStringEvent lse = transform.GetChild(0).GetChild(i).GetComponentInChildren <LocalizeStringEvent>();
         //Add it to the list
         _localizedAnswersList.Add(lse);
         //Add a listener to the Answer button
         lse.GetComponentInParent <Button>().onClick.AddListener(() => CheckAnswer(lse));
     }
 }
Example #7
0
        public void Setup()
        {
            m_OldSettings = LocalizationSettings.Instance;

            LocalizationSettings.Instance       = ScriptableObject.CreateInstance <LocalizationSettings>();
            m_FixtureStringDatabase             = new FixtureStringDatabase();
            LocalizationSettings.StringDatabase = m_FixtureStringDatabase;

            m_GameObject          = new GameObject(nameof(ChangingLocalizedStringUpdatesValues));
            m_LocalizeStringEvent = m_GameObject.AddComponent <LocalizeStringEvent>();

            // Setup with a default value so we do not start with an empty StringReference.
            m_LocalizeStringEvent.StringReference.SetReference(kDefaultTableCollectionName, kDefaultEntryName);
            ClearLastGetTableEntryValues();
        }
Example #8
0
    public void Initialize(Type type)
    {
        foreach (Enum enumValue in Enum.GetValues(type))
        {
            GameObject      option   = Instantiate(optionPrefab, optionPrefab.transform.parent);
            TextMeshProUGUI textMesh = option.GetComponent <TextMeshProUGUI>();
            regularSize   = textMesh.fontSize;
            textMesh.text = enumValue.ToString();
            PickerChoiceAttribute pickerChoice = GetPickerChoice(enumValue);
            if (pickerChoice != null)
            {
                LocalizeStringEvent localizeString = textMesh.GetComponent <LocalizeStringEvent>();
                if (localizeString == null)
                {
                    throw new Exception($"Enum Picker prefab for type '{type}' is missing LocalizeStringEvent component");
                }
                LocalizedString localizedString = new LocalizedString();
                localizedString.SetReference(pickerChoice.Table, pickerChoice.Entry);
                localizeString.StringReference = localizedString;
            }
            items.Add(enumValue, textMesh);
            option.GetComponent <Button>().onClick.AddListener(() =>
            {
                if (Locked)
                {
                    return;
                }
                Select(textMesh);
                OnClick?.Invoke(enumValue);
            });
            option.SetActive(true);
        }
        TextMeshProUGUI defaultSelected = items.First().Value; //todo maybe add an optional default selected parameter

        foreach (TextMeshProUGUI text in items.Values)
        {
            if (shouldBold)
            {
                text.fontStyle &= ~FontStyles.Bold;
            }
            text.color = normalColor;
        }
        Select(defaultSelected);
    }
    public void CheckAnswer(LocalizeStringEvent pLocalizedStringEvent)
    {
        if (pLocalizedStringEvent.StringReference == QuizManager.Singleton.CurrentQuestion.LocalizedCorrectAnswer)
        {
            Debug.Log("Correct!");
            pLocalizedStringEvent.transform.parent.parent.Find("Correct").gameObject.SetActive(true);

            for (int i = 0; i < _localizedAnswersList.Count; i++)
            {
                _localizedAnswersList[i].transform.parent.GetComponent <Button>().interactable = false;
            }

            Invoke(nameof(HideQuiz), 3);
        }
        else
        {
            Debug.Log("Sorry, but that's wrong");
            pLocalizedStringEvent.transform.parent.parent.Find("Wrong").gameObject.SetActive(true);
            StartCoroutine(ResetAnswers(pLocalizedStringEvent.transform.parent.parent.Find("Wrong").gameObject, 0.2f));
        }
    }
Example #10
0
        public void Setup()
        {
            LocalizationSettingsHelper.SaveCurrentSettings();

            LocalizationSettings.Instance = ScriptableObject.CreateInstance <LocalizationSettings>();

            var localeProvider = new TestLocaleProvider();

            m_Selected = Locale.CreateLocale("en");
            localeProvider.AddLocale(m_Selected);
            LocalizationSettings.Instance.SetAvailableLocales(localeProvider);

            m_FixtureStringDatabase             = new FixtureStringDatabase();
            LocalizationSettings.StringDatabase = m_FixtureStringDatabase;

            m_FixtureStringDatabase.NoTranslationFoundMessage = "No translation found for '{key}'";
            m_GameObject          = new GameObject(nameof(ChangingLocalizedStringUpdatesValues));
            m_LocalizeStringEvent = m_GameObject.AddComponent <LocalizeStringEvent>();

            // Setup with a default value so we do not start with an empty StringReference.
            m_LocalizeStringEvent.StringReference.SetReference(kDefaultTableCollectionName, kDefaultEntryName);
            ClearLastGetTableEntryValues();
        }
 private void Awake()
 {
     _localizedQuestionTextEvent = transform.GetChild(0).GetComponent <LocalizeStringEvent>();
     _localizedQuestionTheme     = transform.GetChild(1).GetChild(0).GetComponent <LocalizeStringEvent>();
     _bubbleIcon = transform.GetChild(1).GetChild(1).GetComponent <Image>();
 }