Esempio n. 1
0
 public ChoiceLineContent(string speaker, string lineText, int lineNumber, string jumpLabel, ScriptLine jumpLine = null)
 {
     this.lineText   = lineText;
     this.lineNumber = lineNumber;
     this.jumpLabel  = jumpLabel;
     this.jumpLine   = jumpLine;
 }
        private void SetVariable_Click(object sender, RoutedEventArgs e)
        {
            var newSetVariableWindow = new ScriptEditors.SetVariableEditor();
            var script = this.DataContext as Script;

            if (script != null)
            {
                var newSetVariable = new Scripter.Flow.SetVariable();
                script.AddBeforeSelected(newSetVariable);
                newSetVariable.SelectedVariable  = new ObjectTypes.VarRef();
                newSetVariable.TargetVar         = new ObjectTypes.VarRef();
                newSetVariableWindow.DataContext = newSetVariable;
                newSetVariableWindow.ShowDialog();
                if (newSetVariableWindow.DialogResult == true)
                {
                    invalidate = true;
                    newItem    = newSetVariable;
                    this.Close();
                }
                else
                {
                    script.ScriptLines.Remove(newSetVariable);
                }
            }
        }
Esempio n. 3
0
 public void Delete()
 {
     PrevByTime.NextByTime = NextByTime;
     NextByTime.PrevByTime = PrevByTime;
     PrevByTime            = null;
     NextByTime            = null;
 }
    public ResponseAccuracyStats CheckResponse(string playerResponse)
    {
        ScriptLine activeLine = _scriptManager.GetActiveLine();
        Regex      pattern    = new Regex("[;,!.]");
        string     expected   = pattern.Replace(activeLine.line, "");

        Debug.Log("checking (" + playerResponse + ") vs. expected (" + expected + ")");
        // TODO: handle special characters
        string[] activeWords      = expected.Split();
        string[] playerWords      = playerResponse.Split();
        int      numWordsCorrect  = 0;
        int      numWordsExpected = activeWords.Length;

        for (int i = 0; i < numWordsExpected && i < playerWords.Length; i++)
        {
            // TODO: perform better and more forgiving checking versus exact match, in order
            Debug.Log("comparing: (" + activeWords[i] + ") and (" + playerWords[i] + ")");
            if (activeWords[i].Equals(playerWords[i], StringComparison.OrdinalIgnoreCase))
            {
                numWordsCorrect++;
            }
        }
        ResponseAccuracyStats stats = new ResponseAccuracyStats();

        stats.NumWordsCorrect  = numWordsCorrect;
        stats.NumWordsExpected = numWordsExpected;
        return(stats);
    }
Esempio n. 5
0
        /// *******************************************************
        /// <summary>コマンド実行</summary>
        /// *******************************************************
        private void PlayLine(EnemyControll character, ScriptLine line)
        {
            var last_limit = Limit;

            CommandAttribute keY_atr  = line.GetAttribute("key");
            bool             have_key = (keY_atr != null);

            Limit = LIMIT_TYPE.NEAR;
            switch (line.CommandName)
            {
            case "position": character.TargetDirection = TargetType.DIRECTION_POSITION; break;

            case "target": character.TargetDirection = TargetType.DIRECTION_TARGET; break;

            case "angle": character.TargetDirection = TargetType.DIRECTION_ANGLE; break;

            case "bottom": character.TargetDirection = TargetType.DIRECTION_BOTTOM; break;

            case "top": character.TargetDirection = TargetType.DIRECTION_TOP; break;

            case "left": character.TargetDirection = TargetType.DIRECTION_LEFT; break;

            case "right": character.TargetDirection = TargetType.DIRECTION_RIGHT; break;

            case "shot": ShotCommand(character, line); return;
            }

            line.Attributes.ForEach(atr => {
                if (RunAttribute(atr) == false)
                {
                    Manager.OverrideParam(atr, have_key);
                }
            });
        }
Esempio n. 6
0
        public override string ToString()
        {
            if (_lines == null)
            {
                return("");
            }
            StringBuilder stringBuilder = new StringBuilder(_length);
            IEnumerator   iEnumerator   = _lines.GetEnumerator();

            try
            {
                while (iEnumerator.MoveNext())
                {
                    ScriptLine scriptLine = (ScriptLine)iEnumerator.Current;
                    scriptLine.Padding = scriptLine.Padding - _minPadding;
                    stringBuilder.Append(scriptLine.ToString());
                    stringBuilder.Append(Environment.NewLine);
                }
            }
            finally
            {
                IDisposable iDisposable = iEnumerator as IDisposable;
                if (iDisposable != null)
                {
                    iDisposable.Dispose();
                }
            }
            return(stringBuilder.ToString());
        }
Esempio n. 7
0
        static List <ScriptLine> GetScriptLines(string scriptText)
        {
            var currentLineBuilder = new StringBuilder();
            var result             = new List <ScriptLine>();
            var currentLine        = new ScriptLine();

            if (scriptText.Length > 0)
            {
                result.Add(currentLine);
            }

            for (var i = 0; i < scriptText.Length; i++)
            {
                var currChar        = scriptText[i];
                var separatorLength = 1;

                // this is either a legacy maCOs newline, or it will be followed by \n for the windows one
                if (currChar == '\r' || currChar == '\n')
                {
                    if (currChar == '\r' && i < scriptText.Length - 1 && scriptText[i + 1] == '\n')
                    {
                        // skip the next character since it's part of an \r\n sequence
                        i++;
                        separatorLength = 2;
                    }

                    var prevIndex     = 0;
                    var prevCount     = 0;
                    var prevSeparator = 0;

                    // if we're not still processing the first line, look at the prev line's starting index
                    if (result.Count > 1)
                    {
                        var rpev = result[result.Count - 2];
                        prevIndex     = rpev.StartingIndex;
                        prevCount     = rpev.LineText.Length;
                        prevSeparator = rpev.NewLineLength;
                    }

                    currentLine.LineText      = currentLineBuilder.ToString();
                    currentLine.StartingIndex = prevIndex + prevCount + prevSeparator;
                    currentLine.NewLineLength = separatorLength;
                    currentLine = new ScriptLine();
                    result.Add(currentLine);
                    currentLineBuilder.Clear();
                }
                else
                {
                    currentLineBuilder.Append(scriptText[i]);
                }
            }

            if (currentLine.LineText == null && currentLine.StartingIndex == 0)
            {
                result.Remove(currentLine);
            }

            return(result);
        }
Esempio n. 8
0
 public bool IsMyLine(ScriptLine line)
 {
     if (System.Array.IndexOf(MyParts, line.speaker) != -1)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 9
0
        public void Should_parse_script_line_template_with_path()
        {
            var scriptLine = new ScriptLine("scaffold\\controller.template => Controller.cs").Parse();

            scriptLine.TemplateFile.ShouldEqual("scaffold\\controller.template");
            scriptLine.TransformationFile.ShouldEqual("Controller.cs");
            scriptLine.ProjectFile.ShouldBeNull();
        }
Esempio n. 10
0
        public override void Read(ref List <ScriptLine> list, ref int start, ref int end, ref ScriptString function)
        {
            var wilds = new List <ScriptWild> {
                new ScriptWord(new ScriptString("if", Program.ScriptsFolder + "60302262020"))
            };

            end--;
            var  stack = new Stack <string>();
            bool expectingCondition   = true;
            bool expectingInstruction = false;

            while (++end < function.Length)
            {
                char chr = (char)function[end];

                // Skip whitespaces, since the parsing is done mostly done in the separate loops below.
                if (char.IsWhiteSpace(chr))
                {
                    continue;
                }

                if (expectingCondition)
                {
                    // <<Expecting Condition>>
                    if (chr == '(')
                    {
                        stack.Push("(\\)");
                    }
                    else
                    {
                        throw new Compiler.SyntaxException("Expected '(...)' after keyword 'if'.", Compiler.CurrentScriptTrace);
                    }
                    start = end;
                    // Find the end of the condition parenthesies.
                    while (++end < function.Length)
                    {
                        chr = (char)function[end];
                        if (ScriptLine.IsBlockCharStart(chr, out string block))
                        {
                            // Start a new block.
                            stack.Push(block);
                        }
                        else if (ScriptLine.IsBlockCharEnd(chr, out block))
                        {
                            // End the current block.
                            string b = stack.Pop();
                            if (block != b)
                            {
                                throw new Compiler.SyntaxException($"Expected '{b[2]}', but got '{block[2]}'.", Compiler.CurrentScriptTrace);
                            }
                            if (stack.Count == 0) /* <<End of Conditional>> */ break {
                                ;
                            }
                        }
                    }
                    // Get the full conditional as a string.
                    ScriptString s = function[start..(end + 1)];
Esempio n. 11
0
    public void StartGame()
    {
        _scriptManager.Reset();
        _scoreManager.Reset();
        _voiceProcessor.SetAfterSpeechCallback(AfterSpeechCallback);
        ScriptLine activeLine = _scriptManager.GetActiveLine();

        processCurrentLine();
    }
Esempio n. 12
0
 /// *******************************************************
 /// <summary>インターバルコマンド実行</summary>
 /// *******************************************************
 private void IntervalLine(ScriptLine line)
 {
     line.Attributes.ForEach(atr =>
     {
         switch (atr.Name)
         {
         case "delay": WaitTime = atr.IntValue; break;
         }
     });
 }
Esempio n. 13
0
        public void Should_parse_script_line_using_parameters_on_path_of_transformation_file()
        {
            var parameters = new Dictionary<string, string> { { "entity", "UserGroup" } };

            var scriptLine = new ScriptLine(
                "view_edit.template => Web/Views/${entity}/Edit.aspx", parameters)
                .Parse();

            scriptLine.TemplateFile.ShouldEqual("view_edit.template");
            scriptLine.TransformationFile.ShouldEqual("Web/Views/UserGroup/Edit.aspx");
            scriptLine.ProjectFile.ShouldBeNull();
        }
Esempio n. 14
0
        public void Should_parse_script_line_using_parameters_on_transformation_file()
        {
            var parameters = new Dictionary<string, string> { { "entity", "UserGroup" } };

            var scriptLine = new ScriptLine(
                "template1.template => ${entity}Controller.cs", parameters)
                .Parse();

            scriptLine.TemplateFile.ShouldEqual("template1.template");
            scriptLine.TransformationFile.ShouldEqual("UserGroupController.cs");
            scriptLine.ProjectFile.ShouldBeNull();
        }
Esempio n. 15
0
 private void GetLinesLeft(string character, out int left, out int total)
 {
     left  = 0;
     total = 0;
     for (ScriptLine scriptLine = m_lines.GetFirstLine(character); scriptLine != null; scriptLine = scriptLine.NextByCharacter)
     {
         ++total;
         if (!scriptLine.IsDone)
         {
             ++left;
         }
     }
 }
Esempio n. 16
0
    private void processCurrentLine()
    {
        ScriptLine activeLine = _scriptManager.GetActiveLine();

        if (_director.IsMyLine(activeLine))
        {
            NarrateLine(activeLine);
        }
        else
        {
            // player's turn to respond
        }
    }
Esempio n. 17
0
        /// *******************************************************
        /// <summary>コマンド実行</summary>
        /// *******************************************************
        private void PlayLine(EnemyControll character, ScriptLine line)
        {
            line.Attributes.ForEach(atr => {
                switch (atr.Name)
                {
                case "time": WaitTime = atr.FloatValue; break;

                case "tough": Manager.Character.ToughPoint = atr.FloatValue; break;

                default: Manager.OverrideParam(atr, false); break;
                }
            });
        }
Esempio n. 18
0
        /// *******************************************************
        /// <summary>タグ名検索+実行</summary>
        /// *******************************************************
        private bool FindRunScript(string keyword)
        {
            WaitTime = -1;
            ScriptLine script_line = Scripts.ScriptLine.Find(line => line.CommandName.CompareTo(keyword) == 0);

            if (script_line != null)
            {
                PlayLine(Manager.Character, script_line);
                return(true);
            }

            return(false);
        }
Esempio n. 19
0
    public void NarrateLine(ScriptLine line)
    {
        if (line == null)
        {
            Debug.Log("error reading active line");
            return;
        }
        string lineText = line.line;

        _scriptManager.MoveToNextLine();
        string toRead = lineText; //"<speak version=\"1.0\"><express-as type=\"GoodNews\">" + lineText + "</express-as></speak>";

        _scriptReader.ReadText(toRead, DoneReadingCallback);
    }
Esempio n. 20
0
        /// *******************************************************
        /// <summary>射撃アトリビュート解析</summary>
        /// *******************************************************
        private void ShotCommand(EnemyControll character, ScriptLine line)
        {
            Limit    = LIMIT_TYPE.TIME;
            WaitTime = 0;
            PastTime = 0;
            line.Attributes.ForEach(atr => {
                switch (atr.Name)
                {
                case "time": WaitTime = atr.IntValue; break;
                }
            });

            Shots.Add(new ShotScript(this, line));
        }
Esempio n. 21
0
 /// <summary>
 /// Construct the ScriptTalkLabel
 /// </summary>
 /// <param name="labelNum">label number between 0 and 9</param>
 /// <param name="initialLine">The initial line that will always be shown</param>
 /// <param name="defaultAnswers">Default answer if an expected response is not given</param>
 /// <param name="sqa">Script questions and answers</param>
 public ScriptTalkLabel(int labelNum, ScriptLine initialLine, List <ScriptLine> defaultAnswers, ScriptQuestionAnswers sqa)
 {
     QuestionAnswers = sqa;
     InitialLine     = initialLine;
     // if one is not provided, then one will be provided for you
     if (defaultAnswers == null)
     {
         DefaultAnswers = new List <ScriptLine>();
     }
     else
     {
         DefaultAnswers = DefaultAnswers;
     }
     LabelNum = labelNum;
 }
Esempio n. 22
0
        private IReadOnlyList <ScriptLine> LoadScriptReference <TLine>(string file) where TLine : ScriptLine
        {
            if (!File.Exists(file))
            {
                return(new List <ScriptLine>());
            }
            Func <string, ScriptLine> factory = line => new XSEScriptLine(line);

            if (typeof(TLine) == typeof(BSEScriptLine))
            {
                factory = line => new BSEScriptLine(line);
            }
            if (typeof(TLine) == typeof(ASEScriptLine))
            {
                factory = line => new ASEScriptLine(line);
            }

            var        lines       = File.ReadAllLines(file);
            var        scriptLines = new List <ScriptLine>();
            ScriptLine active      = null;

            foreach (var line in lines)
            {
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }
                if (!line.StartsWith(" ") && active != null)
                {
                    active = null;
                }
                if (line.StartsWith("#"))
                {
                    continue;
                }
                if (line.Trim().StartsWith("#") && active != null)
                {
                    active.AddDocumentation(line.Trim());
                }
                else
                {
                    active = factory(line);
                    scriptLines.Add(active);
                }
            }

            return(scriptLines.ToArray());
        }
Esempio n. 23
0
        private void GetLinesLeft(string character, int episode, out int left, out int total)
        {
            ExcelScript excelScript = new ExcelScript();

            excelScript.Load(m_path, episode);
            left  = 0;
            total = 0;
            for (ScriptLine scriptLine = excelScript.Lines.GetFirstLine(character); scriptLine != null; scriptLine = scriptLine.NextByCharacter)
            {
                ++total;
                if (!scriptLine.IsDone)
                {
                    ++left;
                }
            }
        }
Esempio n. 24
0
    // Update is called once per frame
    protected virtual void Update()
    {
        if (currentCutscene != null)
        {
            if (inMovement)
            {
                characterMoving();
            }
            else if (inDialogue)
            {
                if (dialogueController.CompletedTalkingPoint && keyChecker.useKey(KeyCode.E))
                {
                    inDialogue = false;
                    dialogueController.endCurrentDialogue();
                }
            }
            else if (inAction)
            {
            }
            else
            {
                ScriptLine nextLine = (ScriptLine)currentScript [scriptRunner];
                scriptRunner++;

                if (nextLine.Action == "Talk")
                {
                    inDialogue = true;
                    characterTalking(nextLine);
                }
                else if (nextLine.Action == "Move")
                {
                    currentActor = GameObject.Find(nextLine.Character);
                    dialogueController.endCutsceneDialogue();
                    newLocation = nextLine.NewLocation;
                    characterMoving();
                    inMovement = true;
                }
                else if (nextLine.Action == "End")
                {
                    endCutscene();
                }
                else
                {
                }
            }
        }
    }
Esempio n. 25
0
    public static List <ScriptLine> CreateDialogueComponents(string text)
    {
        if (!initialized)
        {
            throw new Exception("InitializeGenerators not yet called");
        }

        List <string> rawLines = new List <string>(text.Split('\n'));

        rawLines = rawLines.Select(x => x.Trim()).ToList();
        rawLines = rawLines.Where(x => x != "").ToList();

        List <ScriptLine> processedLines = new List <ScriptLine>();

        string currentSpeaker     = "";
        int    speakingLineNumber = 0;

        for (int i = 0; i < rawLines.Count; i++)
        {
            ScriptLine processedLine = null;

            string line = rawLines[i];
            switch (GetLineType(line))
            {
            case LineType.SpeakingLine:
                string speaker = GetSpeaker(line);
                if (speaker != "")
                {
                    currentSpeaker = speaker;
                }
                else if (currentSpeaker == "")
                {
                    Debug.LogWarning("Speaker not specified");
                }
                processedLine = GenerateSpeakingLine(currentSpeaker, GetSpokenLine(line), speakingLineNumber);
                speakingLineNumber++;
                break;

            case LineType.Instruction:
                processedLine = GenerateInstructionLine(line);
                break;
            }
            processedLines.Add(processedLine);
        }

        return(processedLines);
    }
Esempio n. 26
0
        public void DoScript(int animIdx, int keyFrameIdx)
        {
            CharacterDefinition charDef   = character.GetCharDef();
            Animation           animation = charDef.GetAnimation(animIdx);
            KeyFrame            keyFrame  = animation.GetKeyFrame(keyFrameIdx);

            bool done = false;

            for (int i = 0; i < keyFrame.GetScriptArray().Length; i++)
            {
                if (done)
                {
                    break;
                }
                else
                {
                    ScriptLine line = keyFrame.GetScript(i);
                    if (line != null)
                    {
                        switch (line.GetCommand())
                        {
                        case Commands.SetAnim:
                            character.SetAnim(line.GetSParam());
                            break;

                        case Commands.Goto:
                            character.SetFrame(line.GetIParam());
                            done = true;
                            break;

                        case Commands.PlaySound:
                            SoundManager.PlaySound(line.GetSParam(), false);
                            break;

                        case Commands.IfDyingGoto:

                            break;

                        case Commands.KillMe:

                            break;
                        }
                    }
                }
            }
        }
Esempio n. 27
0
        public bool AnalyzeLine(string str)
        {
            ScriptLine line = new ScriptLine(str);
            string     word = new string(new char[STR_MAXLEN]);

            line.Skip(" \t");
            if (!line.GetWord(ref word, " \t(=+-*/["))
            {
                return(true);
            }

            TokenInfo tokenInfo;

            if (!m_tokenMap.Get(word, out tokenInfo))
            {
                Error("AnalyzeLine - [{0}] is not a tokenMap", word);
                return(false);
            }

            if (tokenInfo.type == TOKENTYPE.TOKENTYPE_COMMAND)
            {
                if (!OnControl(line, tokenInfo.num))
                {
                    return(false);
                }
            }

            Parsing Parse = new Parsing();

            if (!Parse.Run(line.GetBase(), "$"))
            {
                Error("(,) error type AnalyzeLine 1");
                return(false);
            }

            for (int i = 0; i < Parse.GetNum(); i++)
            {
                var p = Parse.Get(i);
                if (!AnalyzeParse(ref p))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 28
0
        public bool AnalyzeParse(ref string str)
        {
            ScriptLine line = new ScriptLine(str);
            string     word = new string(new char[STR_MAXLEN]);

            line.Skip(" \t");
            if (!line.GetWord(ref word, " \t(=+-*/%["))
            {
                return(true);
            }

            TokenInfo tokenInfo = new TokenInfo();

            if (!m_tokenMap.Get(word, out tokenInfo))
            {
                if (word[0] != '$')
                {
                    Error("AnalyzeParse - 1:[%s] is not in a tokenMap", word);
                    return(false);
                }

                m_tokenMap.Set(word, TOKENTYPE.TOKENTYPE_VAR);
                if (!m_tokenMap.Get(word, out tokenInfo))
                {
                    Error("AnalyzeParse - 2:[%s] is not in a tokenMap", word);
                    return(false);
                }
            }

            switch (tokenInfo.type)
            {
            case TOKENTYPE.TOKENTYPE_COMMAND:
                return(OnCommand(line, (CMD)tokenInfo.num));

            case TOKENTYPE.TOKENTYPE_FUNC:
                return(OnFunc(line, tokenInfo.num, tokenInfo.str));

            case TOKENTYPE.TOKENTYPE_VAR:
                return(OnVar(line, word));
            }

            Error("[%s] token type not found", word, tokenInfo.type);
            return(false);
        }
Esempio n. 29
0
 public void AddScript(string script)
 {
     StringReader reader = new StringReader(script);
     for (string str = reader.ReadLine(); str != null; str = reader.ReadLine())
     {
         ScriptLine line = new ScriptLine(str);
         int padding = line.Padding;
         if (padding < this._minPadding)
         {
             this._minPadding = padding;
         }
         this._length += line.Length + 2;
         if (this._lines == null)
         {
             this._lines = new ArrayList();
         }
         this._lines.Add(line);
     }
 }
Esempio n. 30
0
        public void Save(string path)
        {
            Color     color    = Color.FromArgb(204, byte.MaxValue, 204);
            IWorkbook workbook = Factory.GetWorkbook(path);

            UpdateTotals(workbook.Worksheets[0]);
            IWorksheet worksheet      = workbook.Worksheets[m_episodeNo];
            int        scriptStartRow = ScriptStartRow;

            worksheet.Cells[scriptStartRow, CharacterColumn, worksheet.UsedRange.RowCount - 1, CheckboxColumn].Clear();
            worksheet.Cells[scriptStartRow, CharacterColumn, worksheet.UsedRange.RowCount - 1, CheckboxColumn].Rows.AutoFit();
            for (ScriptLine scriptLine = m_lines.GetFirstLine(); scriptLine != null; scriptLine = scriptLine.NextByTime)
            {
                IRange cell1 = worksheet.Cells[scriptStartRow, CharacterColumn];
                IRange cell2 = worksheet.Cells[scriptStartRow, TimeColumn];
                IRange cell3 = worksheet.Cells[scriptStartRow, LineColumn];
                IRange cell4 = worksheet.Cells[scriptStartRow, CheckboxColumn];
                worksheet.Cells[scriptStartRow, CharacterColumn, scriptStartRow, CheckboxColumn].VerticalAlignment = VAlign.Top;
                cell1.MergeArea.MergeCells = false;
                cell2.MergeArea.MergeCells = false;
                cell3.MergeArea.MergeCells = false;
                cell4.MergeArea.MergeCells = false;
                cell3.WrapText             = true;
                cell1.Value = scriptLine.Character;
                cell2.Value = scriptLine.Offset.ToString();
                cell3.Value = scriptLine.Line;
                IRange cell5 = worksheet.Cells[scriptStartRow, CharacterColumn, scriptStartRow, LineColumn];
                if (scriptLine.IsDone)
                {
                    cell5.Interior.Color = color;
                    cell4.Value          = "ü";
                    cell4.Font.Name      = "Wingdings";
                }
                else
                {
                    cell5.Interior.ColorIndex = -2;
                }
                scriptStartRow += LineSpacing;
            }
            workbook.Save();
            workbook.Close();
        }
Esempio n. 31
0
        public void AddScript(string script)
        {
            StringReader stringReader = new StringReader(script);

            for (string str = stringReader.ReadLine(); str != null; str = stringReader.ReadLine())
            {
                ScriptLine scriptLine = new ScriptLine(str);
                int        i          = scriptLine.Padding;
                if (i < _minPadding)
                {
                    _minPadding = i;
                }
                _length += scriptLine.Length + 2;
                if (_lines == null)
                {
                    _lines = new ArrayList();
                }
                _lines.Add(scriptLine);
            }
        }
Esempio n. 32
0
        /// *******************************************************
        /// <summary>コマンド実行</summary>
        /// *******************************************************
        private void SpawnLine(ScriptLine line)
        {
            string source = null;
            string key    = null;
            float  spd    = 0;
            float  dir    = 0;

            line.Attributes.ForEach(atr =>
            {
                switch (atr.Name)
                {
                case "source": source = atr.StringValue; break;

                case "key": key = atr.StringValue; break;

                case "spd": spd = atr.FloatValue; break;

                case "dir": dir = atr.FloatValue; break;
                }
            });
            if (string.IsNullOrEmpty(source) == false)
            {
                //Debug.Log("Spawn:" + source + " / " + key);

                GameObject       spawner       = StageManager.Instance.InstantiateObject(source);
                EnemyControll    self_ctrl     = spawner.GetComponent <EnemyControll>();
                FortressControll fortress_ctrl = spawner.GetComponent <FortressControll>();

                if (self_ctrl != null)
                {
                    self_ctrl.SpawnKey = key;
                }
                if (fortress_ctrl != null)
                {
                    fortress_ctrl.MoveSpeed         = spd / 100f;
                    fortress_ctrl.FortressDirection = dir;
                }

                spawner.SetActive(true);
            }
        }
        private void LoadWindow(Window editor, ScriptLine line)
        {
            var script = this.DataContext as Script;

            if (script != null)
            {
                script.AddBeforeSelected(line);
                editor.DataContext = line;
                editor.ShowDialog();
                if (editor.DialogResult == true)
                {
                    invalidate = true;
                    newItem    = line;
                    this.Close();
                }
                else
                {
                    script.ScriptLines.Remove(line);
                }
            }
        }
Esempio n. 34
0
    public void AfterSpeechCallback(string text, double confidence)
    {
        ScriptLine activeLine = _scriptManager.GetActiveLine();

        if (_director.IsMyLine(activeLine))
        {
            // the user just uttered something again before the director spoke,
            // but not their turn, just ignore
            return;
        }
        ResponseAccuracyStats stats = _responseChecker.CheckResponse(text);
        int lineNum = _scriptManager.GetActiveLineNumber();

        _scoreManager.UpdateStats(lineNum, stats);
        Debug.Log("numCorrect: " + stats.NumWordsCorrect + " numExpected: " + stats.NumWordsExpected);
        Debug.Log("Overall Score: " + _scoreManager.GetOverallScore());
        _scriptManager.MoveToNextLine();
        if (_scriptManager.HasMoreLines())
        {
            processCurrentLine();
        }
    }
		/// <summary>
		/// Create a statement
		/// parts;
		/// </summary>
		/// <param name="parts"></param>
		public JsStatement(params object[] parts)  
		{
			Line = new ScriptLine(parts);
		}
Esempio n. 36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScriptLineEventArgs"/> class.
 /// </summary>
 /// <param name="line">The line.</param>
 public ScriptLineEventArgs(ScriptLine line)
 {
     this.Line = line;
 }
Esempio n. 37
0
        public void Should_parse_script_line_with_csproj()
        {
            var parameters = new Dictionary<string, string> { { "entity", "UserGroup" } };

            var scriptLine = new ScriptLine(
                "view_edit.template => Web/Views/${entity}/Edit.aspx @ csproj.xml", parameters)
                .Parse();

            scriptLine.TemplateFile.ShouldEqual("view_edit.template");
            scriptLine.TransformationFile.ShouldEqual("Web/Views/UserGroup/Edit.aspx");
            scriptLine.ProjectFile.ShouldEqual("csproj.xml");
        }
Esempio n. 38
0
        /// <summary>
        /// Parses the row.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <returns></returns>
        public ScriptLine ParseRow(Row row, ScriptFile file)
        {
            try {
                var lastindex = LastValidWord(row);
                var words = row.ToList().Where(w => w.Index < lastindex).ToList();

                //Primary Validation
                if (words.Count == 0) { return new ScriptLine(null, row.Index, row.Text, file); }
                if (words.First().Text.StartsWith("/")) { return new ScriptLine(null, row.Index, row.Text, file); }
                if (IsEmptyRow(row)) { return new ScriptLine(null, row.Index, row.Text, file); }
                if (row.Text.StartsWith("#endsection")) { return new ScriptLine(null, row.Index, row.Text, file); }

                //Section Validation
                if (row.Text.StartsWith("#section")) {
                    var sectionName = row.Text.Replace("#section", "").TrimStart(' ').TrimEnd(' ');
                    if (!ScriptSections.Contains(sectionName)) {
                        ScriptSections.Add(sectionName);
                        return new ScriptLine(null, row.Index, row.Text, file);
                    }
                    else { SetError(row, "Duplicated section name."); return null; }
                }

                //Syntax Validation
                if (words.Count < 3) { SetError(row, "Invalid expression."); return null; }
                if (words[1].Text != "(") { SetError(row, "Invalid expression."); return null; }
                if (words.Last().Text != ")") { SetError(row, "Invalid expression."); return null; }

                //Brackets Validation.
                if (CountChars(row.Text, '(') != CountChars(row.Text, ')')) { SetError(row, "You forgot to use the char ')' to close a function. Or otherwise used unnecessarily."); return null; }
                if (CountChars(row.Text, '[') != CountChars(row.Text, ']')) { SetError(row, "You forgot to use the char ']' to close a player property. Or otherwise used unnecessarily."); return null; }
                if (CountChars(row.Text, '{') != CountChars(row.Text, '}')) { SetError(row, "You forgot to use the char '}' to close a custom item. Or otherwise used unnecessarily."); return null; }
                if (CountChars(row.Text, '\"') % 2 != 0) { SetError(row, "You forgot to use the char '\"' to close a text expression. Or otherwise used unnecessarily."); return null; }

                //Null argument validation.
                if (row.Text.IndexOf("((") > -1) { SetError(row, "Invalid expression '(('."); return null; }
                if (row.Text.IndexOf("[[") > -1) { SetError(row, "Invalid expression '[['."); return null; }
                if (row.Text.IndexOf("{{") > -1) { SetError(row, "Invalid expression '{{'."); return null; }
                if (row.Text.IndexOf("[]") > -1) { SetError(row, "Invalid expression '[['."); return null; }
                if (row.Text.IndexOf("{}") > -1) { SetError(row, "Invalid expression '{{'."); return null; }
                if (row.Text.IndexOf(",,") > -1) { SetError(row, "Invalid expression ',,'."); return null; }

                //Function Validation
                if (ScriptActions.ContainsKey(words.First().Text)) {
                    var action = ScriptActions[words.First().Text];
                    var actionline = new ScriptLine(action, row.Index, row.Text, file);
                    var args = RemoveArgumentSpaces(GetFunctionArgument(row.Text).Split(new[] { ',' }));

                    //Argument Validation.
                    if ((action.Params == null || action.Params.Length > 0) && args.Length > 0) {
                        if (args.Length == 0) { SetError(row, "This function does not require arguments."); return null; }
                    }
                    if (action.Params != null && action.Params.Length > 0) {
                        if (args.Length == 0) { SetError(row, "This function requires one or more arguments."); return null; }
                        if (args.Length != action.Params.Length) { SetError(row, "Invalid number of arguments."); return null; }
                        actionline.Args = new string[args.Length];
                        for (int i = 0; i < args.Length; i++) {

                            #region "[rgn] String Argument Valdation "
                            if (action.Params[i].NeedQuotes && args[i].Contains("+")) {
                                var subparams = args[i].Split(new[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
                                foreach (var sp in subparams) {
                                    if (sp.StartsWith("getparam")) {
                                        var spargs = GetFunctionArguments(sp);
                                        if (spargs.Length != 2) {
                                            SetError(row, "Invalid number of arguments to funcion getparam.");
                                            return null;
                                        }
                                        if (!GetParams.ContainsKey(spargs[0])) { GetParams.Add(spargs[0], row); }
                                    }
                                }
                            }
                            else if (!args[i].StartsWith("\"") && action.Params[i].NeedQuotes) {
                                if (!args[i].StartsWith("getparam") && !args[i].StartsWith("getvalue")) {
                                    SetError(row, string.Format("The argument \"{0}\" of this function must be inside quotes. Ex. \"...\"", i.ToString()));
                                    return null;
                                }
                            }
                            actionline.Args[i] = args[i];
                            #endregion
                        }
                    }

                    //Waypoint Validation.
                    if (actionline.FunctionText.ToLower() == "goto") {
                        var wp = new LocationKeyword();
                        if (wp.Parse(GetFunctionArgument(row.Text))) {
                            ScriptWayPoints.Add(row, wp);
                        }
                        else { SetError(row, "Invalid waypoint declaration."); }
                    }

                    //Parameter Validation
                    if (actionline.FunctionText.ToLower() == "setparam") {
                        var paramkey = actionline.Args[0].ToString().TrimStart(new[] { '"' }).TrimEnd(new[] { '"' });
                        var paramvalue = actionline.Args[1].ToString().TrimStart(new[] { '"' }).TrimEnd(new[] { '"' });
                        if (!ScriptParams.ContainsKey(paramkey)) { ScriptParams.Add(paramkey, paramvalue); }
                    }
                    foreach (var word in words) {
                        if (word.Text == "getparam") {
                            if (!ScriptParams.ContainsKey(row[word.Index + 3].Text)) {
                                SetError(row[word.Index + 3], string.Format("The parameter \"{0}\" was not found. You must call setparam(\"{0}\", value) before use it.", row[word.Index + 3].Text));
                                return null;
                            }
                            else { if (!GetParams.ContainsKey(row[word.Index + 3].Text)) { GetParams.Add(row[word.Index + 3].Text, row); } }
                        }
                        else if (word.Text == "gotoline") {
                            if (row[word.Index + 2].Text.ToInt32() >= Document.Lines.Length) {
                                SetError(word, string.Format("This script does not have the line \"{0}\".", row[word.Index + 2].Text));
                                return null;
                            }
                        }
                        else if (word.Text == "gotosection") {
                            if (!row.Document.Text.Contains(string.Format("#section {0}", row[word.Index + 2].Text))) {
                                SetError(row[word.Index + 2], string.Format("This script does not contains a section named \"{0}\".", row[word.Index + 2].Text));
                                return null;
                            }
                        }
                        else if (word.Text == "[") {
                            if (PlayerProperties.FindByInputText(row[word.Index + 1].Text.Trim().ToUpper()) == null) {
                                SetError(row[word.Index + 1], string.Format("The player property \"{0}\" does not exist.", row[word.Index + 1].Text));
                                return null;
                            }
                        }
                        else if (word.Text == "{") {
                            if (CustomItems.FindByInputText(row[word.Index + 1].Text.Trim().ToUpper()) == null) {
                                SetError(row[word.Index + 1], string.Format("The custom item \"{0}\" does not exist.", row[word.Index + 1].Text));
                                return null;
                            }
                        }
                    }
                    return actionline;
                }
                SetError(words.First(), string.Format("The function \"{0}\" does not exist.", words.First().Text)); return null;
            }
            catch (Exception ex) {
                SetWarning(row, string.Format("Could not parse the row number \"{0}\"", row.Index + 1));
                SetError(row, string.Format("Details: {0}", ex.Message));
                return null;
            }
        }
		/// <summary>
		/// Create a statement
		/// parts;
		/// </summary>
		/// <param name="layout"></param>
		/// <param name="parts"></param>
		public JsStatement(ScriptLayout layout, params object[] parts)
			: base(layout)
		{
			Line = new ScriptLine(parts);
		}
		/// <summary>
		/// Create an empty statement
		/// ;
		/// </summary>
		public JsStatement() 
		{
			Line = new ScriptLine();
		}
		/// <summary>
		/// Create a statement
		/// line;
		/// </summary>
		/// <param name="layout"></param>
		/// <param name="line"></param>
		public JsStatement(ScriptLayout layout, ScriptLine line)
			: base(layout)
		{
			Line = line;
		}
		/// <summary>
		/// Create a statement
		/// parts;
		/// </summary>
		/// <param name="parts"></param>
        public JsStatement(IEnumerable<object> parts) 
		{
			Line = new ScriptLine(parts);
		}
		/// <summary>
		/// Create a statement
		/// line;
		/// </summary>
		/// <param name="line"></param>
		public JsStatement(ScriptLine line)
		{
			Line = line;
		}
Esempio n. 44
0
 public Text(Parser.Text pObj, int pageno, bool ix2)
 {
     pageId = pageno;
     x2 = ix2;
     title = pObj.title;
     promptType = pObj.promptType;
     altText = pObj.altText;
     if(pObj.narr != null)
         narr = new ScriptLine(pObj.narr);
     if (pObj.lines != null)
     {
         lines = new List<ScriptLine>();
         foreach (var l in pObj.lines)
             lines.Add(new ScriptLine(l));
     }
 }
		/// <summary>
		/// Create an empty statement
		/// ;
		/// </summary>
		/// <param name="layout"></param>
		public JsStatement(ScriptLayout layout)
			: base(layout)
		{
			Line = new ScriptLine();
		}
		/// <summary>
		/// Create a statement
		/// parts;
		/// </summary>
		/// <param name="layout"></param>
		/// <param name="parts"></param>
		public JsStatement(ScriptLayout layout, IEnumerable<object> parts)
			: base(layout)
		{
			Line = new ScriptLine(parts);
		}