void Start() { if (LocalizeManager.GetInstance().GetTranslationOf(key) != null) { GetComponent <Text>().text = LoadTranslationWithVariables(key); } else { shouldUpdate = false; } }
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); }
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/"); }); }
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; }