예제 #1
0
        /// <summary>
        /// 更新已顯示在畫面上的文字, 切換語言時呼叫, 如果正在顯示文字中, 立即中斷顯示, 替換上目標語言
        /// </summary>
        public void UpdateCurrentLangContent(SystemLanguage targetLanguage)
        {
            AdvManager.Instance.advWriter.StopDoWord();

            if (string.IsNullOrEmpty(_onScreenNameTerm))
            {
                NameText = "";
            }
            else
            {
                string _name = LocalizeManager.GetLocalizeName(_onScreenNameTerm);
                NameText = string.IsNullOrEmpty(_name)? $"no key:{_onScreenNameTerm}" : _name;
            }

            //When initialize, the "_onScreenTextTerm" may be null
            if (string.IsNullOrEmpty(_onScreenTextTerm))
            {
                StoryText = "";
            }
            else
            {
                string _text = LocalizeManager.GetLocalizeText(_onScreenTextTerm);
                StoryText = string.IsNullOrEmpty(_text)? $"no key:{_onScreenTextTerm}" : _text;
            }
        }
예제 #2
0
 public static void ChangeSetting(EnumLaungageSetting settingLanguage)
 {
     if (localizeManager == null)
     {
         localizeManager = new LocalizeManager(new LanguageSetting());
     }
     localizeManager.ChangeSetting(settingLanguage);
 }
예제 #3
0
 public static string GetText(EnumLocalizeName id)
 {
     if (localizeManager == null)
     {
         localizeManager = new LocalizeManager(new LanguageSetting());
     }
     return(localizeManager.GetText((int)id));
 }
예제 #4
0
 public static LocalizeManager GetInstance()
 {
     if (Instance == null)
     {
         Instance = new LocalizeManager();
     }
     return(Instance);
 }
예제 #5
0
 void Start()
 {
     if (LocalizeManager.GetInstance().GetTranslationOf(key) != null)
     {
         GetComponent <Text>().text = LoadTranslationWithVariables(key);
     }
     else
     {
         shouldUpdate = false;
     }
 }
예제 #6
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;

            language = Application.systemLanguage;

            DontDestroyOnLoad(gameObject);
            return;
        }

        Destroy(gameObject);
    }
예제 #7
0
    private string LoadTranslationWithVariables(string key)
    {
        string translation = LocalizeManager.GetInstance().GetTranslationOf(key);

        int i     = 0;
        var regex = new Regex(Regex.Escape("{X}"));

        while (translation.Contains("{X}"))
        {
            translation = regex.Replace(translation, variables[i], 1);
            i++;
        }

        return(translation);
    }
예제 #8
0
        private void LoadStringKeys()
        {
            var resPrefix    = GetResourcePrefix();
            var pattern      = LocalizeManager.GetLocalizer().GetFormatterString(resPrefix + "Pattern");
            var futurePrefix = LocalizeManager.GetLocalizer().GetFormatterString(resPrefix + "FuturePrefix");
            var futureSuffix = LocalizeManager.GetLocalizer().GetFormatterString(resPrefix + "FutureSuffix");
            var pastPrefix   = LocalizeManager.GetLocalizer().GetFormatterString(resPrefix + "PastPrefix");
            var pastSuffix   = LocalizeManager.GetLocalizer().GetFormatterString(resPrefix + "PastSuffix");

            Name       = LocalizeManager.GetLocalizer().GetFormatterString(resPrefix + "Name");
            PluralName = LocalizeManager.GetLocalizer().GetFormatterString(resPrefix + "PluralName");

            Format = new BasicTimeFormat().SetPattern(pattern)
                     .SetFuturePrefix(futurePrefix)
                     .SetFutureSuffix(futureSuffix)
                     .SetPastPrefix(pastPrefix)
                     .SetPastSuffix(pastSuffix);
        }
예제 #9
0
    void Awake()
    {
        if (instance)
        {
            DestroyImmediate(gameObject);
            return;
        }
        instance = this;
        DontDestroyOnLoad(gameObject);

        SystemLanguage deviceSystemLanguage = Application.systemLanguage;         //이 device의 언어를 가져옴

        systemLanguage = baseLanguage;
        foreach (SystemLanguage item in useLanguages)
        {
            if (deviceSystemLanguage.Equals(item))
            {
                systemLanguage = item;
            }
        }

        foreach (SystemLanguage tLanguage in useLanguages)
        {
            textDic.Add(tLanguage, new List <string> ());
        }

        TextAsset ta = Resources.Load <TextAsset> (textDataPath);

        string[] lines = ta.text.Split('\n');
        foreach (string line in lines)
        {
            string[] words = line.Split('\t');
            for (int i = 0; i < useLanguages.Length; i++)
            {
                textDic [useLanguages [i]].Add(words [i]);
            }
        }
    }
예제 #10
0
        /// <summary>
        /// 增加對話項目, 擴充了 "條件選擇項目"
        /// </summary>
        public virtual bool AddOption(string displayTerm, bool interactable, bool hideOption, Block targetBlock, FlowchartExtend srcFlowChart, bool hasCondition, int requireValue)
        {
            if (localizeIndex < _onScreenTextTerms.Length)
            {
                _onScreenTextTerms[localizeIndex] = displayTerm;
                localizeIndex++;
            }
            _onScreenFlowchart = srcFlowChart;

            string localText   = LocalizeManager.GetLocalizeText(displayTerm);
            string displayText = string.IsNullOrEmpty(localText)? $"no key:{displayTerm}" : srcFlowChart.SubstituteVariables(localText);

            if (hasCondition)
            {
                if (OnRequireValue != null)
                {
                    //OnRequireValue 自行添加判斷式, Menu將帶入 requireValue 來跑判斷式
                    interactable = OnRequireValue(requireValue);
                }
            }

            return(AddOption(displayText, interactable, hideOption, targetBlock));
        }
예제 #11
0
    public void OpenSettings(GameObject container)
    {
        if (ExistsWindow(container, "SettingsScene"))
        {
            return;
        }

        GameObject settingsScreen = gameObjectLoader.GetWindow("SettingsScene");

        settingsScreen.GetComponent <RectTransform>().parent        = container.GetComponent <RectTransform>();
        settingsScreen.GetComponent <RectTransform>().localPosition = new Vector3(0, 0, -200);
        settingsScreen.GetComponent <RectTransform>().localScale    = new Vector3(0.8f, 0.8f, 0.8f);

        settingsScreen.transform.Find("CloseButton").GetComponent <Button>().onClick.AddListener(() =>
        {
            GameObject.Find("AudioSourceClick").GetComponent <AudioSource>().Play();
            Destroy(settingsScreen);
        });

        settingsScreen.transform.Find("LanguageArea").transform.Find("GermanButton").GetComponent <Button>().onClick.AddListener(() =>
        {
            LocalizeManager.GetInstance().SetLanguage(Languages.GERMAN);
            SaveLoadGame.SaveGame();
        });

        settingsScreen.transform.Find("LanguageArea").transform.Find("EnglishButton").GetComponent <Button>().onClick.AddListener(() =>
        {
            LocalizeManager.GetInstance().SetLanguage(Languages.ENGLISH);
            SaveLoadGame.SaveGame();
        });

        settingsScreen.transform.Find("PrivacyPolicy").GetComponent <Button>().onClick.AddListener(() =>
        {
            GameObject.Find("AudioSourceClick").GetComponent <AudioSource>().Play();
            Application.OpenURL("http://boxfox-games.de/tilebreaker-privacy-policy/");
        });
    }
예제 #12
0
        public void UpdateCurrentLangContent(SystemLanguage language)
        {
            //initialize will call it , and in the time it's null
            if (cachedButtons == null)
            {
                return;
            }

            for (int i = 0; i < cachedButtons.Length; i++)
            {
                TextAdapter textAdapter = new TextAdapter();
                textAdapter.InitFromGameObject(cachedButtons[i].gameObject, true);
                if (textAdapter.HasTextObject() && !string.IsNullOrEmpty(_onScreenTextTerms[i]))
                {
                    string localText = LocalizeManager.GetLocalizeText(_onScreenTextTerms[i]);

                    if (string.IsNullOrEmpty(localText))
                    {
                        localText = $"no key:{_onScreenTextTerms[i]}";
                    }
                    else
                    {
                        //trim flowchart's token
                        if (_onScreenFlowchart != null)
                        {
                            localText = _onScreenFlowchart.SubstituteVariables(localText);
                        }

                        //trim global TextVariation's token
                        localText = TextVariationHandler.SelectVariations(localText);
                    }

                    textAdapter.Text = localText;
                }
            }
        }
예제 #13
0
    public static void LoadGame()
    {
        Debug.Log("LOAD");
        if (ObscuredPrefs.GetString("PlayerStats").Equals(""))
        {
            Debug.Log("FT");
            // Startsprache setzen
            if (Application.systemLanguage == SystemLanguage.German)
            {
                LocalizeManager.GetInstance().SetLanguage(Languages.GERMAN);
            }
            else if (Application.systemLanguage == SystemLanguage.English)
            {
                LocalizeManager.GetInstance().SetLanguage(Languages.ENGLISH);
            }
            else
            {
                LocalizeManager.GetInstance().SetLanguage(Languages.ENGLISH);
            }

            return;
        }

        PlayerStats ps = JsonUtility.FromJson <PlayerStats>(ObscuredPrefs.GetString("PlayerStats"));

        // Coins
        Player.GetInstance().Coins = ps.coins;

        // Hints
        Player.GetInstance().Hints = ps.hints;

        // Games
        if (ps.playedGames == 0)
        {
            foreach (GameInfos gameInfos in ps.gameInfos)
            {
                if (Player.GetInstance().AllChapter.Count <= gameInfos.chapterIndex || Player.GetInstance().AllChapter[gameInfos.chapterIndex].AllGames.Count <= gameInfos.gameIndex)
                {
                    continue;
                }

                Game g = Player.GetInstance().AllChapter[gameInfos.chapterIndex].AllGames[gameInfos.gameIndex];
                g.Hints    = gameInfos.hints;
                g.Tries    = gameInfos.tries;
                g.isPlayed = gameInfos.isPlayed;
            }
        }
        else
        {
            for (int i = 0; i < ps.playedGames; i++)
            {
                int cIndex = 0;
                int gIndex = i;
                foreach (Chapter c in Player.GetInstance().AllChapter)
                {
                    if (c.AllGames.Count <= gIndex)
                    {
                        gIndex -= c.AllGames.Count;
                        cIndex++;
                    }
                    else
                    {
                        break;
                    }
                }
                Player.GetInstance().AllChapter[cIndex].AllGames[gIndex].isPlayed = true;
            }
        }

        foreach (Chapter c in Player.GetInstance().AllChapter)
        {
            c.ReloadAvailableGames();
        }

        // Character
        foreach (string c in ps.availableCharacter)
        {
            foreach (Character character in Player.GetInstance().AllCharacter)
            {
                character.isAvailable = character.name.Equals(c);
            }
        }

        // Actual Character
        foreach (Character character in Player.GetInstance().AllCharacter)
        {
            if (character.name.Equals(ps.actualCharacter))
            {
                Player.GetInstance().ChooseCharacter(character);
            }
        }

        // Show Ads
        Player.GetInstance().ShouldShowAds = ps.showAds;

        // Show Shadows
        Player.GetInstance().ShowShadows = ps.showShadows;

        // Hint Tutorial
        Player.GetInstance().HasUserGetFreeHints       = ps.hasUserGetFreeHints;
        Player.GetInstance().HasUserPlayedHintTutorial = ps.hasUserPlayedHintTutorial;

        // Sound
        Player.GetInstance().SoundOn = ps.soundOn;
        AudioListener.volume = ps.soundOn ? 1.0f : 0f;

        // Wins Without Ad
        Player.GetInstance().WinsWithoutAd = ps.winsWithoutAd;

        // Language
        LocalizeManager.GetInstance().SetLanguage(ps.language);

        // Last played chapter
        LevelChooseInfos.chapterIndex = ps.lastPlayedChapterIndex;

        // IsFirstTime
        Debug.Log("Load ft " + ps.isFirstTime);
        Player.GetInstance().IsFirstTime = ps.isFirstTime;
    }
예제 #14
0
 void Start()
 {
     GetComponent <Text> ().text = LocalizeManager.GetText(index);
 }
예제 #15
0
 private void OnDestroy() => LocalizeManager.Remove(this);
 void OnEnable()
 {
     LocalizeManager.AddObserver(this);
 }
예제 #17
0
        public override void OnEnter()
        {
            if (!showAlways && executionCount >= showCount)
            {
                Continue();
                return;
            }

            executionCount++;

            // Override the active say dialog if needed
            if (dataCharacter != null && dataCharacter.SetSayDialog != null)
            {
                SayDialog.ActiveSayDialog = character.SetSayDialog;
            }

            if (setSayDialog != null)
            {
                SayDialog.ActiveSayDialog = setSayDialog;
            }

            // Default say dialog is AdvManager's
            var sayDialog = AdvManager.Instance.advSayDialog;

            if (sayDialog == null)
            {
                Continue();
                return;
            }

            var flowchart = GetComponent <FlowchartExtend>();

            bool isRead = false;

            if (AdvManager.Instance.HasReadTable.TryGetValue($"{gameObject.name}.{csvCommandKey}", out isRead))
            {
                hasRead = true;
            }

            sayDialog.SetActive(true);

            //1. Set name , color , portait
            string nameTerm   = overrideTerm;
            string stringName = "";

            if (!string.IsNullOrEmpty(overrideTerm))
            {
                stringName = LocalizeManager.GetLocalizeName(overrideTerm);
                stringName = string.IsNullOrEmpty(stringName) ? $"no key:{overrideTerm}" : stringName;
            }

            Color nameColor;
            Color contentColor;

            nameColor    = sayDialog.ColorName.TryGetValue(overrideTerm, out nameColor) ? nameColor : AdvProjectConfig.Instance.SaySpeakerColor;
            contentColor = sayDialog.ColorText.TryGetValue(overrideTerm, out contentColor) ? contentColor : AdvProjectConfig.Instance.SayContentColor;

            sayDialog.SetCharacter(stringName, nameColor, overridePortrait);
            sayDialog.SetStoryColor(contentColor);

            //2. Set Content text
            string displayText = storyText;
            string textTerm    = $"{flowchart.GoogleSheetID}.{flowchart.GooglePageID}.{CSVCommandKey}";
            string localText   = LocalizeManager.GetLocalizeText(textTerm);

            if (!string.IsNullOrEmpty(localText))
            {
                displayText = localText;
            }

            var activeCustomTags = CustomTag.activeCustomTags;

            for (int i = 0; i < activeCustomTags.Count; i++)
            {
                var ct = activeCustomTags[i];
                displayText = displayText.Replace(ct.TagStartSymbol, ct.ReplaceTagStartWith);
                if (ct.TagEndSymbol != "" && ct.ReplaceTagEndWith != "")
                {
                    displayText = displayText.Replace(ct.TagEndSymbol, ct.ReplaceTagEndWith);
                }
            }
            string subbedText = flowchart.SubstituteVariables(displayText); //displayText is origin Tag string , subbedText is Replace by Variables Text

            //3. Set Icon show / hide
            sayDialog.SetIconDisplay(showIcon);

            // //如果立繪中有存在這個 SpeakerTerm , 啟用立繪相關功能
            // BillboardController billboardCtrl = null;
            // if(!string.IsNullOrEmpty(speakerTerm.ToString())){
            //     billboardCtrl = AdvManager.Instance.mainStage.BillboardLayout.FindBillboardWithTerm(speakerTerm);
            // }
            // if(billboardCtrl != null){
            //     //關閉頭相框
            //     sayDialog.SayIconObject.SetActive(false);

            //     //從 atlas 取得說話表情
            //     billboardCtrl.SetRendererSprite(portrait);
            //     AdvManager.Instance.mainStage.BillboardLayout.PopUpBillboard(billboardCtrl);
            // }
            // else
            // {
            //     AdvManager.Instance.mainStage.BillboardLayout.ResumeBillboardPop();
            // }

            //4. Set billboard on Stage
            UIBillboardController uiCtrl = null;

            if (!string.IsNullOrEmpty(overrideTerm))
            {
                uiCtrl = AdvManager.Instance.advStage.BillboardGUILayout.FindBillboardWithTerm(overrideTerm);
            }
            if (uiCtrl != null)
            {
                //關閉頭相框
                if (AdvProjectConfig.Instance.AlwaysHideIconWhenOnBillboard)
                {
                    sayDialog.SayIconObject.SetActive(false);
                }

                if (overridePortrait)
                {
                    uiCtrl.RuntimeSetEmoji(overridePortrait.name);
                }

                uiCtrl.RuntimeUnequip();
                uiCtrl.RuntimeSetEquip(portraitEquip);
            }
            else
            {
            }


            sayDialog.SetLogInfo(nameTerm, textTerm, voiceOverClip);

            sayDialog.Say(subbedText, !extendPrevious, waitForClick, fadeWhenDone, stopVoiceover, waitForVO, voiceOverClip, hasRead, delegate {
                //已經確定讀完這句話了
                AdvManager.Instance.OnSayRead?.Invoke(gameObject.name, csvCommandKey);
                hasRead = true;

                Continue();
            });
        }
 void OnDisable()
 {
     LocalizeManager.RemoveObserver(this);
 }
예제 #19
0
	public bool GetTransletedTextByID(int id, LocalizeManager.Lang deflang, out string result)
	{
		Dictionary<string, string> defDic;
		Dictionary<string, string> targetDic;
		
		//if(defLang == Lang.en)
		//{
			defDic = hintEnDic;
			targetDic = hintRuDic;
		//}
		//else
		//{
			targetDic = hintEnDic;
			defDic = hintRuDic;
		//}
		if(defDic[id + ""] != "" && defDic[id + ""] != null)
		{
			result = targetDic[id + ""];
			return true;
		}
		result = "";
		return false;
	}
예제 #20
0
	public bool GetTransletedText(string text, LocalizeManager.Lang defLang, LocalizeManager.Lang targetLang, out string result)
	{
		Dictionary<string, string> defDic;
		Dictionary<string, string> targetDic;

		if(defLang == Lang.en)
		{
			defDic = hintEnDic;
			targetDic = hintRuDic;
		}
		else
		{
			targetDic = hintEnDic;
			defDic = hintRuDic;
		}

		for (int i = 0; i < defDic.Keys.Count; i++)
		{
			IEnumerator iterator = defDic.GetEnumerator();
			iterator.MoveNext();
			var tmp = (KeyValuePair<string, string>)iterator.Current;
			if(tmp.Value == text)
			{
				result = targetDic[tmp.Key];
				return true;
			}
		}
		result = "";
		return false;
	}
예제 #21
0
    public void UpdateUIContent(SystemLanguage targetLanguage)
    {
        if (AvatarIcon != null)
        {
            AvatarIcon.sprite = AvatarSprite;
            if (AvatarIcon.sprite == null)
            {
                AvatarBorder.gameObject.SetActive(false);
            }
            else
            {
                if (AvatarSprite.bounds.size.x > AvatarSprite.bounds.size.y)
                {
                    AvatarIcon.rectTransform.sizeDelta = new Vector2(AvatarBorder.rectTransform.sizeDelta.x, AvatarBorder.rectTransform.sizeDelta.y * (AvatarSprite.bounds.size.y / AvatarSprite.bounds.size.x));
                }
                else
                {
                    AvatarIcon.rectTransform.sizeDelta = new Vector2(AvatarBorder.rectTransform.sizeDelta.x * (AvatarSprite.bounds.size.x / AvatarSprite.bounds.size.y), AvatarBorder.rectTransform.sizeDelta.y);
                }
                AvatarBorder.gameObject.SetActive(true);
            }
        }

        if (AvatarVoice == null)
        {
            BTNVoice.gameObject.SetActive(false);
        }
        else
        {
            BTNVoice.gameObject.SetActive(true);
        }

        if (UseDynamicNameColor)
        {
            Color nameColor;
            nameColor      = AdvManager.Instance.advSayDialog.ColorName.TryGetValue(NameTerm, out nameColor) ? nameColor : AdvProjectConfig.Instance.SaySpeakerColor;
            TextName.color = nameColor;
        }

        if (UseDynamicContentColor)
        {
            Color ContentColor;
            ContentColor  = AdvManager.Instance.advSayDialog.ColorText.TryGetValue(NameTerm, out ContentColor) ? ContentColor : AdvProjectConfig.Instance.SayContentColor;
            TextSay.color = ContentColor;
        }

        if (string.IsNullOrEmpty(NameTerm))
        {
            TextName.text = "";
        }
        else
        {
            string _name = LocalizeManager.GetLocalizeName(NameTerm);
            TextName.text = string.IsNullOrEmpty(_name) ? $"no key:{NameTerm}" : _name;
        }

        //When initialize, the "TextTerm" may be null
        if (string.IsNullOrEmpty(TextTerm))
        {
            TextSay.text = "";
        }
        else
        {
            string _text = LocalizeManager.GetLocalizeText(TextTerm);
            TextSay.text = string.IsNullOrEmpty(_text) ? $"no key:{TextTerm}" : _text;
        }
    }
예제 #22
0
 private void Awake()
 {
     LocalizeManager.Register(this);
     OnClickLanguage(0);
 }