Пример #1
0
    void Awake()
    {
        System.Globalization.CultureInfo.CurrentCulture = System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.NeutralCultures)[0];

        appPath = Application.streamingAssetsPath;

        dialogueLine = new List <int>(1)
        {
            0
        };

        parser        = new TextParser(this);
        choiceManager = new ChoiceManager();
        charManager   = new CharacterManager(startingCast);

        themeConstructor = new ThemeConstructor(this);

        uiConstructor = new UIConstructor();
        uiManager     = new UIManager(this, uiConstructor.ConstructText(Color.black), uiConstructor.ConstructGroup(1, false, Color.gray), uiConstructor.ConstructCanvas(), uiConstructor.ConstructButton(Color.black, Color.black), uiConstructor.ConstructGroup(0, false, Color.gray), uiConstructor.ConstructLayoutGroup());

        varManager      = new VariableManager();
        functionManager = new FunctionManager(this);

        //Base starting values
        if (startWithExposition)
        {
            varManager.SetVar(new string[] { "charVisible=0" });
        }
        else
        {
            varManager.SetVar(new string[] { "charVisible=1" });
        }
        varManager.SetVar(new string[] { "typeRate=" + startingTextSpeed });
        varManager.SetVar(new string[] { "buildV=" + version });
        varManager.SetVar(new string[] { "pitch=1" });

        thes      = new Thesaurus("Default");
        uiManager = themeConstructor.ConstructTheme("Default");
    }
Пример #2
0
        public void InterpretFunction(string line)
        {
            string arg = line.Substring(line.IndexOf("(")).Replace("(", "").Replace(")", "");

            line = line.ToLower();
            string funcName = line.Substring(0, line.IndexOf("("));

            thes = DialogueManager.thes;
            if (thes.IsSynonym("opentheme", funcName))
            {
                DialogueManager.uiManager = themeConstructor.ConstructTheme(arg);
            }
            else if (thes.IsSynonym("savetheme", funcName))
            {
                themeSaver.CreateTheme(arg);
                DialogueManager.uiManager.ResetUI();
                DialogueManager.uiManager = themeConstructor.ConstructTheme(arg);
            }
            else if (thes.IsSynonym("setpersistentvar", funcName))
            {
                arg = arg.Replace(" ", "");
                varManager.SetVar(parser.ParseParameters(arg), true);
            }
            else if (thes.IsSynonym("setvar", funcName))
            {
                arg = arg.Replace(" ", "");
                varManager.SetVar(parser.ParseParameters(arg));
            }
            else if (thes.IsSynonym("resetvar", funcName))
            {
                arg = arg.Replace(" ", "");
                varManager.ResetVar();
            }
            else if (thes.IsSynonym("comparevar", funcName))
            {
                string[] statements = parser.ParseParameters(arg);
                bool     hasElse    = statements[statements.Length - 1] == "else";
                DialogueManager.uiManager.choices = new string[statements.Length];
                int index = varManager.CompareVar(statements) - 1;
                if (index >= 0)
                {
                    DialogueManager.uiManager.ChooseChoice(index);
                }
                else if (hasElse)
                {
                    DialogueManager.uiManager.ChooseChoice(DialogueManager.uiManager.choices.Length - 1);
                }
                else
                {
                    dialogue.FallThrough();
                    DialogueManager.currentlyActiveChoice.choicesPassed += DialogueManager.uiManager.choices.Length;
                }
            }
            else if (thes.IsSynonym("setcast", funcName))
            {
                charManager.SetCharacterCast(parser.ParseParameters(arg));
            }
            else if (thes.IsSynonym("setchar", funcName))
            {
                charManager.SetCurrentChar(arg);
            }
            else if (thes.IsSynonym("random", funcName))
            {
                arg = arg.Replace(" ", "");
                Random(parser.ParseParameters(arg));
            }
            else if (thes.IsSynonym("goto", funcName))
            {
                arg = arg.Replace(" ", "");
                GotoKey(arg);
            }
            else if (thes.IsSynonym("setkey", funcName))
            {
                arg = arg.Replace(" ", "");
                varManager.SetKey(arg);
            }
            else if (thes.IsSynonym("loadthes", funcName))
            {
                arg = arg.Replace(" ", "");
                DialogueManager.thes = new Thesaurus(arg);
            }
            else if (thes.IsSynonym("requirechar", funcName))
            {
                string val = (arg.ToLower() == "false" ? "0" : "1");
                varManager.SetVar(new string[] { "charVisible=" + val });
            }
            else if (thes.IsSynonym("setspeed", funcName))
            {
                if (arg == "d" || arg == "default")
                {
                    arg = dialogue.startingTextSpeed + "";
                }
                varManager.SetVar(new string[] { "typeRate=" + arg });
            }
            else if (thes.IsSynonym("loadfile", funcName))
            {
                string[] args = parser.ParseParameters(arg);
                DialogueManager.parser.MakeTree(args[1].Replace(" ", ""), args[0]);
                DialogueManager.dialogueLine = new List <int>(1)
                {
                    0
                };
                dialogue.StartReading(DialogueManager.parser.dialogue);
            }
            else if (thes.IsSynonym("wait", funcName))
            {
                if (float.TryParse(arg, out float t))
                {
                    dialogue.FallThrough(t);
                }
                else
                {
                    throw new Exception("Snow# 4: Argument of the '$Wait' function must be a numerical value. Value found was: [" + arg + "]");
                }
            }
            else if (thes.IsSynonym("quit", funcName))
            {
                Application.Quit();
            }
        }