コード例 #1
0
    public int GetEndifLine()
    {
        int unclosedIfs = 0;

        for (int i = currentLine + 1; i < vsnScriptContent.Length; i++)
        {
            string line    = vsnScriptContent[i];
            string command = OldVSNCommands.GetCommand(line);
            if (command == "if")
            {
                unclosedIfs++;
                continue;
            }
            if (command == "endif")
            {
                if (unclosedIfs == 0)
                {
                    return(i);
                }
                else
                {
                    unclosedIfs--;
                }
            }
        }

        Debug.LogError("NO ENDIF FOUND");

        return(-1);
    }
コード例 #2
0
    void StoreWaypointsAndCountLines()
    {
        Dictionary <string, int> waypoints = new Dictionary <string, int>();
        int        lineCount  = 1;
        bool       canGetItem = true;
        string     line       = null;
        TextReader reader;

        if (Persistence.debugMode && false)
        {
            FileStream scriptFile = new FileStream("script_debug.txt", FileMode.Open, FileAccess.Read);
            reader = new StreamReader(scriptFile);
        }
        else
        {
            reader = new StringReader(currentScript.text);
        }

        while ((line = reader.ReadLine()) != null)
        {
//      Debug.Log("Starting line "+lineCount+".");

            if (line.Length <= 1)
            {
                lineCount++;
                continue;
            }

            string currentCommand = OldVSNCommands.GetCommand(line);
            if (currentCommand == "" || currentCommand == null)
            {
                continue;
            }

            if (currentCommand == "waypoint")
            {
                string[] param        = OldVSNCommands.GetParams(line);
                string   waypointName = param[0];
                Debug.Log(waypointName + " in line " + lineCount);
                waypoints.Add(waypointName, lineCount);
            }
            if (currentCommand == "mouth_anim")
            {
                commandController.CheckCommand(line, lineCount);
            }
            if (currentCommand == "eye_blink_anim")
            {
                commandController.CheckCommand(line, lineCount);
            }

            lineCount++;
        }
        totalLines = lineCount;

        reader.Close();
        commandController.waypoints = waypoints;
    }