示例#1
0
 private void TextUpdated(GameObject go)
 {
     if (go != null && go == base.gameObject)
     {
         TextMeshHelper.Wrap(go.GetComponent <TextMesh>(), (!TextMeshHelper.UsesKanjiCharacters()) ? this.maxCharacters : this.maxKanjiCharacters, this.splitHyphen);
     }
 }
示例#2
0
    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);
                }
            }
        }
    }
示例#3
0
    private void UpdateDaysLeft()
    {
        string arg = string.Format("{0}", this.SeasonDaysLeft());

        Localizer.LocaleParameters localeParameters = Singleton <Localizer> .Instance.Resolve(this.daysLeftLabelKey, null);

        TextMeshHelper.UpdateTextMeshes(this.daysLeftLabel, string.Format(localeParameters.translation, arg), false);
        TextMeshHelper.Wrap(this.daysLeftLabel, 5);
    }
示例#4
0
 private void Wrap(TextMesh target)
 {
     if (TextMeshHelper.UsesKanjiCharacters())
     {
         TextMeshHelper.Wrap(target, this.maxKanjiCharactersInLine, false);
     }
     else
     {
         TextMeshHelper.Wrap(target, this.maxCharacterInLine, false);
     }
 }
示例#5
0
 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);
         }
     }
 }
示例#6
0
    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();
    }
示例#7
0
 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);
         }
     }
 }
示例#8
0
 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);
     }
 }
示例#9
0
    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);
    }
示例#10
0
    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);
        }
    }
示例#11
0
    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);
            }
        }
    }
示例#12
0
    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);
    }
示例#13
0
    private void UpdateTextMeshLocale(TextMesh textMesh, string localeKey, int maxRowCharacters = -1, string postfix = "")
    {
        if (textMesh == null)
        {
            return;
        }
        textMesh.text = localeKey;
        TextMeshLocale component = textMesh.GetComponent <TextMeshLocale>();

        if (component != null)
        {
            component.RefreshTranslation(null);
            if (TextMeshHelper.UsesKanjiCharacters() && localeKey.Equals("REWARD_DAY"))
            {
                component.Postfix = string.Empty;
                textMesh.text     = string.Format(textMesh.text, postfix.Replace(" ", string.Empty));
            }
            else
            {
                component.Postfix = ((!string.IsNullOrEmpty(postfix)) ? postfix : string.Empty);
            }
        }
        TextMeshHelper.Wrap(textMesh, maxRowCharacters, false);
    }