Beispiel #1
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;
                }
            }
        }
Beispiel #2
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));
        }