Exemple #1
0
 public virtual void AddChild(BNode child)
 {
     child.m_parent = this;
     this.m_listChildren.Add(child);
 }
Exemple #2
0
        public virtual void ReplaceChild(BNode prenode, BNode node)
        {
            int index = this.m_listChildren.FindIndex((a) => { return(a == prenode); });

            this.m_listChildren[index] = node;
        }
Exemple #3
0
        public virtual void InsertChild(BNode prenode, BNode node)
        {
            int index = this.m_listChildren.FindIndex((a) => { return(a == prenode); });

            this.m_listChildren.Insert(index, node);
        }
Exemple #4
0
 public virtual void RemoveChild(BNode child)
 {
     this.m_listChildren.Remove(child);
 }
Exemple #5
0
 public virtual void InsertChild(BNode child, int index)
 {
     child.m_parent = this;
     this.m_listChildren.Insert(index, child);
 }
Exemple #6
0
        void AddChildNode(JsonData jsonData, BNode fatherNode)
        {
            //Debug.LogError("jsonData  " + jsonData["name"]);
            Type  t         = Type.GetType((string)jsonData["type"]);
            BNode nodeChild = Activator.CreateInstance(t) as BNode;

            #region args
            JsonData       args   = jsonData["args"];
            PropertyInfo[] pInfos = nodeChild.GetType().GetProperties();
            for (int i = 0; i < args.Count; i++)
            {
                JsonData arg = args[i];

                PropertyInfo pi = nodeChild.GetType().GetProperty(arg["argname"].ToString());
                if (Type.GetType(arg["argtype"].ToString()).Equals(typeof(System.String)))
                {
                    pi.SetValue(nodeChild, arg["argvalue"].ToString(), null);
                }
                else if (Type.GetType(arg["argtype"].ToString()).Equals(typeof(System.Single)))
                {
                    pi.SetValue(nodeChild, float.Parse(arg["argvalue"].ToString()), null);
                }
                else if (Type.GetType(arg["argtype"].ToString()).Equals(typeof(System.Int32)))
                {
                    pi.SetValue(nodeChild, int.Parse(arg["argvalue"].ToString()), null);
                }
                else if (Type.GetType(arg["argtype"].ToString()).BaseType.Equals(typeof(System.Enum)))
                {
                    //pi.SetValue(nodeChild, int.Parse(arg["argvalue"].ToString()), null);
                    //arg["argvalue"].ToString()
                    //Debug.LogError("--------------------------------------ffff");

                    FieldInfo   fiSelect = null;
                    FieldInfo[] fields   = pi.PropertyType.GetFields(BindingFlags.Static | BindingFlags.Public);
                    for (int j = 0; j < fields.Length; j++)
                    {
                        FieldInfo fi = fields[j];
                        if (fi.Name.Equals(arg["argvalue"].ToString()))
                        {
                            fiSelect = fi;
                        }
                    }
                    pi.SetValue(nodeChild, fiSelect.GetValue(null), null);
                }
                else if (Type.GetType(arg["argtype"].ToString()).Equals(typeof(System.Boolean)))
                {
                    if (arg["argvalue"].ToString().Equals("True"))
                    {
                        pi.SetValue(nodeChild, true, null);
                    }
                    else
                    {
                        pi.SetValue(nodeChild, false, null);
                    }
                }
            }

            #endregion

            fatherNode.AddChild(nodeChild);

            for (int i = 0; i < jsonData["children"].Count; i++)
            {
                JsonData nodeJson = jsonData["children"][i];
                AddChildNode(nodeJson, nodeChild);
            }
        }