Exemplo n.º 1
0
 public override void OnEnter()
 {
     GlobalVariables.Save(saveName);
 }
Exemplo n.º 2
0
 public override void OnEnter()
 {
     GlobalVariables.Load(saveName);
     Continue();
 }
Exemplo n.º 3
0
        void ProcessText(string text)
        {
            // Split text into lines. Add a newline at end to ensure last command is always parsed
            string[] lines = Regex.Split(text + "\n", "(?<=\n)");

            string blockBuffer = "";

            ParseMode mode = ParseMode.Idle;

            string blockTag = "";

            for (int i = 0; i < lines.Length; ++i)
            {
                string line = lines[i];

                bool newBlock = line.StartsWith("$");

                if (mode == ParseMode.Idle && !newBlock)
                {
                    // Ignore any text not preceded by a label tag
                    continue;
                }

                string newBlockTag = "";
                if (newBlock)
                {
                    newBlockTag = line.Replace("\n", "");
                }

                bool endOfFile = (i == lines.Length - 1);

                bool storeBlock = false;

                if (newBlock)
                {
                    storeBlock = true;
                }
                else if (mode == ParseMode.Text && endOfFile)
                {
                    storeBlock = true;
                    if (!line.StartsWith("#"))
                    {
                        blockBuffer += line;
                    }
                }
                else
                {
                    if (!line.StartsWith("#"))
                    {
                        blockBuffer += line;
                    }
                }

                if (storeBlock)
                {
                    if (blockTag.Length > 0 && blockBuffer.Length > 0)
                    {
                        // Trim off last newline
                        blockBuffer = blockBuffer.TrimEnd('\r', '\n', ' ', '\t');

                        GlobalVariables.SetString(blockTag, blockBuffer);
                    }

                    // Prepare to parse next block
                    mode = ParseMode.Idle;
                    if (newBlock)
                    {
                        mode     = ParseMode.Text;
                        blockTag = newBlockTag;
                    }

                    blockBuffer = "";
                }
            }
        }