示例#1
0
            public override void Load(string instance, string[] paramStrs)
            {
                Debug.Check(paramStrs.Length == 1);

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

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

                _instance = instance;
                _param0   = AgentMeta.ParseProperty <IList>(paramStrs[0]);
            }
示例#5
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]);
            }
示例#6
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]);
            }
示例#7
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]);
            }
示例#8
0
            public override IValue GetIValue(Agent self, IInstanceMember firstParam)
            {
                Agent agent = Utils.GetParentAgent(self, _instance);

                FightAgent result = ((CInstanceMember <FightAgent>)firstParam).GetValue(self);

                _returnValue.value = ((SoilderAgent)agent).MoveToTarget(result);
                return(_returnValue);
            }
示例#9
0
            public override IValue GetIValue(Agent self, IInstanceMember firstParam)
            {
                Agent agent = Utils.GetParentAgent(self, _instance);

                FightAgent result = ((CInstanceMember <FightAgent>)firstParam).GetValue(self);

                _returnValue.value = ((HeroAgent)agent).LootTreasure(result);
                return(_returnValue);
            }
示例#10
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]);
            }
示例#11
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 == "Time")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_time = AgentMeta.ParseProperty(p.value);
                    }
                    else
                    {
                        this.m_time = AgentMeta.ParseMethod(p.value);
                    }
                }
            }
        }
示例#12
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);
            }
示例#13
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;
            }
示例#14
0
        public static IInstanceMember ParseProperty(string value)
        {
            try
            {
                if (string.IsNullOrEmpty(value))
                {
                    return(null);
                }

                List <string> tokens   = StringUtils.SplitTokens(value);
                string        typeName = "";

                if (tokens[0] == "const")
                {
                    // const Int32 0
                    Debug.Check(tokens.Count == 3);

                    const int kConstLength = 5;
                    string    strRemaining = value.Substring(kConstLength + 1);
                    int       p            = StringUtils.FirstToken(strRemaining, ' ', ref typeName);

                    typeName = typeName.Replace("::", ".");

                    string strVale = strRemaining.Substring(p + 1);

                    // const
                    return(AgentMeta.CreateInstanceConst(typeName, strVale));
                }
                else
                {
                    string propStr      = "";
                    string indexPropStr = "";

                    if (tokens[0] == "static")
                    {
                        // static float Self.AgentNodeTest::s_float_type_0
                        // static float Self.AgentNodeTest::s_float_type_0[int Self.AgentNodeTest::par_int_type_2]
                        Debug.Check(tokens.Count == 3 || tokens.Count == 4);

                        typeName = tokens[1];
                        propStr  = tokens[2];
                        if (tokens.Count == 4) // array index
                        {
                            indexPropStr = tokens[3];
                        }
                    }
                    else
                    {
                        // float Self.AgentNodeTest::par_float_type_1
                        // float Self.AgentNodeTest::par_float_type_1[int Self.AgentNodeTest::par_int_type_2]
                        Debug.Check(tokens.Count == 2 || tokens.Count == 3);

                        typeName = tokens[0];
                        propStr  = tokens[1];
                        if (tokens.Count == 3) // array index
                        {
                            indexPropStr = tokens[2];
                        }
                    }

                    string          arrayItem   = "";
                    IInstanceMember indexMember = null;
                    if (!string.IsNullOrEmpty(indexPropStr))
                    {
                        arrayItem   = "[]";
                        indexMember = ParseProperty <int>(indexPropStr);
                    }

                    typeName = typeName.Replace("::", ".");
                    propStr  = propStr.Replace("::", ".");

                    string[] props = propStr.Split('.');
                    Debug.Check(props.Length >= 3);

                    string instantceName = props[0];
                    string propName      = props[props.Length - 1];
                    string className     = props[1];

                    for (int i = 2; i < props.Length - 1; ++i)
                    {
                        className += "." + props[i];
                    }

                    uint      classId = Utils.MakeVariableId(className);
                    AgentMeta meta    = AgentMeta.GetMeta(classId);
                    Debug.Check(meta != null, "please add the exported 'AgentProperties.cs' and 'customizedtypes.cs' into the project!");

                    uint propId = Utils.MakeVariableId(propName + arrayItem);

                    // property
                    IProperty p = meta.GetProperty(propId);
                    if (p != null)
                    {
                        return(p.CreateInstance(instantceName, indexMember));
                    }

                    // local var
                    return(AgentMeta.CreateInstanceProperty(typeName, instantceName, indexMember, propId));
                }
            }
            catch (System.Exception e)
            {
                Debug.Check(false, e.Message);
            }

            return(null);
        }
示例#15
0
 public static IInstanceMember CreatorInstanceProperty <T>(string instance, IInstanceMember indexMember, uint varId)
 {
     return(new CInstanceCustomizedProperty <T>(instance, indexMember, varId));
 }
示例#16
0
        public static IInstanceMember CreateInstanceProperty(string typeName, string instance, IInstanceMember indexMember, uint varId)
        {
            if (_Creators.ContainsKey(typeName))
            {
                TypeCreator creator = _Creators[typeName];
                return(creator.CreateInstanceProperty(instance, indexMember, varId));
            }

            Debug.Check(false);
            return(null);
        }
示例#17
0
 public IInstanceMember CreateInstanceProperty(string instance, IInstanceMember indexMember, uint id)
 {
     return(_instancePropertyCreator(instance, indexMember, id));
 }
示例#18
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))
                    {
                        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);
                }
            }
        }
示例#19
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);
            }
示例#20
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;
            }
 public AutoContextMemberSource(IInstanceMember member)
 {
     this.member = member;
 }