Beispiel #1
0
    public static List <Entry> GetBuildingTooltip(BlockScheme scheme, List <Entry> _entries = null)
    {
        List <Entry> entries = new List <Entry>();

        entries.Add(new Entry("block" + scheme.ID.ToString(), "blockName", informationType.Neutral));
        entries.Add(new Entry("block" + scheme.ID.ToString(), "blockDescription", informationType.Neutral));
        entries.Add(new Entry(entryType.LineBreak));

        // Porting previous block tooltip entries to this list
        if (_entries != null)
        {
            foreach (Entry tte in _entries)
            {
                entries.Add(tte);
            }
            entries.Add(new Entry(entryType.LineBreak));
        }

        // Flag reading to get the block bonuses and maluses
        foreach (List <string> flag in FlagReader.GetFlags(scheme))
        {
            string name = flag[0];
            flag.Remove(name);
            string[] parameters = flag.ToArray();

            for (int i = 0; i < parameters.Length; i++)
            {
                string popInfo = "";
                bool   wasPop  = false;
                foreach (string popName in parameters[i].Split('-'))
                {
                    if (GameManager.instance.populationManager.GetPopulationByCodename(popName) != null)
                    {
                        if (popInfo.Length > 0)
                        {
                            popInfo += " " + GameManager.instance.localization.GetLineFromCategory("stats", "orSeparator") + " ";
                        }
                        popInfo += GameManager.instance.localization.GetLineFromCategory("populationType", popName);
                        wasPop   = true;
                    }
                }
                if (wasPop)
                {
                    parameters[i] = popInfo;
                }
            }

            entries.Add(new Entry(
                            name.ToLower(), "flagParameter", FlagReader.IsPositive(name) ? informationType.Positive : informationType.Negative, parameters
                            ));
        }

        // Conditional unlocking
        ConditionalUnlocks unlocker = GameManager.instance.cityManager.conditionalUnlocker;

        if (!unlocker.CanBeUnlocked(scheme.ID))
        {
            entries.Add(new Entry(entryType.LineBreak));

            // Bold line
            entries.Add(new Entry(
                            "toUnlockThisBuildingYouMust", "conditionalUnlock", informationType.Neutral
                            )
            {
                formatters = new string[1] {
                    "b"
                }
            });

            // Condition (= <= >= < >)
            foreach (ScriptInterpreter.FormattedComparison condition in unlocker.GetFormattedUnlockConditions(scheme.ID))
            {
                // If Int, no need to tranlate it

                entries.Add(new Entry(
                                condition.oprtr, "conditionalUnlock", informationType.Negative,
                                condition.lefthandData.GetLocalization(GameManager.instance.localization),
                                condition.righthandData.GetLocalization(GameManager.instance.localization)
                                ));
            }
        }

        return(entries);
    }