private void UpdatePlayerStats() { for (int i = 0; i < 3; i++) { int num = 0; if (i != 0) { if (i != 1) { if (i == 2) { num = GameProgress.GetInt("cake_race_bronze_trophies_won", 0, GameProgress.Location.Local, null); } } else { num = GameProgress.GetInt("cake_race_silver_trophies_won", 0, GameProgress.Location.Local, null); } } else { num = GameProgress.GetInt("cake_race_gold_trophies_won", 0, GameProgress.Location.Local, null); } this.trophyIcons[i].gameObject.SetActive(num > 0); TextMeshHelper.UpdateTextMeshes(this.trophyAmountLabels[i], (num <= 0) ? string.Empty : num.ToString(), false); } int @int = GameProgress.GetInt("cake_race_coins_won", 0, GameProgress.Location.Local, null); TextMeshHelper.UpdateTextMeshes(this.totalCoinsWonLabel, string.Format("[snout] {0}", @int), false); TextMeshSpriteIcons.EnsureSpriteIcon(this.totalCoinsWonLabel); int int2 = GameProgress.GetInt("cake_race_highest_rank", 0, GameProgress.Location.Local, null); TextMeshHelper.UpdateTextMeshes(this.highestRankLabel, (int2 <= 0) ? "-" : int2.ToString(), false); }
private void Update() { if (!Singleton <PlayerProgress> .IsInstantiated()) { return; } if (this.currentExperience == Singleton <PlayerProgress> .Instance.ExperienceToNextLevel && Singleton <PlayerProgress> .Instance.LevelUpPending && this.currentState == PlayerProgressBar.State.Regular) { this.SetState((!ResourceBar.Instance.IsItemEnabled(ResourceBar.Item.PlayerProgress) || !this.canLevelUp) ? PlayerProgressBar.State.WaitingLevelInactive : PlayerProgressBar.State.WaitingLevelActive); } if (this.currentExperience != this.targetExperience && Time.realtimeSinceStartup >= this.nextUpdate && this.resourceBarItem.IsShowing && this.currentState == PlayerProgressBar.State.Regular) { this.nextUpdate = Time.realtimeSinceStartup + SoftCurrencyButton.updateInterval; int deltaAmount = SoftCurrencyButton.GetDeltaAmount(this.currentExperience, this.targetExperience); if (this.currentExperience < this.targetExperience) { this.currentExperience += deltaAmount; } else if (this.currentExperience > this.targetExperience) { this.currentExperience -= deltaAmount; } int experienceToNextLevel = Singleton <PlayerProgress> .Instance.ExperienceToNextLevel; int level = Singleton <PlayerProgress> .Instance.Level; this.currentExperience = Mathf.Min(this.currentExperience, experienceToNextLevel); TextMeshHelper.UpdateTextMeshes(this.levelLabel, level.ToString(), false); TextMeshHelper.UpdateTextMeshes(this.experienceLabel, string.Format("{0}/{1}", this.currentExperience, experienceToNextLevel), false); float d = Mathf.Clamp((float)this.currentExperience / (float)experienceToNextLevel, 0.001f, 1f); this.experienceFillMeter.localScale = Vector3.forward + Vector3.up + Vector3.right * d * this.maxFill; } }
private void TextUpdated(GameObject go) { if (go != null && go == base.gameObject) { TextMeshHelper.Wrap(go.GetComponent <TextMesh>(), (!TextMeshHelper.UsesKanjiCharacters()) ? this.maxCharacters : this.maxKanjiCharacters, this.splitHyphen); } }
protected override void Awake() { base.Awake(); TextMesh[] componentsInChildren = this.descriptionText.GetComponentsInChildren <TextMesh>(true); for (int i = 0; i < componentsInChildren.Length; i++) { TextMeshLocale component = componentsInChildren[i].GetComponent <TextMeshLocale>(); if (!(component == null)) { component.RefreshTranslation(componentsInChildren[i].text); component.enabled = false; float value = Singleton <GameConfigurationManager> .Instance.GetValue <float>("cake_race", "kings_favorite_bonus"); int num = 0; if (!Mathf.Approximately(value, 0f)) { num = Mathf.RoundToInt((value - 1f) * 100f); } componentsInChildren[i].text = string.Format(componentsInChildren[i].text, num.ToString()); if (TextMeshHelper.UsesKanjiCharacters()) { TextMeshHelper.Wrap(componentsInChildren[i], this.maxKanjiCharacterInLine, false); } else { TextMeshHelper.Wrap(componentsInChildren[i], this.maxCharactersInLine, false); } } } }
public void UpdateAmount(bool force = false) { if (!Singleton <PlayerProgress> .IsInstantiated()) { return; } this.nextUpdate = Time.realtimeSinceStartup; this.targetExperience = this.currentRealExperience; if (force && this.currentState == PlayerProgressBar.State.Regular) { int experienceToNextLevel = Singleton <PlayerProgress> .Instance.ExperienceToNextLevel; this.currentRealExperience = Singleton <PlayerProgress> .Instance.Experience; this.targetExperience = this.currentRealExperience; this.currentExperience = this.targetExperience; TextMeshHelper.UpdateTextMeshes(this.levelLabel, Singleton <PlayerProgress> .Instance.Level.ToString(), false); if (Singleton <PlayerProgress> .Instance.LevelUpPending) { this.experienceFillMeter.localScale = Vector3.forward + Vector3.up + Vector3.right * this.maxFill; if (ResourceBar.Instance.IsItemEnabled(ResourceBar.Item.PlayerProgress) && this.canLevelUp) { this.SetState(PlayerProgressBar.State.WaitingLevelActive); } else { this.SetState(PlayerProgressBar.State.WaitingLevelInactive); } } else { TextMeshHelper.UpdateTextMeshes(this.experienceLabel, string.Format("{0}/{1}", this.targetExperience, experienceToNextLevel), false); float d = Mathf.Clamp((float)this.currentExperience / (float)experienceToNextLevel, 0.001f, 1f); this.experienceFillMeter.localScale = Vector3.forward + Vector3.up + Vector3.right * d * this.maxFill; } } }
private void UpdateDaysLeft() { string arg = string.Format("{0}", this.SeasonDaysLeft()); Localizer.LocaleParameters localeParameters = Singleton <Localizer> .Instance.Resolve(this.daysLeftKey, null); TextMeshHelper.UpdateTextMeshes(this.daysLeftTextMesh, string.Format(localeParameters.translation, arg), false); }
public void SetRewards(LootCrateType crateType, int snoutCoins) { TextMeshHelper.UpdateTextMeshes(this.coinRewardLabel, snoutCoins.ToString(), false); for (int i = 0; i < this.rewardCrateContainer.childCount; i++) { Transform child = this.rewardCrateContainer.GetChild(i); child.gameObject.SetActive(child.name.Equals(crateType.ToString())); } }
public void SetPlayerInfo(string name, int level, bool refreshTranslation = false) { if (string.IsNullOrEmpty(name)) { name = "anonpig"; } TextMeshHelper.UpdateTextMeshes(this.nameLabel, name, refreshTranslation); TextMeshHelper.UpdateTextMeshes(this.levelLabel, Mathf.Clamp(level, 0, 999).ToString(), refreshTranslation); }
public void SetInfo(int track, int score, int cakeCount, bool kingsFavorite) { TextMeshHelper.UpdateTextMeshes(this.trackLabel, string.Format("{0}", track + 1), false); TextMeshHelper.UpdateTextMeshes(this.scoreLabel, (score > 0) ? string.Format("{0:n0}", score) : "-", false); this.kingsFavoriteIcon.enabled = kingsFavorite; for (int i = 0; i < this.cakes.Length; i++) { this.cakes[i].enabled = (i < cakeCount); } }
private void SetNameLabels(string left, string right, bool refreshLocalization) { if (this.leftName != null) { TextMeshHelper.UpdateTextMeshes(this.leftName, left, refreshLocalization); } if (this.rightName != null) { TextMeshHelper.UpdateTextMeshes(this.rightName, right, false); } }
private void Wrap(TextMesh target) { if (TextMeshHelper.UsesKanjiCharacters()) { TextMeshHelper.Wrap(target, this.maxKanjiCharactersInLine, false); } else { TextMeshHelper.Wrap(target, this.maxCharacterInLine, false); } }
private void SetScoreLabels(int score, int opponentScore) { if (this.leftScore != null) { TextMeshHelper.UpdateTextMeshes(this.leftScore, (score >= 0) ? string.Format("{0:n0}", score) : string.Empty, false); } if (this.rightScore != null) { TextMeshHelper.UpdateTextMeshes(this.rightScore, (opponentScore >= 0) ? string.Format("{0:n0}", opponentScore) : string.Empty, false); } }
private void Awake() { this.SetStatus(ExtraCoinsRewardButton.Status.Uninitialized); if (this.labels != null && this.labels.Length > 0) { this.rewardAmount = Singleton <GameConfigurationManager> .Instance.GetValue <int>("extra_coins_video", "coin_reward"); string text = string.Format(this.stringFormat, this.rewardAmount); TextMeshHelper.UpdateTextMeshes(this.labels, text, false); } this.Initialize(); }
private void SetLockScreen(bool locked, string localeKey, bool loading) { if (this.lockScreen != null) { this.lockScreen.SetActive(locked); TextMesh[] componentsInChildren = this.lockScreen.GetComponentsInChildren <TextMesh>(); TextMeshHelper.UpdateTextMeshes(componentsInChildren, localeKey, !string.IsNullOrEmpty(localeKey)); } if (this.lockScreenLoading != null) { this.lockScreenLoading.SetActive(loading); } }
private void ChangeState(State newState) { this.state = newState; if (this.state == LootCrateSlot.State.Empty) { this.crateType = LootCrateType.None; } this.activeTf.gameObject.SetActive(this.state != LootCrateSlot.State.Empty); this.emptyTf.gameObject.SetActive(this.state == LootCrateSlot.State.Empty); this.unlockedTf.gameObject.SetActive(this.state == LootCrateSlot.State.Unlocked); this.priceTf.gameObject.SetActive(this.state == LootCrateSlot.State.Locked); this.timeTf.gameObject.SetActive(this.state != LootCrateSlot.State.Unlocked); this.lockIcon.enabled = (this.state == LootCrateSlot.State.Inactive); this.clockIcon.enabled = (this.state == LootCrateSlot.State.Locked); bool flag = this.state == LootCrateSlot.State.Unlocked || this.state == LootCrateSlot.State.Inactive; this.crateHolder.transform.localScale = Vector3.one * ((!flag) ? 1f : 1.2f); this.crateHolder.transform.localPosition = Vector3.up * ((!flag) ? 0.1f : 0f); if (this.crateType != LootCrateType.None && this.crateHolder.childCount == 0 && this.state != LootCrateSlot.State.Empty) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(LootCrateSlots.GetCratePrefab(this.crateType)); gameObject.transform.parent = this.crateHolder; gameObject.transform.localPosition = Vector3.zero; gameObject.transform.localScale = Vector3.one; gameObject.transform.localRotation = Quaternion.identity; } else if (this.crateHolder.childCount > 0 && this.state == LootCrateSlot.State.Empty) { for (int i = 0; i < this.crateHolder.childCount; i++) { Transform child = this.crateHolder.GetChild(i); if (child) { UnityEngine.Object.Destroy(child.gameObject); } } } if (this.state == LootCrateSlot.State.Locked) { Localizer.LocaleParameters localeParameters = Singleton <Localizer> .Instance.Resolve(this.openNowLocalization, null); TextMeshHelper.UpdateTextMeshes(this.activeInfoLabel, localeParameters.translation, false); TextMeshHelper.Wrap(this.activeInfoLabel, (!TextMeshHelper.UsesKanjiCharacters()) ? 8 : 4); } else { TextMeshHelper.UpdateTextMeshes(this.activeInfoLabel, string.Empty, false); } this.UpdateLabels(); }
public void UpdateAmount(bool forceUpdate = false) { if (this.labels == null || !GameProgress.Initialized) { return; } this.targetAmount = this.GetCurrencyCount(); this.nextUpdate = Time.realtimeSinceStartup; if (forceUpdate) { this.currentAmount = this.targetAmount; TextMeshHelper.UpdateTextMeshes(this.labels, string.Format("{0}", this.currentAmount), false); } }
public static void Wrap(TextMesh[] textMesh, int maxCharactersOnRow) { if (textMesh == null || textMesh.Length == 0) { return; } for (int i = 0; i < textMesh.Length; i++) { if (textMesh[i] != null) { TextMeshHelper.Wrap(textMesh[i], maxCharactersOnRow, false); } } }
private void SetText(string localeKey) { this.thisLocaleKey = localeKey; this.textMesh.text = this.thisLocaleKey; this.locale.RefreshTranslation(null); if (TextMeshHelper.UsesKanjiCharacters()) { TextMeshHelper.Wrap(this.textMesh, 13, false); } else { TextMeshHelper.Wrap(this.textMesh, 24, false); } }
protected virtual void Start() { for (int i = 0; i < this.texts.Length; i++) { this.texts[i].textMesh.text = this.texts[i].localizationKey; TextMeshLocale component = this.texts[i].textMesh.gameObject.GetComponent <TextMeshLocale>(); if (component != null) { component.RefreshTranslation(null); component.enabled = false; TextMeshHelper.Wrap(this.texts[i].textMesh, (!TextMeshHelper.UsesKanjiCharacters()) ? this.maxCharactersInLine : this.maxKanjiCharacterInLine, false); } } }
public void SetInfo(string playFabId, string name, int score, int rank) { this.playFabId = playFabId; this.playerName = name; this.playerScore = score; this.playerRank = rank; if (string.IsNullOrEmpty(playFabId)) { this.Show(false); return; } this.Show(true); bool flag = playFabId.Equals(HatchManager.CurrentPlayer.PlayFabID); string format = (!flag) ? "{0}" : string.Format("{0} ({1})", this.GetLocalizedPlayerName(), "{0}"); string[] array = name.Split(new char[] { '|' }); if (array != null && array.Length > 0) { this.playerName = string.Format(format, array[0]); } else { this.playerName = string.Format(format, name); } TextMeshHelper.UpdateTextMeshes(this.nameLabel, this.playerName, false); TextMeshHelper.UpdateTextMeshes(this.scoreLabel, string.Format("{0:n0}", score), false); if (rank >= 0) { this.SetRank(rank + 1); } else { this.SetRank(rank); } if (this.otherPlayerBackground != null) { this.otherPlayerBackground.enabled = !flag; } if (this.currentPlayerBackground != null) { this.currentPlayerBackground.enabled = flag; } if (this.currentPlayerInfoButton != null) { this.currentPlayerInfoButton.enabled = flag; } }
private void SetWinCount(int wins) { CakeRaceMenu.WinCount = wins; if (CakeRaceMenu.IsTutorial) { Localizer.LocaleParameters localeParameters = Singleton <Localizer> .Instance.Resolve(this.winsLabelKey, null); TextMeshHelper.UpdateTextMeshes(this.winsLabel, string.Format(localeParameters.translation, CakeRaceMenu.WinCount), false); TextMeshHelper.Wrap(this.winsLabel, (!TextMeshHelper.UsesKanjiCharacters()) ? 1 : 6); } else { TextMeshHelper.UpdateTextMeshes(this.winsLabel, string.Empty, false); } }
public void SetLevelRequirement(int levelRequirement) { Localizer.LocaleParameters localeParameters = Singleton <Localizer> .Instance.Resolve(this.descriptionKey, null); if (localeParameters.translation.Contains("{0}")) { TextMeshHelper.UpdateTextMeshes(this.descriptionLabel, string.Format(localeParameters.translation, levelRequirement), false); } else { TextMeshHelper.UpdateTextMeshes(this.descriptionLabel, localeParameters.translation, false); } TextMeshHelper.Wrap(this.descriptionLabel, (!TextMeshHelper.UsesKanjiCharacters()) ? 16 : 8); TextMeshHelper.UpdateTextMeshes(this.levelRequirementLabel, levelRequirement.ToString(), false); }
public void SetRewards(LootCrateType crateType, int coinAmount) { for (int i = 0; i < this.crateIcons.Length; i++) { if (this.crateIcons[i] != null) { this.crateIcons[i].SetActive(crateType != LootCrateType.None && i == Mathf.Clamp((int)crateType, 0, 6)); } } if (this.coinPrizeContainer != null) { TextMeshHelper.UpdateTextMeshes(this.coinPrizeLabel, coinAmount.ToString(), false); this.coinPrizeContainer.gameObject.SetActive(coinAmount > 0); } }
private void UpdateLabels() { string formattedTimeFromSeconds = LootCrateSlot.GetFormattedTimeFromSeconds((int)this.TimeLeftInSeconds()); this.nextLabelUpdateTime = Time.realtimeSinceStartup + 1f; TextMeshHelper.UpdateTextMeshes(this.timeLabel, formattedTimeFromSeconds, false); TextMeshHelper.UpdateTextMeshes(this.priceLabel, string.Format("{0} [snout]", LootCrateSlot.GetSnoutCoinPrice(this.crateType, this.TimeLeftInSeconds())), false); TextMeshSpriteIcons[] componentsInChildren = this.priceTf.GetComponentsInChildren <TextMeshSpriteIcons>(); if (componentsInChildren != null) { for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].UpdateIcons(); } } }
public void SetRankScoreInfo(int rank, int score, bool isLocalPlayer = false) { this.Init(); this.trophies.gameObject.SetActive(isLocalPlayer); this.scroller.SetLowerPadding((!isLocalPlayer) ? -5.5f : 2f); TextMeshHelper.UpdateTextMeshes(this.rankLabel, (rank > 0) ? rank.ToString() : "-", false); TextMeshHelper.UpdateTextMeshes(this.scoreLabel, (score > 0) ? string.Format("{0:n0}", score) : "-", false); for (int i = 0; i < this.rankBackgrounds.Length; i++) { if (this.rankBackgrounds[i] != null) { this.rankBackgrounds[i].enabled = (i + 1 == rank || (i == 3 && (rank > 3 || rank == 0))); } } if (isLocalPlayer) { this.UpdatePlayerStats(); } }
private void Lock(bool doLock) { this.isLocked = doLock; if (this.lockedContainer) { this.lockedContainer.SetActive(doLock); } if (this.unlockedContainer) { this.unlockedContainer.SetActive(!doLock); } if (doLock) { TextMeshHelper.UpdateTextMeshes(this.levelLabel, this.levelRequirement.ToString(), false); } if (this.OnUnlock != null) { this.OnUnlock(!doLock); } }
private void RefreshLocalization() { for (int i = 0; i < this.texts.Length; i++) { this.texts[i].textMesh.text = this.texts[i].localizationKey; TextMeshLocale component = this.texts[i].textMesh.gameObject.GetComponent <TextMeshLocale>(); if (component != null) { component.RefreshTranslation(null); string text = this.texts[i].textMesh.text; if (this.texts[i].textMesh.name.Equals("ScrapLabel") && text.Contains("{0}") && text.Contains("{1}")) { string arg = string.Empty; switch (this.partTier) { case BasePart.PartTier.Common: arg = "[common_star]"; break; case BasePart.PartTier.Rare: arg = "[rare_star][rare_star]"; break; case BasePart.PartTier.Epic: arg = "[epic_star][epic_star][epic_star]"; break; case BasePart.PartTier.Legendary: arg = "[legendary_icon]"; break; } this.texts[i].textMesh.text = string.Format(text, this.buyScrapAmount, arg); } component.enabled = false; TextMeshSpriteIcons.EnsureSpriteIcon(this.texts[i].textMesh); TextMeshHelper.Wrap(this.texts[i].textMesh, (!TextMeshHelper.UsesKanjiCharacters()) ? this.maxCharactersInLine : this.maxKanjiCharacterInLine, false); } } }
public void SetCrateRankAndReward(LootCrateType crateType, int rank, int reward) { this.reward = reward; Localizer.LocaleParameters localeParameters = Singleton <Localizer> .Instance.Resolve(this.rankLocalizationKey, null); TextMeshHelper.UpdateTextMeshes(this.rankLabel, string.Format(localeParameters.translation, rank), false); TextMeshHelper.Wrap(this.rankLabel, 15); Localizer.LocaleParameters localeParameters2 = Singleton <Localizer> .Instance.Resolve(this.snoutRewardLocalizationKey, null); TextMeshHelper.UpdateTextMeshes(this.rewardLabel, string.Format(localeParameters2.translation, reward), false); TextMeshSpriteIcons.EnsureSpriteIcon(this.rewardLabel); TextMeshHelper.Wrap(this.rewardLabel, 15); this.lootCrate.gameObject.SetActive(crateType != LootCrateType.None); this.barrelContainer.SetActive(crateType == LootCrateType.None); if (crateType != LootCrateType.None) { this.lootCrate.initialSkinName = crateType.ToString(); this.lootCrate.Initialize(true); this.lootCrate.state.SetAnimation(0, "Idle", true); this.lootCrate.Update(Time.deltaTime); } this.SetLoading(false); }
protected override void Awake() { base.Awake(); Transform transform = this.dialogRoot.transform.Find("TitleRibbon/TitleLabel"); if (transform != null) { this.titleLabel = transform.GetComponentsInChildren <TextMesh>(); } transform = this.dialogRoot.transform.Find("RewardContainer/RankLabel"); if (transform != null) { this.rankLabel = transform.GetComponentsInChildren <TextMesh>(); } transform = this.dialogRoot.transform.Find("RewardContainer/RewardLabel"); if (transform != null) { this.rewardLabel = transform.GetComponentsInChildren <TextMesh>(); } Localizer.LocaleParameters localeParameters = Singleton <Localizer> .Instance.Resolve(this.titleLocalizationKey, null); TextMeshHelper.UpdateTextMeshes(this.titleLabel, string.Format(localeParameters.translation, CakeRaceMenu.CurrentCakeRaceWeek() - 1), false); }
private void SetRank(int rank) { TextMeshHelper.ForceWrapText(this.rankLabel, (rank >= 0) ? rank.ToString() : "-", 3); this.rankLabel[0].transform.localScale = ((rank < 100) ? new Vector3(0.12f, 0.12f) : new Vector3(0.09f, 0.09f)); if (this.rankIcons != null && this.trophyIcons != null) { if (rank < 0) { rank = 4; } for (int i = 0; i < this.rankIcons.Length; i++) { if (this.rankIcons[i] != null) { this.rankIcons[i].enabled = (i + 1 == Mathf.Clamp(rank, 1, 4)); } if (i < this.trophyIcons.Length && this.trophyIcons[i] != null) { this.trophyIcons[i].enabled = (i + 1 == Mathf.Clamp(rank, 1, 4)); } } } }