Beispiel #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);
     }
 }
Beispiel #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);
                }
            }
        }
    }
Beispiel #3
0
 private void Wrap(TextMesh target)
 {
     if (TextMeshHelper.UsesKanjiCharacters())
     {
         TextMeshHelper.Wrap(target, this.maxKanjiCharactersInLine, false);
     }
     else
     {
         TextMeshHelper.Wrap(target, this.maxCharacterInLine, false);
     }
 }
Beispiel #4
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);
         }
     }
 }
Beispiel #5
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();
    }
Beispiel #6
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);
     }
 }
    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);
    }
Beispiel #8
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);
        }
    }
Beispiel #9
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);
            }
        }
    }
Beispiel #10
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);
    }
Beispiel #11
0
    public static void Wrap(TextMesh textMesh, int maxCharactersOnRow, bool splitHyphen = false)
    {
        if (textMesh == null || maxCharactersOnRow <= 0)
        {
            return;
        }
        string text = textMesh.text;

        text = text.Replace("\n", " ");
        text = text.Replace("\r", " ");
        StringBuilder stringBuilder = new StringBuilder();
        int           num           = 0;
        bool          flag          = false;

        if (TextMeshHelper.UsesKanjiCharacters())
        {
            for (int i = 0; i < text.Length; i++)
            {
                if (!flag && text[i].Equals('<'))
                {
                    flag = true;
                }
                if (!flag)
                {
                    num++;
                    if (num > maxCharactersOnRow)
                    {
                        num = 0;
                        stringBuilder.Append('\n');
                    }
                }
                else if (text[i].Equals('>'))
                {
                    flag = false;
                }
                stringBuilder.Append(text[i]);
            }
        }
        else
        {
            char[] array2;
            if (splitHyphen)
            {
                char[] array = new char[2];
                array[0] = ' ';
                array2   = array;
                array[1] = '-';
            }
            else
            {
                (array2 = new char[1])[0] = ' ';
            }
            char[]   separator = array2;
            string[] array3    = text.Split(separator);
            int      num2      = 0;
            foreach (string text2 in array3)
            {
                bool flag2 = false;
                if (!flag && text2.Contains("<quad"))
                {
                    flag = true;
                }
                if (!flag)
                {
                    num2++;
                    num += text2.Length;
                    if (num2 > 1 && num >= maxCharactersOnRow)
                    {
                        num = text2.Length;
                        stringBuilder.Append('\n');
                    }
                }
                else if (text2.Contains("/>"))
                {
                    num++;
                    if (num2 > 1 && num >= maxCharactersOnRow)
                    {
                        num   = 1;
                        flag2 = true;
                    }
                    if (!text2.Contains("/><quad"))
                    {
                        flag = false;
                    }
                }
                if (text2.Contains("/><quad") && flag2)
                {
                    stringBuilder.Append(text2.Replace("><", ">\n<"));
                    flag2 = false;
                }
                else
                {
                    stringBuilder.Append(text2);
                }
                if (flag2)
                {
                    stringBuilder.Append('\n');
                }
                if (num2 < array3.Length)
                {
                    stringBuilder.Append(' ');
                }
            }
        }
        textMesh.text = stringBuilder.ToString();
    }