private static BTLTokenizer.Token GenerateCommentToken(string lineContent, int lineNumber)
        {
            var token = new BTLTokenizer.Token(BTLTokenizer.TokenType.Comment, 0, lineContent.Length, lineContent, 0);

            token.line = lineNumber;
            return(token);
        }
        public static object ParseParameter(BTLTokenizer.Token token)
        {
            object o = null;

            o = token.parsedParameter;
            return(o);
        }
Esempio n. 3
0
        bool IsLabel(BTLTokenizer.Token token)
        {
            bool itIs = false;

            switch (token.type)
            {
            case BTLTokenizer.TokenType.Comment:
            case BTLTokenizer.TokenType.Fallback:
            case BTLTokenizer.TokenType.Mute:
            case BTLTokenizer.TokenType.Not:
            case BTLTokenizer.TokenType.Parallel:
            case BTLTokenizer.TokenType.Sequence:
            case BTLTokenizer.TokenType.Race:
            case BTLTokenizer.TokenType.Random:
            case BTLTokenizer.TokenType.Tree:
            case BTLTokenizer.TokenType.Repeat:
            case BTLTokenizer.TokenType.While:
                itIs = true;
                break;

            case BTLTokenizer.TokenType.Word:
                itIs = token.valueType == BTLTokenizer.TokenValueType.None;
                break;
            }
            return(itIs);
        }
Esempio n. 4
0
        public GUINodeParameter(BTLTokenizer.Token token)
        {
            var v = BTLTokenizer.ParseParameter(token);

            value = token.content;

            _type = v.GetType();
        }
        private void GUI_token(GUIStyle style, BTNode node, BTLTokenizer.Token token)
        {
            var label = token.content.Replace("\t", "   ");

            if (clickedTask != null && clickedTaskFade < Time.realtimeSinceStartup)
            {
                clickedTask = null;
            }


#if UNITY_EDITOR
            var task = node as BTTask;

            if (task != null && task.boundState != BoundState.Bound)
            {
                style = BTLSyntaxHighlight.style_failed;
            }

            if (task != null && task.boundState == BoundState.Bound && token.type == BTLTokenizer.TokenType.Word)
            {
                if (GUILayout.Button(label, style) && Event.current.button == 0)
                {
                    if (clickedTask == task)
                    {
                        GUIBTScript.OpenScript(task.boundObject as MonoBehaviour, task.boundMember);
                    }

                    clickedTask     = task;
                    clickedTaskFade = Time.realtimeSinceStartup + 0.5f;
                }
            }
            else
            {
                GUILayout.Label(label, style);
            }
#else
            GUILayout.Label(label, style);
#endif
        }
        public static GUIStyle GetTokenStyle(BTLTokenizer.Token token)
        {
            var style = style_label;

            switch (token.type)
            {
            case BTLTokenizer.TokenType.Comment: style = style_comment; break;

            case BTLTokenizer.TokenType.Sequence: style = style_keyword; break;

            case BTLTokenizer.TokenType.Fallback: style = style_keyword; break;

            case BTLTokenizer.TokenType.While: style = style_keyword; break;

            case BTLTokenizer.TokenType.Repeat: style = style_keyword; break;

            case BTLTokenizer.TokenType.Tree: style = style_keyword; break;

            case BTLTokenizer.TokenType.Random: style = style_keyword; break;

            case BTLTokenizer.TokenType.TreeProxy: style = style_keyword; break;

            case BTLTokenizer.TokenType.Mute: style = style_keyword; break;

            case BTLTokenizer.TokenType.Parallel: style = style_keyword; break;

            case BTLTokenizer.TokenType.Not: style = style_keyword; break;

            case BTLTokenizer.TokenType.Race: style = style_keyword; break;

            case BTLTokenizer.TokenType.Value: style = style_value; break;

            case BTLTokenizer.TokenType.Word: style = style_task; break;
            }

            return(style);
        }