示例#1
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "Opl")
                {
                    this.m_opl = AgentMeta.ParseProperty(p.value);
                }
                else if (p.name == "Opr")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_opr = AgentMeta.ParseProperty(p.value);
                    }
                    else
                    {
                        this.m_opr = AgentMeta.ParseMethod(p.value);
                    }
                }
            }
        }
示例#2
0
            public override void Load(string instance, string[] paramStrs)
            {
                Debug.Check(paramStrs.Length == 1);

                _instance = instance;
                _value    = (CInstanceMember <string>)AgentMeta.ParseProperty <string>(paramStrs[0]);
            }
示例#3
0
            public override void Load(string instance, string[] paramStrs)
            {
                Debug.Check(paramStrs.Length == 1);

                _instance        = instance;
                _retreatPosition = AgentMeta.ParseProperty <bVector3>(paramStrs[0]);
            }
示例#4
0
            public override void Load(string instance, string[] paramStrs)
            {
                Debug.Check(paramStrs.Length == 1);

                _instance    = instance;
                _enemyTarget = AgentMeta.ParseProperty <FightAgent>(paramStrs[0]);
            }
示例#5
0
            public override void Load(string instance, string[] paramStrs)
            {
                Debug.Check(paramStrs.Length == 1);

                _instance = instance;
                _param0   = (CInstanceMember <UnityEngine.Vector3>)AgentMeta.ParseProperty <UnityEngine.Vector3>(paramStrs[0]);
            }
            public override void Load(string instance, string[] paramStrs)
            {
                Debug.Check(paramStrs.Length == 1);

                _instance = instance;
                _param0   = AgentMeta.ParseProperty <IList>(paramStrs[0]);
            }
示例#7
0
            public override void Load(string instance, string[] paramStrs)
            {
                Debug.Check(paramStrs.Length == 2);

                _instance = instance;
                _param0   = (CInstanceMember <float>)AgentMeta.ParseProperty <float>(paramStrs[0]);
                _param1   = (CInstanceMember <int>)AgentMeta.ParseProperty <int>(paramStrs[1]);
            }
示例#8
0
            public override void Load(string instance, string[] paramStrs)
            {
                Debug.Check(paramStrs.Length == 2);

                _instance = instance;
                _param0   = AgentMeta.ParseProperty <GameActor>(paramStrs[0]);
                _param1   = (CInstanceMember <eMapDirection>)AgentMeta.ParseProperty <eMapDirection>(paramStrs[1]);
            }
示例#9
0
            public override void Load(string instance, string[] paramStrs)
            {
                Debug.Check(paramStrs.Length == 2);

                _instance = instance;
                _param0   = AgentMeta.ParseProperty <IList>(paramStrs[0]);
                _param1   = (CInstanceMember <System.Object>)AgentMeta.ParseProperty <System.Object>(paramStrs[1]);
            }
示例#10
0
            public CInstanceConst_FirstStruct(string typeName, string valueStr) : base(typeName, valueStr)
            {
                List <string> paramStrs = behaviac.StringUtils.SplitTokensForStruct(valueStr);

                Debug.Check(paramStrs != null && paramStrs.Count == 2);

                _s1 = (CInstanceMember <int>)AgentMeta.ParseProperty <int>(paramStrs[0]);
                _s2 = (CInstanceMember <float>)AgentMeta.ParseProperty <float>(paramStrs[1]);
            }
示例#11
0
            public override void Load(string instance, string[] paramStrs)
            {
                Debug.Check(paramStrs.Length == 4);

                _instance = instance;
                _param0   = (CInstanceMember <string>)AgentMeta.ParseProperty <string>(paramStrs[0]);
                _param1   = AgentMeta.ParseProperty <UnityEngine.Transform>(paramStrs[1]);
                _param2   = (CInstanceMember <UnityEngine.Vector3>)AgentMeta.ParseProperty <UnityEngine.Vector3>(paramStrs[2]);
                _param3   = (CInstanceMember <float>)AgentMeta.ParseProperty <float>(paramStrs[3]);
            }
示例#12
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "Count")
                {
                    this.m_count = AgentMeta.ParseProperty(p.value);
                }
            }
        }
示例#13
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];

                if (p.name == "ReferenceBehavior")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_referencedBehaviorPath = AgentMeta.ParseProperty(p.value);
                    }
                    else
                    {
                        this.m_referencedBehaviorPath = AgentMeta.ParseMethod(p.value);
                    }

                    string szTreePath = this.GetReferencedTree(null);

                    //conservatively make it true
                    bool bHasEvents = true;

                    if (!string.IsNullOrEmpty(szTreePath))
                    {
                        if (Config.PreloadBehaviors)
                        {
                            BehaviorTree behaviorTree = Workspace.Instance.LoadBehaviorTree(szTreePath);
                            Debug.Check(behaviorTree != null);

                            if (behaviorTree != null)
                            {
                                bHasEvents = behaviorTree.HasEvents();
                            }
                        }

                        this.m_bHasEvents |= bHasEvents;
                    }
                }
                else if (p.name == "Task")
                {
                    this.m_taskMethod = AgentMeta.ParseMethod(p.value);
                }
            }
        }
示例#14
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];

                if (p.name == "Opl")
                {
                    this.m_opl = AgentMeta.ParseProperty(p.value);
                }
                else if (p.name == "Operator")
                {
                    Debug.Check(p.value == "Add" || p.value == "Sub" || p.value == "Mul" || p.value == "Div");

                    this.m_operator = OperationUtils.ParseOperatorType(p.value);
                }
                else if (p.name == "Opr1")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_opr1 = AgentMeta.ParseProperty(p.value);
                    }
                    else
                    {
                        this.m_opr1 = AgentMeta.ParseMethod(p.value);
                    }
                }
                else if (p.name == "Opr2")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_opr2 = AgentMeta.ParseProperty(p.value);
                    }
                    else
                    {
                        this.m_opr2 = AgentMeta.ParseMethod(p.value);
                    }
                }
            }
        }
示例#15
0
        public static object FromString(Type type, string valStr, bool bStrIsArrayType /*= false*/)
        {
            if (!string.IsNullOrEmpty(valStr) && valStr == "null")
            {
                Debug.Check(Utils.IsRefNullType(type));
                return(null);
            }

            if (type.IsByRef)
            {
                type = type.GetElementType();
            }

            bool bIsArrayType = Utils.IsArrayType(type);

            object v = null;

            //customized type, struct or enum
            if (bStrIsArrayType || bIsArrayType)
            {
                if (bIsArrayType)
                {
                    Type elemType = type.GetGenericArguments()[0];
                    v = StringUtils.FromStringVector(elemType, valStr);
                }
                else
                {
                    v = StringUtils.FromStringVector(type, valStr);
                }
            }
            else if (type == typeof(behaviac.IProperty))
            {
                v = AgentMeta.ParseProperty(valStr);
            }
            else if (Utils.IsCustomClassType(type))
            {
                v = StringUtils.FromStringStruct(type, valStr);
            }
            else
            {
                v = Utils.FromStringPrimitive(type, valStr);
            }

            return(v);
        }
示例#16
0
            public virtual bool load(List <property_t> properties)
            {
                for (int i = 0; i < properties.Count; ++i)
                {
                    property_t p = properties[i];
                    if (p.name == "Mode")
                    {
                        switch (p.value)
                        {
                        case "Condition":
                            this.m_mode = TransitionMode.Condition;
                            break;

                        case "Success":
                            this.m_mode = TransitionMode.Success;
                            break;

                        case "Failure":
                            this.m_mode = TransitionMode.Failure;
                            break;

                        case "End":
                            this.m_mode = TransitionMode.End;
                            break;
                        }
                    }
                    else if (p.name == "Opl")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opl = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opl = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Opr1")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opr1 = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opr1 = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Operator")
                    {
                        this.m_operator = OperationUtils.ParseOperatorType(p.value);
                    }
                    else if (p.name == "Opr2")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opr2 = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opr2 = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                }

                return(this.m_opl != null);
            }
示例#17
0
            public virtual bool load(List <property_t> properties)
            {
                for (int i = 0; i < properties.Count; ++i)
                {
                    property_t p = properties[i];

                    if (p.name == "Opl")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opl = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opl = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Opr1")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opr1 = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opr1 = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Operator")
                    {
                        this.m_operator = OperationUtils.ParseOperatorType(p.value);
                    }
                    else if (p.name == "Opr2")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opr2 = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opr2 = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                }

                return(this.m_opl != null);
            }
示例#18
0
        public static bool ParseForStruct(Type type, string str, ref string strT, Dictionary <string, IInstanceMember> props)
        {
            int pB = 0;
            int i  = 0;

            while (i < str.Length)
            {
                char c = str[i];

                if (c == ';' || c == '{' || c == '}')
                {
                    int p = pB;

                    while (p <= i)
                    {
                        strT += str[p++];
                    }

                    pB = i + 1;
                }
                else if (c == ' ')
                {
                    //par or property
                    string propName = "";
                    int    p        = pB;

                    while (str[p] != '=')
                    {
                        propName += str[p++];
                    }

                    //skip '='
                    Debug.Check(str[p] == '=');
                    p++;

                    string valueStr = str.Substring(p);

                    string typeStr = "";

                    while (str[p] != ' ')
                    {
                        typeStr += str[p++];
                    }

                    //bool bStatic = false;

                    if (typeStr == "static")
                    {
                        //skip ' '
                        Debug.Check(str[p] == ' ');
                        p++;

                        while (str[p] != ' ')
                        {
                            typeStr += str[p++];
                        }

                        //bStatic = true;
                    }

                    string parName = "";

                    //skip ' '
                    Debug.Check(str[i] == ' ');
                    i++;

                    while (str[i] != ';')
                    {
                        parName += str[i++];
                    }

                    props[propName] = AgentMeta.ParseProperty(valueStr);

                    //skip ';'
                    Debug.Check(str[i] == ';');

                    pB = i + 1;
                }

                i++;
            }

            return(true);
        }