public virtual void AddChild(BNode child) { child.m_parent = this; this.m_listChildren.Add(child); }
public virtual void ReplaceChild(BNode prenode, BNode node) { int index = this.m_listChildren.FindIndex((a) => { return(a == prenode); }); this.m_listChildren[index] = node; }
public virtual void InsertChild(BNode prenode, BNode node) { int index = this.m_listChildren.FindIndex((a) => { return(a == prenode); }); this.m_listChildren.Insert(index, node); }
public virtual void RemoveChild(BNode child) { this.m_listChildren.Remove(child); }
public virtual void InsertChild(BNode child, int index) { child.m_parent = this; this.m_listChildren.Insert(index, child); }
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); } }